Skip to content

create_intent async

create_intent(
    intent_name: Name,
    bot_id: Id,
    bot_version: DraftBotVersion,
    locale_id: LocaleId,
    *,
    config_overrides: Optional[AsyncLexModelsV2ClientConfig] = None,
    intent_display_name: Optional[DisplayName] = None,
    description: Optional[Description] = None,
    parent_intent_signature: Optional[IntentSignature] = None,
    sample_utterances: Optional[SampleUtterancesList] = None,
    dialog_code_hook: Optional[DialogCodeHookSettings] = None,
    fulfillment_code_hook: Optional[FulfillmentCodeHookSettings] = None,
    intent_confirmation_setting: Optional[IntentConfirmationSetting] = None,
    intent_closing_setting: Optional[IntentClosingSetting] = None,
    input_contexts: Optional[InputContextsList] = None,
    output_contexts: Optional[OutputContextsList] = None,
    kendra_configuration: Optional[KendraConfiguration] = None,
    initial_response_setting: Optional[InitialResponseSetting] = None,
    qn_a_intent_configuration: Optional[QnAIntentConfiguration] = None,
    q_in_connect_intent_configuration: Optional[QInConnectIntentConfiguration] = None,
) -> CreateIntentResponse

Creates an intent.

To define the interaction between the user and your bot, you define one or more intents. For example, for a pizza ordering bot you would create an OrderPizza intent.

When you create an intent, you must provide a name. You can optionally provide the following:

  • Sample utterances. For example, "I want to order a pizza" and "Can I order a pizza." You can't provide utterances for built-in intents.

  • Information to be gathered. You specify slots for the information that you bot requests from the user. You can specify standard slot types, such as date and time, or custom slot types for your application.

  • How the intent is fulfilled. You can provide a Lambda function or configure the intent to return the intent information to your client application. If you use a Lambda function, Amazon Lex invokes the function when all of the intent information is available.

  • A confirmation prompt to send to the user to confirm an intent. For example, "Shall I order your pizza?"

  • A conclusion statement to send to the user after the intent is fulfilled. For example, "I ordered your pizza."

  • A follow-up prompt that asks the user for additional activity. For example, "Do you want a drink with your pizza?"

Parameters:

  • intent_name (Name) –

    The name of the intent. Intent names must be unique in the locale that contains the intent and cannot match the name of any built-in intent.

  • intent_display_name (Optional[DisplayName], default: None ) –

    A display name for the intent. If configured, This name will be shown to users during Intent Disambiguation instead of the intent name. Display names should be user-friendly, descriptive and match the intent's purpose to improve user experience during disambiguation.

  • description (Optional[Description], default: None ) –

    A description of the intent. Use the description to help identify the intent in lists.

  • parent_intent_signature (Optional[IntentSignature], default: None ) –

    A unique identifier for the built-in intent to base this intent on.

  • sample_utterances (Optional[SampleUtterancesList], default: None ) –

    An array of strings that a user might say to signal the intent. For example, "I want a pizza", or "I want a {PizzaSize} pizza".

    In an utterance, slot names are enclosed in curly braces ("{", "}") to indicate where they should be displayed in the utterance shown to the user..

  • dialog_code_hook (Optional[DialogCodeHookSettings], default: None ) –

    Specifies that Amazon Lex invokes the alias Lambda function for each user input. You can invoke this Lambda function to personalize user interaction.

    For example, suppose that your bot determines that the user's name is John. You Lambda function might retrieve John's information from a backend database and prepopulate some of the values. For example, if you find that John is gluten intolerant, you might set the corresponding intent slot, glutenIntolerant to true. You might find John's phone number and set the corresponding session attribute.

  • fulfillment_code_hook (Optional[FulfillmentCodeHookSettings], default: None ) –

    Specifies that Amazon Lex invokes the alias Lambda function when the intent is ready for fulfillment. You can invoke this function to complete the bot's transaction with the user.

    For example, in a pizza ordering bot, the Lambda function can look up the closest pizza restaurant to the customer's location and then place an order on the customer's behalf.

  • intent_confirmation_setting (Optional[IntentConfirmationSetting], default: None ) –

    Provides prompts that Amazon Lex sends to the user to confirm the completion of an intent. If the user answers "no," the settings contain a statement that is sent to the user to end the intent.

  • intent_closing_setting (Optional[IntentClosingSetting], default: None ) –

    Sets the response that Amazon Lex sends to the user when the intent is closed.

  • input_contexts (Optional[InputContextsList], default: None ) –

    A list of contexts that must be active for this intent to be considered by Amazon Lex.

    When an intent has an input context list, Amazon Lex only considers using the intent in an interaction with the user when the specified contexts are included in the active context list for the session. If the contexts are not active, then Amazon Lex will not use the intent.

    A context can be automatically activated using the outputContexts property or it can be set at runtime.

    For example, if there are two intents with different input contexts that respond to the same utterances, only the intent with the active context will respond.

    An intent may have up to 5 input contexts. If an intent has multiple input contexts, all of the contexts must be active to consider the intent.

  • output_contexts (Optional[OutputContextsList], default: None ) –

    A lists of contexts that the intent activates when it is fulfilled.

    You can use an output context to indicate the intents that Amazon Lex should consider for the next turn of the conversation with a customer.

    When you use the outputContextsList property, all of the contexts specified in the list are activated when the intent is fulfilled. You can set up to 10 output contexts. You can also set the number of conversation turns that the context should be active, or the length of time that the context should be active.

  • kendra_configuration (Optional[KendraConfiguration], default: None ) –

    Configuration information required to use the AMAZON.KendraSearchIntent intent to connect to an Amazon Kendra index. The AMAZON.KendraSearchIntent intent is called when Amazon Lex can't determine another intent to invoke.

  • bot_id (Id) –

    The identifier of the bot associated with this intent.

  • bot_version (DraftBotVersion) –

    The version of the bot associated with this intent.

  • locale_id (LocaleId) –

    The identifier of the language and locale where this intent is used. All of the bots, slot types, and slots used by the intent must have the same locale. For more information, see Supported languages.

  • initial_response_setting (Optional[InitialResponseSetting], default: None ) –

    Configuration settings for the response that is sent to the user at the beginning of a conversation, before eliciting slot values.

  • qn_a_intent_configuration (Optional[QnAIntentConfiguration], default: None ) –

    Specifies the configuration of the built-in Amazon.QnAIntent. The AMAZON.QnAIntent intent is called when Amazon Lex can't determine another intent to invoke. If you specify this field, you can't specify the kendraConfiguration field.

  • q_in_connect_intent_configuration (Optional[QInConnectIntentConfiguration], default: None ) –

    Qinconnect intent configuration details for the create intent request.

