

End of support notice: On September 15, 2025, AWS will discontinue support for Amazon Lex V1. After September 15, 2025, you will no longer be able to access the Amazon Lex V1 console or Amazon Lex V1 resources. If you are using Amazon Lex V2, refer to the [Amazon Lex V2 guide](https://docs.aws.amazon.com/lexv2/latest/dg/what-is.html) instead. . 

# Built-in Intents and Slot Types
<a name="howitworks-builtins"></a>

To make it easier to create bots, Amazon Lex allows you to use standard built-in intents and slot types. 

**Topics**
+ [Built-in Intents](howitworks-builtins-intents.md)
+ [Built-in Slot Types](howitworks-builtins-slots.md)

# Built-in Intents
<a name="howitworks-builtins-intents"></a>

For common actions, you can use the standard built-in intents library. To create an intent from a built-in intent, choose a built-intent in the console, and give it a new name. The new intent has the configuration of the base intent, such as the sample utterances. 

In the current implementation, you can't do the following: 
+ Add or remove sample utterances from the base intent
+ Configure slots for built-in intents

**To add a built-in intent to a bot**

1. Sign in to the AWS Management Console and open the Amazon Lex console at [https://console.aws.amazon.com/lex/](https://console.aws.amazon.com/lex/).

1. Choose the bot to add the built-in intent to.

1. In the navigation pane, choose the plus (\$1) next to **Intents**.

1. For **Add intent**, choose **Search existing intents**.

1. In the **Search intents** box, type the name of the built-in intent to add to your bot.

1. For **Copy built-in intent**, give the intent a name, and then choose **Add**.

1. Configure the intent as required for your bot.

**Topics**
+ [AMAZON.CancelIntent](built-in-intent-cancel.md)
+ [AMAZON.FallbackIntent](built-in-intent-fallback.md)
+ [AMAZON.HelpIntent](built-in-intent-help.md)
+ [AMAZON.KendraSearchIntent](built-in-intent-kendra-search.md)
+ [AMAZON.PauseIntent](built-in-intent-pause.md)
+ [AMAZON.RepeatIntent](built-in-intent-repeat.md)
+ [AMAZON.ResumeIntent](built-in-intent-resume.md)
+ [AMAZON.StartOverIntent](built-in-intent-start-over.md)
+ [AMAZON.StopIntent](built-in-intent-stop.md)

**Note**  
For the English (US) (en-US) locale, Amazon Lex supports intents from the Alexa standard built-in intents. For a list of built-in intents, see [Standard Built-in Intents](https://developer.amazon.com/docs/custom-skills/standard-built-in-intents.html) in the *Alexa Skills Kit*.  
Amazon Lex doesn't support the following intents:  
`AMAZON.YesIntent`
`AMAZON.NoIntent` 
The intents in the [Built-in Intent Library](https://developer.amazon.com/docs/custom-skills/built-in-intent-library.html) in the *Alexa Skills Kit*

# AMAZON.CancelIntent
<a name="built-in-intent-cancel"></a>

Responds to words and phrases that indicate the user wants to cancel the current interaction. Your application can use this intent to remove slot type values and other attributes before ending the interaction with the user.

Common utterances:
+ cancel
+ never mind
+ forget it

# AMAZON.FallbackIntent
<a name="built-in-intent-fallback"></a>

When a user's input to an intent isn't what a bot expects, you can configure Amazon Lex to invoke a *fallback intent*. For example, if the user input "I'd like to order candy" doesn't match an intent in your `OrderFlowers` bot, Amazon Lex invokes the fallback intent to handle the response.

You add a fallback intent by adding the built-in `AMAZON.FallbackIntent` intent type to your bot. You can specify the intent using the [PutBot](API_PutBot.md) operation or by choosing the intent from the list of built-in intents in the console. 

Invoking a fallback intent uses two steps. In the first step the fallback intent is matched based on the input from the user. When the fallback intent is matched, the way the bot behaves depends on the number of retries configured for a prompt. For example, if the maximum number of attempts to determine an intent is 2, the bot returns the bot's clarification prompt twice before invoking the fallback intent.

Amazon Lex matches the fallback intent in these situations: 
+ The user's input to an intent doesn't match the input that the bot expects
+ Audio input is noise, or text input isn't recognized as words.
+ The user's input is ambiguous and Amazon Lex can't determine which intent to invoke.

The fallback intent is invoked when:
+ The bot doesn't recognize the user input as an intent after the configured number of tries for clarification when the conversation is started.
+ An intent doesn't recognize the user input as a slot value after the configured number of tries.
+ An intent doesn't recognize the user input as a response to a confirmation prompt after the configured number of tries.

You can use the following with a fallback intent:
+ A fulfillment Lambda function
+ A conclusion statement
+ A follow up prompt

You can't add the following to a fallback intent:
+ Utterances
+ Slots
+ An initialization and validation Lambda function 
+ A confirmation prompt

If you have configured both a cancel statement and a fallback intent for a bot, Amazon Lex uses the fallback intent. If you need your bot to have a cancel statement, you can use the fulfillment function for the fallback intent to provide the same behavior as a cancel statement. For more information, see the `abortStatement` parameter of the [PutBot](API_PutBot.md) operation.

## Using Clarification Prompts
<a name="fallback-clarification"></a>

If you provide your bot with a clarification prompt, the prompt is used to solicit a valid intent from the user. The clarification prompt will be repeated the number of times that you configured. After that the fallback intent will be invoked.

If you don't set a clarification prompt when you create a bot and the user doesn't start the conversation with a valid intent, Amazon Lex immediately calls your fallback intent . 

When you use a fallback intent without a clarification prompt, Amazon Lex doesn't call the fallback under these circumstances:
+ When the user responds to a follow-up prompt but doesn't provide an intent. For example, in response to a follow-up prompt that says "Would you like anything else today?", the user says "Yes." Amazon Lex returns a 400 Bad Request exception because it doesn't have a clarification prompt to send to the user to get an intent.
+ When using an AWS Lambda function, you return an `ElicitIntent` dialog type. Because Amazon Lex doesn't have a clarification prompt to get an intent from the user, it returns a 400 Bad Request exception.
+ When using the `PutSession` operation, you send an `ElicitIntent` dialog type. Because Amazon Lex doesn't have a clarification prompt to get an intent from the user, it returns a 400 Bad Request exception.

## Using a Lambda Function with a Fallback Intent
<a name="invoke-fallback"></a>

When a fallback intent is invoked, the response depends on the setting of the `fulfillmentActivity` parameter to the [PutIntent](API_PutIntent.md) operation. The bot does one of the following:
+ Returns the intent information to the client application.
+ Calls the fulfillment Lambda function. It calls the function with the session variables that are set for the session.

For more information about setting the response when a fallback intent is invoked, see the `fulfillmentActivity` parameter of the [PutIntent](API_PutIntent.md) operation. 

If you use the fulfillment Lambda function in your fallback intent, you can use this function to call another intent or to perform some form of communication with the user, such as collecting a callback number or opening a session with a customer service representative.

You can perform any action in a fallback intent Lambda function that you can perform in the fulfillment function for any other intent. For more information about creating a fulfillment function using AWS Lambda, see [Using Lambda Functions](using-lambda.md).

A fallback intent can be invoked multiple times in the same session. For example, suppose that your Lambda function uses the `ElicitIntent` dialog action to prompt the user for a different intent. If Amazon Lex can't infer the user's intent after the configured number of tries, it invokes the fallback intent again. It also invokes the fallback intent when the user doesn't respond with a valid slot value after the configured number of tries.

You can configure a Lambda function to keep track of the number of times that the fallback intent is called using a session variable. Your Lambda function can take a different action if it is called more times than the threshold that you set in your Lambda function. For more information about session variables, see [Setting Session Attributes](context-mgmt-session-attribs.md).

# AMAZON.HelpIntent
<a name="built-in-intent-help"></a>

Responds to words or phrases that indicate the user needs help while interacting with your bot. When this intent is invoked, you can configure your Lambda function or application to provide information about the your bot's capabilities, ask follow up questions about areas of help, or hand the interaction over to a human agent. 

Common utterances:
+ help
+ help me
+ can you help me

# AMAZON.KendraSearchIntent
<a name="built-in-intent-kendra-search"></a>

To search documents that you have indexed with Amazon Kendra, use the `AMAZON.KendraSearchIntent` intent. When Amazon Lex can't determine the next action in a conversation with the user, it triggers the search intent.

The `AMAZON.KendraSearchIntent` is available only in the English (US) (en-US) locale and in the US East (N. Virginia), US West (Oregon) and Europe (Ireland) Regions.

Amazon Kendra is a machine-learning-based search service that indexes natural language documents such as PDF documents or Microsoft Word files. It can search indexed documents and return the following types of responses to a question:
+ An answer 
+ An entry from a FAQ that might answer the question
+ A document that is related to the question

For an example of using the `AMAZON.KendraSearchIntent`, see [Example: Creating a FAQ Bot for an Amazon Kendra Index](faq-bot-kendra-search.md).

If you configure an `AMAZON.KendraSearchIntent` intent for your bot, Amazon Lex calls the intent whenever it can't determine the user utterance for a slot or intent. For example, if your bot is eliciting a response for a slot type called "pizza topping" and the user says "What is a pizza?," Amazon Lex calls the `AMAZON.KendraSearchIntent` to handle the question. If there is no response from Amazon Kendra, the conversation continues as configured in the bot.

When you use both the `AMAZON.KendraSearchIntent` and the `AMAZON.FallbackIntent` in the same bot, Amazon Lex uses the intents as follows:

1. Amazon Lex calls the `AMAZON.KendraSearchIntent`. The intent calls the Amazon Kendra `Query` operation.

1. If Amazon Kendra returns a response, Amazon Lex displays the result to the user.

1. If there is no response from Amazon Kendra, Amazon Lex re-prompts the user. The next action depends on response from the user.
   + If the response from the user contains an utterance that Amazon Lex recognizes, such as filling a slot value or confirming an intent, the conversation with the user proceeds as configured for the bot.
   + If the response from the user does not contain an utterance that Amazon Lex recognizes, Amazon Lex makes another call to the `Query` operation.

1. If there is no response after the configured number of retries, Amazon Lex calls the `AMAZON.FallbackIntent` and ends the conversation with the user.

There are three ways to use the `AMAZON.KendraSearchIntent` to make a request to Amazon Kendra:
+ Let the search intent make the request for you. Amazon Lex calls Amazon Kendra with the user's utterance as the search string. When you create the intent, you can define a query filter string that limits the number of responses that Amazon Kendra returns. Amazon Lex uses the filter in the query request.
+ Add additional query parameters to the request to narrow the search results using your dialog Lambda function. You add a `kendraQueryFilterString` field that contains Amazon Kendra query parameters to the `delegate` dialog action. When you add query parameters to the request with the Lambda function, they take precedence over the query filter that you defined when you created the intent.
+ Create a new query using the dialog Lambda function. You can create a complete Amazon Kendra query request that Amazon Lex sends. You specify the query in the `kendraQueryRequestPayload` field in the `delegate` dialog action. The `kendraQueryRequestPayload` field takes precedence over the `kendraQueryFilterString` field.

To specify the `queryFilterString` parameter when you create a bot, or to specify the `kendraQueryFilterString` field when you call the `delegate` action in a dialog Lambda function, you specify a string that is used as the attribute filter for the Amazon Kendra query. If the string isn't a valid attribute filter, you'll get an `InvalidBotConfigException` exception at runtime. For more information about attribute filters, see [Using document attributes to filter queries](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html#search-filtering) in the *Amazon Kendra Developer Guide*.

To have control over the query that Amazon Lex sends to Amazon Kendra, you can specify a query in the `kendraQueryRequestPayload`field in your dialog Lambda function. If the query isn't valid, Amazon Lex returns an `InvalidLambdaResponseException` exception. For more information, see the [Query operation](https://docs.aws.amazon.com/kendra/latest/dg/API_Query.html) in the *Amazon Kendra Developer Guide*.

For an example of how to use the `AMAZON.KendraSearchIntent`, see [Example: Creating a FAQ Bot for an Amazon Kendra Index](faq-bot-kendra-search.md).

## IAM Policy for Amazon Kendra Search
<a name="kendra-search-iam"></a>

To use the `AMAZON.KendraSearchIntent` intent, you must use a role that provides AWS Identity and Access Management (IAM) policies that enable Amazon Lex to assume a runtime role that has permission to call the Amazon Kendra `Query` intent. The IAM settings that you use depend on whether you create the `AMAZON.KendraSearchIntent` using the Amazon Lex console, or using an AWS SDK or the AWS Command Line Interface (AWS CLI). When you use the console, you can choose between adding permission to call Amazon Kendra to the Amazon Lex service-linked role or using a role specifically for calling the Amazon Kendra `Query` operation. When you use the AWS CLI or an SDK to create the intent, you must use a role specifically for calling the `Query` operation.

### Attaching Permissions
<a name="kendra-iam-attach"></a>

You can use the console to attach permissions to access the Amazon Kendra `Query` operation to the default Amazon Lex service-linked role. When you attach permissions to the service-linked role, you don't have to create and manage a runtime role specifically to connect to the Amazon Kendra index.

The user, role, or group that you use to access the Amazon Lex console must have permissions to manage role policies. Attach the following IAM policy to the console access role. When you grant these permissions, the role has permissions to change the existing service-linked role policy. 

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "iam:AttachRolePolicy",
                "iam:PutRolePolicy",
                "iam:GetRolePolicy"
            ],
            "Resource": "arn:aws:iam::*:role/aws-service-role/lex.amazonaws.com/AWSServiceRoleForLexBots"
        },
        {
            "Effect": "Allow",
            "Action": "iam:ListRoles",
            "Resource": "*"
        }
    ]
}
```

------

### Specifying a Role
<a name="kendra-iam-role"></a>

You can use the console, the AWS CLI, or the API to specify a runtime role to use when calling the Amazon Kendra `Query` operation. 

The user, role, or group that you use to specify the runtime role must have the `iam:PassRole` permission. The following policy defines the permission. You can use the `iam:AssociatedResourceArn` and `iam:PassedToService` condition context keys to further limit the scope of the permissions. For more information, see [ IAM and AWS STS Condition Context Keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_iam-condition-keys.html) in the *AWS Identity and Access Management User Guide*.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "iam:PassRole",
            "Resource": "arn:aws:iam::111122223333:role/role"
        }
    ]
}
```

------

The runtime role that Amazon Lex needs to use to call Amazon Kendra must have the `kendra:Query` permissions. When you use an existing IAM role for permission to call the Amazon Kendra `Query` operation, the role must have the following policy attached.

You can use the IAM console, the IAM API, or the AWS CLI to create a policy and attach it to a role. These instructions use the AWS CLI to create the role and policies.

**Note**  
The following code is formatted for Linux and MacOS. For Windows, replace the Linux line continuation character (\$1) with a caret (^).

**To add Query operation permission to a role**

1. Create a document called **KendraQueryPolicy.json** in the current directory, add the following code to it, and save it

1. In the AWS CLI, run the following command to create the IAM policy for running the Amazon Kendra `Query` operation.

   ```
   aws iam create-policy \
       --policy-name query-policy-name \
       --policy-document file://KendraQueryPolicy.json
   ```

1. Attach the policy to the IAM role that you are using to call the `Query` operation.

   ```
   aws iam attach-role-policy \
       --policy-arn arn:aws:iam::account-id:policy/query-policy-name
       --role-name role-name
   ```

You can choose to update the Amazon Lex service-linked role or to use a role that you created when you create the `AMAZON.KendraSearchIntent` for your bot. The following procedure shows how to choose the IAM role to use.

**To specify the runtime role for AMAZON.KendraSearchIntent**

1. Sign in to the AWS Management Console and open the Amazon Lex console at [https://console.aws.amazon.com/lex/](https://console.aws.amazon.com/lex/).

1. Choose the bot that you want to add the `AMAZON.KendraSearchIntent` to.

1. Choose the plus (\$1) next to **Intents**.

1. In **Add intent**, choose **Search existing intents**.

1. In **Search intents**, enter **AMAZON.KendraSearchIntent** and then choose **Add**.

1. In **Copy built-in intent**, enter a name for the intent, such as **KendraSearchIntent**, and then choose **Add**.

1. Open the **Amazon Kendra query** section.

1. For **IAM role** choose one of the following options:
   + To update the Amazon Lex service-linked role to enable your bot to query Amazon Kendra indexes, choose **Add Amazon Kendra permissions**.
   + To use a role that has permission to call the Amazon Kendra `Query` operation, choose **Use an existing role**.

## Using Request and Session Attributes as Filters
<a name="kendra-search-filter"></a>

To filter the response from Amazon Kendra to items related to current conversation, use session and request attributes as filters by adding the `queryFilterString` parameter when you create your bot. You specify a placeholder for the attribute when you create the intent, and then Amazon Lex V2 substitutes a value before it calls Amazon Kendra. For more information about request attributes, see [Setting Request Attributes](context-mgmt-request-attribs.md). For more information about session attributes, see [Setting Session Attributes](context-mgmt-session-attribs.md).

The following is a example of a `queryFilterString` parameter that uses a string to filter the Amazon Kendra query.

```
"{"equalsTo": {"key": "City", "value": {"stringValue": "Seattle"}}}"
```

The following is an example of a `queryFilterString` parameter that uses a session attribute called `"SourceURI"` to filter the Amazon Kendra query.

```
"{"equalsTo": {"key": "SourceURI","value": {"stringValue": "[FileURL]"}}}"
```

The following is an example of a `queryFilterString` parameter that uses a request attribute called `"DepartmentName"` to filter the Amazon Kendra query.

```
"{"equalsTo": {"key": "Department","value": {"stringValue": "((DepartmentName))"}}}"
```

The `AMAZON.KendraSearchInteng` filters use the same format as the Amazon Kendra search filters. For more information, see [Using document attributes to filter search results](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html#search-filtering) in the *Amazon Kendra developer guide*.

The query filter string used with the `AMAZON.KendraSearchIntent` must use lower-case letters for the first letter of each filter. For example, the following is a valid query filter for the `AMAZON.KendraSearchIntent`.

```
{
    "andAllFilters": [
        {
            "equalsTo": {
                "key": "City",
                "value": {
                    "stringValue": "Seattle"
                }
            }
        },
        {
            "equalsTo": {
                "key": "State",
                "value": {
                    "stringValue": "Washington"
                }
            }
        }
    ]
}
```

## Using the Search Response
<a name="kendra-search-response"></a>

Amazon Kendra returns the response to a search in the intent's `conclusion` statement. The intent must have a `conclusion` statement unless a fulfillment Lambda function produces a conclusion message.

Amazon Kendra has four types of responses. 
+ `x-amz-lex:kendra-search-response-question_answer-question-<N>` – The question from a FAQ that matches the search.
+ `x-amz-lex:kendra-search-response-question_answer-answer-<N>` – The answer from a FAQ that matches the search.
+ `x-amz-lex:kendra-search-response-document-<N>` – An excerpt from a document in the index that is related to the text of the utterance.
+ `x-amz-lex:kendra-search-response-document-link-<N>` – The URL of a document in the index that is related to the text of the utterance.
+ `x-amz-lex:kendra-search-response-answer-<N>` – An excerpt from a document in the index that answers the question.

The responses are returned in `request` attributes. There can be up to five responses for each attribute, numbered 1 through 5. For more information about responses, see [Types of response](https://docs.aws.amazon.com/kendra/latest/dg/response-types.html) in the *Amazon Kendra Developer Guide*. 

The `conclusion` statement must have one or more message groups. Each message group contains one or more messages. Each message can contain one or more placeholder variables that are replaced by request attributes in the response from Amazon Kendra. There must be at least one message in the message group where all of the variables in the message are replaced by request attribute values in the runtime response, or there must be a message in the group with no placeholder variables. The request attributes are set off with double parentheses ("((" "))"). The following message group messages match any response from Amazon Kendra:
+ “I found a FAQ question for you: ((x-amz-lex:kendra-search-response-question\$1answer-question-1)), and the answer is ((x-amz-lex:kendra-search-response-question\$1answer-answer-1))”
+ “I found an excerpt from a helpful document: ((x-amz-lex:kendra-search-response-document-1))”
+ “I think the answer to your questions is ((x-amz-lex:kendra-search-response-answer-1))”

## Using a Lambda Function to Manage the Request and Response
<a name="kendra-search-lambda"></a>

The `AMAZON.KendraSearchIntent` intent can use your dialog code hook and fulfillment code hook to manage the request to Amazon Kendra and the response. Use the dialog code hook Lambda function when you want to modify the query that you send to Amazon Kendra, and the fulfillment code hook Lambda function when you want to modify the response.

### Creating a Query with the Dialog Code Hook
<a name="kendra-search-lambda-dialog"></a>

You can use the dialog code hook to create a query to send to Amazon Kendra. Using the dialog code hook is optional. If you don't specify a dialog code hook, Amazon Lex constructs a query from the user utterance and uses the `queryFilterString` that you provided when you configured the intent, if you provided one.

You can use two fields in the dialog code hook response to modify the request to Amazon Kendra:
+ `kendraQueryFilterString` – Use this string to specify attribute filters for the Amazon Kendra request. You can filter the query using any of the index fields defined in your index. For the structure of the filter string, see [Using document attributes to filter queries](https://docs.aws.amazon.com/kendra/latest/dg/filtering.html#search-filtering) in the *Amazon Kendra Developer Guide*. If the specified filter string isn't valid, you will get an `InvalidLambdaResponseException` exception. The `kendraQueryFilterString` string overrides any query string specified in the `queryFilterString` configured for the intent.
+ `kendraQueryRequestPayload` – Use this string to specify an Amazon Kendra query. Your query can use any of the features of Amazon Kendra. If you don't specify a valid query, you get a `InvalidLambdaResponseException` exception. For more information, see [Query](https://docs.aws.amazon.com/kendra/latest/dg/API_Query.html) in the *Amazon Kendra Developer Guide*.

After you have created the filter or query string, you send the response to Amazon Lex with the `dialogAction` field of the response set to `delegate`. Amazon Lex sends the query to Amazon Kendra and then returns the query response to the fulfillment code hook.

### Using the Fulfillment Code Hook for the Response
<a name="kendra-search-lambda-fulfillment"></a>

After Amazon Lex sends a query to Amazon Kendra, the query response is returned to the `AMAZON.KendraSearchIntent` fulfillment Lambda function. The input event to the code hook contains the complete response from Amazon Kendra. The query data is in the same structure as the one returned by the Amazon Kendra `Query` operation. For more information, see [ Query response syntax](https://docs.aws.amazon.com/kendra/latest/dg/API_Query.html#API_Query_ResponseSyntax) in the *Amazon Kendra Developer Guide*.

The fulfillment code hook is optional. If one does not exist, or if the code hook doesn't return a message in the response, Amazon Lex uses the `conclusion` statement for responses.

# Example: Creating a FAQ Bot for an Amazon Kendra Index
<a name="faq-bot-kendra-search"></a>

This example creates an Amazon Lex bot that uses an Amazon Kendra index to provide answers to users' questions. The FAQ bot manages the dialog for the user. It uses the `AMAZON.KendraSearchIntent` intent to query the index and to present the response to the user. To create the bot, you: 

1. Create a bot that your customers will interact with to get answers from your bot.

1. Create a custom intent. Your bot requires at least one intent with at least one utterance. This intent enables your bot to build, but is not used otherwise.

1. Add the `KendraSearchIntent` intent to your bot and configure it to work with your Amazon Kendra index.

1. Test the bot by asking questions that are answered by documents stored in your Amazon Kendra index.

Before you can use this example, you need to create an Amazon Kendra index. For more information, see [Getting started with an S3 bucket (console) ](https://docs.aws.amazon.com/kendra/latest/dg/gs-console.html) in the *Amazon Kendra Developer Guide*.

**To create a FAQ bot**

1. Sign in to the AWS Management Console and open the Amazon Lex console at [https://console.aws.amazon.com/lex/](https://console.aws.amazon.com/lex/).

1. In the navigation pane, choose **Bots**. 

1. Choose **Create**.

1. Choose **Custom bot**. Configure the bot as follows:
   + **Bot name** – Give the bot a name that indicates its purpose, such as **KendraTestBot**.
   + **Output voice** – Choose **None**.
   + **Session timeout** – Enter **5**.
   + **Sentiment analysis** – Choose **No**.
   + **COPPA** – Choose **No**.
   + **User utterance storage** – Choose **Do not store**.

1. Choose **Create**.

To successfully build a bot, you must create at least one intent with at least one sample utterance. This intent is required to build your Amazon Lex bot, but isn't used for the FAQ response. The utterance for the intent must not apply to any of the questions that your customer asks.

**To create the required intent**

1. On the **Getting started with your bot** page, choose **Create intent**.

1. For **Add intent**, choose **Create intent**.

1. In the **Create intent** dialog box, give the intent a name, such as **RequiredIntent**.

1. For **Sample utterances**, type an utterance, such as **Required utterance**.

1. Choose **Save intent**.

Now, create the intent to search an Amazon Kendra index and the response messages that it should return.

**To create an AMAZON.KendraSearchIntent intent and response message**

1. In the navigation pane, choose the plus (\$1) next to **Intents**.

1. For **Add intent**, choose **Search existing intents**.

1. In the **Search intents** box, enter **AMAZON.KendraSearchIntent**, then choose it from the list.

1. For **Copy built-in intent**, give the intent a name, such as **KendraSearchIntent**, and then choose **Add**. 

1. In the intent editor, choose **Amazon Kendra query** to open the query options.

1. From the **Amazon Kendra index** menu, choose the index that you want the intent to search.

1. In the **Response** section, add the following three messages:

   ```
   I found a FAQ question for you: ((x-amz-lex:kendra-search-response-question_answer-question-1)) and the answer is ((x-amz-lex:kendra-search-response-question_answer-answer-1)).
   I found an excerpt from a helpful document: ((x-amz-lex:kendra-search-response-document-1)).
   I think the answer to your questions is ((x-amz-lex:kendra-search-response-answer-1)).
   ```

1. Choose **Save intent**, and then choose **Build** to build the bot.

Finally, use the console test window to test responses from your bot. Your questions should be in the domain that your index supports.

**To test your FAQ bot**

1. In the console test window, type a question for your index.

1. Verify the answer in the test window's response section.

1. To reset the test window for another question, choose **Clear chat history**.

# AMAZON.PauseIntent
<a name="built-in-intent-pause"></a>

Responds to words and phrases that enable the user to pause an interaction with a bot so that they can return to it later. Your Lambda function or application needs to save intent data in session variables, or you need to use the [GetSession](API_runtime_GetSession.md) operation to retrieve intent data when you resume the current intent.

Common utterances:
+ pause
+ pause that

# AMAZON.RepeatIntent
<a name="built-in-intent-repeat"></a>

Responds to words and phrases that enable the user to repeat the previous message. Your application needs to use a Lambda function to save the previous intent information in session variables, or you need to use the [GetSession](API_runtime_GetSession.md) operation to get the previous intent information.

Common utterances:
+ repeat
+ say that again
+ repeat that

# AMAZON.ResumeIntent
<a name="built-in-intent-resume"></a>

Responds to words and phrases the enable the user to resume a previously paused intent. You Lambda function or application must manage the information required to resume the previous intent.

Common utterances:
+ resume
+ continue
+ keep going

# AMAZON.StartOverIntent
<a name="built-in-intent-start-over"></a>

Responds to words and phrases that enable the user to stop processing the current intent and start over from the beginning. You can use your Lambda function or the `PutSession` operation to elicit the first slot value again.

Common utterances:
+ start over
+ restart
+ start again

# AMAZON.StopIntent
<a name="built-in-intent-stop"></a>

Responds to words and phrases that indicate that the user wants to stop processing the current intent and end the interaction with a bot. Your Lambda function or application should clear any existing attributes and slot type values and then end the interaction.

Common utterances:
+ stop
+ off
+ shut up

# Built-in Slot Types
<a name="howitworks-builtins-slots"></a>

Amazon Lex supports built-in slot types that define how data in the slot is recognized and handled. You can create slots of these types in your intents. This eliminates the need to create enumeration values for commonly used slot data such as date, time, and location. Built-in slot types do not have versions. 


| Slot Type | Short Description | Supported Locales | 
| --- | --- | --- | 
| [AMAZON.Airport](built-in-slot-airport.md) | Recognizes words that represent an airport. | All locales | 
| [AMAZON.AlphaNumeric](built-in-slot-alphanumeric.md) | Recognizes words made up of letters and numbers. | All locales except Korean (ko-KR) | 
| [AMAZON.City](built-in-slot-city.md) | Recognizes words that represent a city. | All locales | 
| [AMAZON.Country](built-in-slot-country.md) | Recognizes words that represent a country. | All locales | 
| [AMAZON.DATE](built-in-slot-date.md) | Recognizes words that represent a date and converts them to a standard format. | All locales | 
| [AMAZON.DURATION](built-in-slot-duration.md) | Recognizes words that represent duration and converts them to a standard format. | All locales | 
| [AMAZON.EmailAddress](built-in-slot-email.md) | Recognizes words that represent an email address and converts them into a standard email address. | All locales | 
| [AMAZON.FirstName](built-in-slot-first-name.md) | Recognizes words that represent a first name. | All locales | 
| [AMAZON.LastName](built-in-slot-last-name.md) | Recognizes words that represent a last name. | All locales | 
| [AMAZON.NUMBER](built-in-slot-number.md) | Recognizes numeric words and converts them into digits. | All locales | 
| [AMAZON.Percentage](built-in-slot-percent.md) | Recognizes words that represent a percentage and converts them to a number and a percent sign (%). | All locales | 
| [AMAZON.PhoneNumber](built-in-slot-phone.md) | Recognizes words that represent a phone number and converts them into a numeric string. | All locales | 
| [AMAZON.SpeedUnit](built-in-slot-speed.md) | Recognizes words that represent a speed unit and converts them into a standard abbreviation. | English (US) (en-US) | 
| [AMAZON.State](built-in-slot-state.md) | Recognizes words that represent a state. | All locales | 
| [AMAZON.StreetName](built-in-slot-street-name.md) | Recognizes words that represent a street name. | All locales except English (US) (en-US) | 
| [AMAZON.TIME](built-in-slot-time.md) | Recognizes words that indicate times and converts them into a time format. | All locales | 
| [AMAZON.WeightUnit](built-in-slot-weight.md) | Recognizes words that represent a weight unit and converts them into a standard abbreviation  | English (US) (en-US) | 

**Note**  
For the English (US) (en-US) locale, Amazon Lex supports slot types from the Alexa Skill Kit. For a list of available built-in slot types, see the [Slot Type Reference](https://developer.amazon.com/docs/custom-skills/slot-type-reference.html) in the Alexa Skills Kit documentation.   
Amazon Lex doesn't support the `AMAZON.LITERAL` or the `AMAZON.SearchQuery` built-in slot types. 

# AMAZON.Airport
<a name="built-in-slot-airport"></a>

Provides a list of airports. Examples include:
+ John F. Kennedy International Airport
+ Melbourne Airport

# AMAZON.AlphaNumeric
<a name="built-in-slot-alphanumeric"></a>

Recognizes strings made up of letters and numbers, such as **APQ123**.

This slot type is not available in the Korean (ko-KR) locale.

You can use the `AMAZON.AlphaNumeric` slot type for strings that contain: 
+ Alphabetical characters, such as **ABC**
+ Numeric characters, such as **123**
+ A combination of alphanumeric characters, such as **ABC123**

You can add a regular expression to the `AMAZON.AlphaNumeric` slot type to validate values entered for the slot. For example, you can use a regular expression to validate:
+ United Kingdom or Canadian postal codes
+ Driver's license numbers
+ Vehicle identification numbers

Use a standard regular expression. Amazon Lex supports the following characters in the regular expression:
+ A-Z, a-z
+ 0-9

Amazon Lex also supports Unicode characters in regular expressions. The form is `\uUnicode`. Use four digits to represent Unicode characters. For example, `[\u0041-\u005A]` is equivalent to [A-Z].

The following regular expression operators are not supported:
+ Infinite repeaters: \$1, \$1, or \$1x,\$1 with no upper bound.
+ Wild card (.)

The maximum length of the regular expression is 300 characters. The maximum length of a string stored in an AMAZON.AlphaNumeric slot type that uses a regular expression is 30 characters.

The following are some example regular expressions.
+ Alphanumeric strings, such as **APQ123** or **APQ1**: `[A-Z]{3}[0-9]{1,3}` or a more constrained `[A-DP-T]{3} [1-5]{1,3}`
+ US Postal Service Priority Mail International format, such as **CP123456789US**: `CP[0-9]{9}US`
+ Bank routing numbers, such as **123456789**: `[0-9]{9}`

To set the regular expression for a slot type, use the console or the [PutSlotType](API_PutSlotType.md) operation. The regular expression is validated when you save the slot type. If the expression isn't valid, Amazon Lex returns an error message.

When you use a regular expression in a slot type, Amazon Lex checks input to slots of that type against the regular expression. If the input matches the expression, the value is accepted for the slot. If the input does not match, Amazon Lex prompts the user to repeat the input. 

# AMAZON.City
<a name="built-in-slot-city"></a>

Provides a list of local and world cities. The slot type recognizes common variations of city names. Amazon Lex doesn't convert from a variation to an official name.

Examples:
+ New York
+ Reykjavik
+ Tokyo
+ Versailles

# AMAZON.Country
<a name="built-in-slot-country"></a>

The names of countries around the world. Examples:
+ Australia
+ Germany
+ Japan
+ United States
+ Uruguay

# AMAZON.DATE
<a name="built-in-slot-date"></a>

Converts words that represent dates into a date format.

The date is provided to your intent in ISO-8601 date format. The date that your intent receives in the slot can vary depending on the specific phrase uttered by the user.
+ Utterances that map to a specific date, such as "today," "now," or "November twenty-fifth," convert to a complete date: `2020-11-25`. This defaults to dates *on or after* the current date.
+ Utterances that map to a specific week, such as "this week," or "next week," convert to the date of the first day of the week. In ISO-8601 format, the week starts on Monday and ends on Sunday. For example, if today is 2020-11-25, "next week" converts to `2020-11-30`.
+ Utterances that map to a month, but not a specific day, such as "next month," convert to the last day of the month. For example, if today is 2020-11-25, "next month" converts to `2020-12-31`.
+ Utterances that map to a year, but not a specific month or day, such as "next year," convert to the last day of the following year. For example, if today is 2020-11-25, "next year" converts to `2021-12-31`.

# AMAZON.DURATION
<a name="built-in-slot-duration"></a>

Converts words that indicate durations into a numeric duration.

The duration is resolved to a format based on the [ISO-8601 duration format](https://en.wikipedia.org/wiki/ISO_8601#Durations), `PnYnMnWnDTnHnMnS`. The `P` indicates that this is a duration, the `n` is a numeric value, and the capital letter following the `n` is the specific date or time element. For example, `P3D` means 3 days. A `T` is used to indicate that the remaining values represent time elements rather than date elements.

Examples:
+ "ten minutes": `PT10M`
+ "five hours": `PT5H`
+ "three days": `P3D`
+ "forty five seconds": `PT45S`
+ "eight weeks": `P8W`
+ "seven years": `P7Y`
+ "five hours ten minutes": `PT5H10M`
+ "two years three hours ten minutes": `P2YT3H10M`

# AMAZON.EmailAddress
<a name="built-in-slot-email"></a>

Recognizes words that represent an email address provided as username@domain. Addresses can include the following special characters in a user name: underscore (\$1), hyphen (-), period (.), and the plus sign (\$1).

# AMAZON.FirstName
<a name="built-in-slot-first-name"></a>

Commonly used first names. This slot type recognizes both formal names and informal nicknames. The name sent to your intent is the value sent by the user. Amazon Lex doesn't convert from the nick name to the formal name.

For first names that sound alike but are spelled differently, Amazon Lex sends your intent a single common form.

In the English (US) (en-US) locale, use the slot name AMAZON.US\$1First\$1Name.

Examples:
+ Emily
+ John
+ Sophie

# AMAZON.LastName
<a name="built-in-slot-last-name"></a>

Commonly used last names. For names that sound alike that are spelled differently, Amazon Lex sends your intent a single common form.

In the English (US) (en-US) locale, use the slot name AMAZON.US\$1Last\$1Name.

Examples:
+ Brosky
+ Dasher
+ Evers
+ Parres
+ Welt

# AMAZON.NUMBER
<a name="built-in-slot-number"></a>

Converts words or numbers that express a number into digits, including decimal numbers. The following table shows how the `AMAZON.NUMBER` slot type captures numeric words.


| Input | Response | 
| --- | --- | 
| one hundred twenty three point four five | 123.45 | 
| one hundred twenty three dot four five | 123.45 | 
| point four two | 0.42 | 
| point forty two | 0.42 | 
| 232.998 | 232.998 | 
| 50 | 50 | 

# AMAZON.Percentage
<a name="built-in-slot-percent"></a>

Converts words and symbols that represent a percentage into a numeric value with a percent sign (%).

If the user enters a number without a percent sign or the word "percent," the slot value is set to the number. The following table shows how the `AMAZON.Percentage` slot type captures percentages.


| Input | Response | 
| --- | --- | 
| 50 percent | 50% | 
| 0.4 percent | 0.4% | 
| 23.5% | 23.5% | 
| twenty five percent | 25% | 

# AMAZON.PhoneNumber
<a name="built-in-slot-phone"></a>

Converts the numbers or words that represent a phone number into a string format without punctuation as follows.


| Type | Description | Input | Result | 
| --- | --- | --- | --- | 
| International number with leading plus (\$1) sign | 11-digit number with leading plus sign. | \$161 7 4445 1061 \$11 (509) 555-1212 | `+61744431061` `+15095551212` | 
| International number without leading plus (\$1) sign | 11-digit number without leading plus sign | 1 (509) 555-1212 61 7 4445 1061 | `15095551212` `61744451061` | 
| National number | 10-digit number without international code | (03) 5115 4444 (509) 555-1212 | `0351154444` `5095551212` | 
| Local number | 7-digit phone number without an international code or an area code | 555-1212 | 5551212 | 

# AMAZON.SpeedUnit
<a name="built-in-slot-speed"></a>

Converts words that represent speed units into the corresponding abbreviation. For example, "miles per hour" is converted to `mph`.

This slot type is available only in the English (US) (en-US) locale.

The following examples show how the `AMAZON.SpeedUnit` slot type captures speed units.


| Speed unit | Abbreviation | 
| --- | --- | 
|  miles per hour, mph, MPH, m/h  | mph | 
|  kilometers per hour, km per hour, kmph, KMPH, km/h  | kmph | 
|  meters per second, mps, MPS, m/s  | mps | 
| nautical miles per hour, knots, knot | knot | 

# AMAZON.State
<a name="built-in-slot-state"></a>

The names of geographical and political regions within countries. 

Examples:
+ Bavaria
+ Fukushima Prefecture
+ Pacific Northwest
+ Queensland
+ Wales

# AMAZON.StreetName
<a name="built-in-slot-street-name"></a>

The names of streets within a typical street address. This includes just the street name, not the house number.

This slot type isn't available in the English (US) (en-US) locale.

Examples:
+ Canberra Avenue
+ Front Street
+ Market Road

# AMAZON.TIME
<a name="built-in-slot-time"></a>

Converts words that represent times into time values. Includes resolutions for ambiguous times. When a user enters an ambiguous time, Amazon Lex uses the `slotDetails` attribute of a Lambda event to pass resolutions for the ambiguous times to your Lambda function. For example, if your bot prompts the user for a delivery time, the user can respond by saying "10 o'clock." This time is ambiguous. It means either 10:00 AM or 10:00 PM. In this case, the value in the `slots` map is `null`, and the `slotDetails` entity contains the two possible resolutions of the time. Amazon Lex inputs the following into the Lambda function:

```
"slots": {
   "deliveryTime": null
},
"slotDetails": {
   "deliveryTime": {
      "resolutions": [
         {
            "value": "10:00"
         },
         {
            "value": "22:00"
         }
      ]
   }
}
```

When the user responds with an unambiguous time, Amazon Lex sends the time to your Lambda function in the `slots` attribute of the Lambda event and the `slotDetails` attribute is empty. For example, if your user responds to the prompt for a delivery time with "10:00 PM," Amazon Lex inputs the following into the Lambda function:

```
"slots": {
   "deliveryTime": "22:00"
}
```

For more information about the data sent from Amazon Lex to a Lambda function, see [Input Event Format](lambda-input-response-format.md#using-lambda-input-event-format).

# AMAZON.WeightUnit
<a name="built-in-slot-weight"></a>

Converts words that represent a weight unit into the corresponding abbreviation. For example, "kilogram" is converted to `kg`. 

This slot type is available only in the English (US) (en-US) locale.

The following examples show how the `AMAZON.WeightUnit` slot type captures weight units:


| Weight unit | Abbreviation | 
| --- | --- | 
| kilograms, kilos, kgs, KGS | kg | 
| grams, gms, gm, GMS, g | g | 
| milligrams, mg, mgs | mg | 
| pounds, lbs, LBS | lbs | 
| ounces, oz, OZ | oz | 
| tonne, ton, t | t | 
| kiloton, kt | kt | 