Raises:

  • ConflictException –

    The action that you tried to perform couldn't be completed because the resource is in a conflicting state. For example, deleting a bot that is in the CREATING state. Try your request again.

  • InternalServerException –

    The service encountered an unexpected condition. Try your request again.

  • PreconditionFailedException –

    Your request couldn't be completed because one or more request fields aren't valid. Check the fields in your request and try again.

  • ServiceQuotaExceededException –

    You have reached a quota for your bot.

  • ThrottlingException –

    Your request rate is too high. Reduce the frequency of requests.

  • ValidationException –

    One of the input parameters in your request isn't valid. Check the parameters and try your request again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_lex_models_v2/_services/async_lex_models_v2.py
async def create_intent(
    self,
    intent_name: "capo_lex_models_v2.types.name.Name",
    bot_id: "capo_lex_models_v2.types.id.Id",
    bot_version: "capo_lex_models_v2.types.draft_bot_version.DraftBotVersion",
    locale_id: "capo_lex_models_v2.types.locale_id.LocaleId",
    *,
    config_overrides: Optional[AsyncLexModelsV2ClientConfig] = None,
    intent_display_name: Optional[
        "capo_lex_models_v2.types.display_name.DisplayName"
    ] = None,
    description: Optional[
        "capo_lex_models_v2.types.description.Description"
    ] = None,
    parent_intent_signature: Optional[
        "capo_lex_models_v2.types.intent_signature.IntentSignature"
    ] = None,
    sample_utterances: Optional[
        "capo_lex_models_v2.types.sample_utterances_list.SampleUtterancesList"
    ] = None,
    dialog_code_hook: Optional[
        "capo_lex_models_v2.types.dialog_code_hook_settings.DialogCodeHookSettings"
    ] = None,
    fulfillment_code_hook: Optional[
        "capo_lex_models_v2.types.fulfillment_code_hook_settings.FulfillmentCodeHookSettings"
    ] = None,
    intent_confirmation_setting: Optional[
        "capo_lex_models_v2.types.intent_confirmation_setting.IntentConfirmationSetting"
    ] = None,
    intent_closing_setting: Optional[
        "capo_lex_models_v2.types.intent_closing_setting.IntentClosingSetting"
    ] = None,
    input_contexts: Optional[
        "capo_lex_models_v2.types.input_contexts_list.InputContextsList"
    ] = None,
    output_contexts: Optional[
        "capo_lex_models_v2.types.output_contexts_list.OutputContextsList"
    ] = None,
    kendra_configuration: Optional[
        "capo_lex_models_v2.types.kendra_configuration.KendraConfiguration"
    ] = None,
    initial_response_setting: Optional[
        "capo_lex_models_v2.types.initial_response_setting.InitialResponseSetting"
    ] = None,
    qn_a_intent_configuration: Optional[
        "capo_lex_models_v2.types.qn_a_intent_configuration.QnAIntentConfiguration"
    ] = None,
    q_in_connect_intent_configuration: Optional[
        "capo_lex_models_v2.types.q_in_connect_intent_configuration.QInConnectIntentConfiguration"
    ] = None,
) -> "capo_lex_models_v2.types.create_intent_response.CreateIntentResponse":
    """<p>Creates an intent.</p> <p>To define the interaction between the user and your bot, you define one or more intents. For example, for a pizza ordering bot you would create an <code>OrderPizza</code> intent.</p> <p>When you create an intent, you must provide a name. You can optionally provide the following:</p> <ul> <li> <p>Sample utterances. For example, "I want to order a pizza" and "Can I order a pizza." You can't provide utterances for built-in intents.</p> </li> <li> <p>Information to be gathered. You specify slots for the information that you bot requests from the user. You can specify standard slot types, such as date and time, or custom slot types for your application.</p> </li> <li> <p>How the intent is fulfilled. You can provide a Lambda function or configure the intent to return the intent information to your client application. If you use a Lambda function, Amazon Lex invokes the function when all of the intent information is available.</p> </li> <li> <p>A confirmation prompt to send to the user to confirm an intent. For example, "Shall I order your pizza?"</p> </li> <li> <p>A conclusion statement to send to the user after the intent is fulfilled. For example, "I ordered your pizza."</p> </li> <li> <p>A follow-up prompt that asks the user for additional activity. For example, "Do you want a drink with your pizza?"</p> </li> </ul>

    Args:
        intent_name: <p>The name of the intent. Intent names must be unique in the locale that contains the intent and cannot match the name of any built-in intent.</p>
        intent_display_name: <p>A display name for the intent. If configured, This name will be shown to users during Intent Disambiguation instead of the intent name. Display names should be user-friendly, descriptive and match the intent's purpose to improve user experience during disambiguation.</p>
        description: <p>A description of the intent. Use the description to help identify the intent in lists.</p>
        parent_intent_signature: <p>A unique identifier for the built-in intent to base this intent on.</p>
        sample_utterances: <p>An array of strings that a user might say to signal the intent. For example, "I want a pizza", or "I want a {PizzaSize} pizza". </p> <p>In an utterance, slot names are enclosed in curly braces ("{", "}") to indicate where they should be displayed in the utterance shown to the user.. </p>
        dialog_code_hook: <p>Specifies that Amazon Lex invokes the alias Lambda function for each user input. You can invoke this Lambda function to personalize user interaction.</p> <p>For example, suppose that your bot determines that the user's name is John. You Lambda function might retrieve John's information from a backend database and prepopulate some of the values. For example, if you find that John is gluten intolerant, you might set the corresponding intent slot, <code>glutenIntolerant</code> to <code>true</code>. You might find John's phone number and set the corresponding session attribute.</p>
        fulfillment_code_hook: <p>Specifies that Amazon Lex invokes the alias Lambda function when the intent is ready for fulfillment. You can invoke this function to complete the bot's transaction with the user.</p> <p>For example, in a pizza ordering bot, the Lambda function can look up the closest pizza restaurant to the customer's location and then place an order on the customer's behalf.</p>
        intent_confirmation_setting: <p>Provides prompts that Amazon Lex sends to the user to confirm the completion of an intent. If the user answers "no," the settings contain a statement that is sent to the user to end the intent.</p>
        intent_closing_setting: <p>Sets the response that Amazon Lex sends to the user when the intent is closed.</p>
        input_contexts: <p>A list of contexts that must be active for this intent to be considered by Amazon Lex.</p> <p>When an intent has an input context list, Amazon Lex only considers using the intent in an interaction with the user when the specified contexts are included in the active context list for the session. If the contexts are not active, then Amazon Lex will not use the intent.</p> <p>A context can be automatically activated using the <code>outputContexts</code> property or it can be set at runtime.</p> <p> For example, if there are two intents with different input contexts that respond to the same utterances, only the intent with the active context will respond.</p> <p>An intent may have up to 5 input contexts. If an intent has multiple input contexts, all of the contexts must be active to consider the intent.</p>
        output_contexts: <p>A lists of contexts that the intent activates when it is fulfilled.</p> <p>You can use an output context to indicate the intents that Amazon Lex should consider for the next turn of the conversation with a customer. </p> <p>When you use the <code>outputContextsList</code> property, all of the contexts specified in the list are activated when the intent is fulfilled. You can set up to 10 output contexts. You can also set the number of conversation turns that the context should be active, or the length of time that the context should be active.</p>
        kendra_configuration: <p>Configuration information required to use the <code>AMAZON.KendraSearchIntent</code> intent to connect to an Amazon Kendra index. The <code>AMAZON.KendraSearchIntent</code> intent is called when Amazon Lex can't determine another intent to invoke.</p>
        bot_id: <p>The identifier of the bot associated with this intent.</p>
        bot_version: <p>The version of the bot associated with this intent.</p>
        locale_id: <p>The identifier of the language and locale where this intent is used. All of the bots, slot types, and slots used by the intent must have the same locale. For more information, see <a href="https://docs.aws.amazon.com/lexv2/latest/dg/how-languages.html">Supported languages</a>.</p>
        initial_response_setting: <p>Configuration settings for the response that is sent to the user at the beginning of a conversation, before eliciting slot values.</p>
        qn_a_intent_configuration: <p>Specifies the configuration of the built-in <code>Amazon.QnAIntent</code>. The <code>AMAZON.QnAIntent</code> intent is called when Amazon Lex can't determine another intent to invoke. If you specify this field, you can't specify the <code>kendraConfiguration</code> field.</p>
        q_in_connect_intent_configuration: <p>Qinconnect intent configuration details for the create intent request.</p>

    Raises:
        capo_lex_models_v2.errors.conflict_exception.ConflictException: <p>The action that you tried to perform couldn't be completed because the resource is in a conflicting state. For example, deleting a bot that is in the CREATING state. Try your request again. </p>
        capo_lex_models_v2.errors.internal_server_exception.InternalServerException: <p>The service encountered an unexpected condition. Try your request again.</p>
        capo_lex_models_v2.errors.precondition_failed_exception.PreconditionFailedException: <p>Your request couldn't be completed because one or more request fields aren't valid. Check the fields in your request and try again.</p>
        capo_lex_models_v2.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You have reached a quota for your bot. </p>
        capo_lex_models_v2.errors.throttling_exception.ThrottlingException: <p>Your request rate is too high. Reduce the frequency of requests.</p>
        capo_lex_models_v2.errors.validation_exception.ValidationException: <p>One of the input parameters in your request isn't valid. Check the parameters and try your request again.</p>
        capo_lex_models_v2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lex_models_v2.types.create_intent_request.CreateIntentRequest]",
    ) -> AsyncOperationResponse[
        "capo_lex_models_v2.types.create_intent_response.CreateIntentResponse"
    ]:
        import capo_lex_models_v2._operations.lex_model_building_service_v2.create_intent

        (
            output,
            http_response,
        ) = await capo_lex_models_v2._operations.lex_model_building_service_v2.create_intent.async_create_intent(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateIntent")
    )
    input_: capo_lex_models_v2.types.create_intent_request.CreateIntentRequest = {
        "intent_name": intent_name,
        "bot_id": bot_id,
        "bot_version": bot_version,
        "locale_id": locale_id,
    }
    if intent_display_name is not None:
        input_["intent_display_name"] = intent_display_name
    if description is not None:
        input_["description"] = description
    if parent_intent_signature is not None:
        input_["parent_intent_signature"] = parent_intent_signature
    if sample_utterances is not None:
        input_["sample_utterances"] = sample_utterances
    if dialog_code_hook is not None:
        input_["dialog_code_hook"] = dialog_code_hook
    if fulfillment_code_hook is not None:
        input_["fulfillment_code_hook"] = fulfillment_code_hook
    if intent_confirmation_setting is not None:
        input_["intent_confirmation_setting"] = intent_confirmation_setting
    if intent_closing_setting is not None:
        input_["intent_closing_setting"] = intent_closing_setting
    if input_contexts is not None:
        input_["input_contexts"] = input_contexts
    if output_contexts is not None:
        input_["output_contexts"] = output_contexts
    if kendra_configuration is not None:
        input_["kendra_configuration"] = kendra_configuration
    if initial_response_setting is not None:
        input_["initial_response_setting"] = initial_response_setting
    if qn_a_intent_configuration is not None:
        input_["qn_a_intent_configuration"] = qn_a_intent_configuration
    if q_in_connect_intent_configuration is not None:
        input_["q_in_connect_intent_configuration"] = (
            q_in_connect_intent_configuration
        )

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output