

# Optimize Lex V2 bot creation and performance by using generative AI
Optimize Lex V2 bots with generative AI

Take advantage of Amazon Bedrock's generative AI capabilities to automate and speed up your Amazon Lex V2 bot building process. You can carry out the following processes with the help of Amazon Bedrock.

**Note**  
These features uses generative AI. As you use the service, remember that it may give inaccurate or inappropriate responses. For more information, refer to [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/).  
Powered by Amazon Bedrock: AWS implements automated abuse detection. Because the Amazon Lex V2 generative AI features are built on Amazon Bedrock, users inherit the controls implemented in Amazon Bedrock to enforce safety, security, and the responsible use of AI.
+ Create new bots and populate them with relevant intents and slot types efficiently using natural language description.
+ Automatically generate sample utterances for your bot's intents.
+ Improve your bots' slot resolution performance.
+ Create an intent to help answer your customer's questions.
+ Use Amazon Bedrock Agents and Amazon Bedrock Knowledge Bases to help answer your customer's questions.

You can activate generative AI capabilities for Amazon Lex V2 either through the console or the API.

**Note**  
Before you can take advantage of the generative AI features, you must fulfill the following prerequisites  
For information about pricing for using Amazon Bedrock, see [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/).
Turn on the generative AI capabilities for your bot locale. To do so, follow the steps at [Optimize Lex V2 bot creation and performance by using generative AI](#generative-features). 

------
#### [ Using the console ]

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

1. Select the bot and the locale in the bot for which you want to turn on generative AI capabilities.

1. In the **Generative AI configurations** section, select **Configure**.

1. Toggle the **Enabled** button for each feature that you want to activate. Select the model and version that you want to use for that feature. Enabling a feature may incur additional charges. For information about pricing for using Amazon Bedrock, see [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/). To learn more about a feature, select the corresponding topic from the list below. Select **Save** after you turn on the features that you want to activate. A green success banner appears to confirm that the capabilities are turned on. 

------
#### [ Using the API ]

1. To enable generative AI capabilities for a new bot, use the [CreateBot](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateBot.html) operation to create a new bot.

1. Send a [CreateBotLocale](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateBotLocale.html) request, modifying the `generativeAISettings` object as necessary. If you are enabling the capabilities for an existing bot, send a [UpdateBotLocale](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_UpdateBotLocale.html) request instead.

   1. To enable usage of the descriptive bot builder, modify the `descriptiveBotBuilder` object. Specify the foundation model to use in the `modelArn` field and set the `enabled` value to `True`.

   1. To enable slot resolution improvement, modify the `slotResolutionImprovement` object. Specify the foundation model to use in the `modelArn` field and set the `enabled` value to `True`.

   1. To enable sample utterance generation, modify the `sampleUtteranceGeneration` object. Specify the foundation model to use in the `modelArn` field and set the `enabled` value to `True`.

------

**Topics**
+ [

# Use a description to build a bot in Lex V2 with the descriptive bot builder
](nld-bots.md)
+ [

# Use utterance generation to generate sample utterances for intent recognition
](utterance-generation.md)
+ [

# Using assisted slot resolution to clarify slot values in Amazon Lex V2
](assisted-slot.md)
+ [

# Using BedrockAgentIntent to use a Amazon Bedrock Agent in Amazon Lex V2
](bedrock-agent-intent.md)
+ [

# Improve intent classification and slot resolution in Lex V2 with assisted NLU
](assisted-nlu.md)
+ [

# Resolve ambiguous user inputs with Intent Disambiguation
](generative-intent-disambiguation.md)
+ [

# Optimize Bot using AI-powered Bot Analyzer
](bot-analyzer.md)
+ [

# AMAZON.QnAIntent
](generative-qna.md)

# Use a description to build a bot in Lex V2 with the descriptive bot builder
Descriptive bot builder from your description

**Note**  
Before you can take advantage of the generative AI features, you must fulfill the following prerequisites  
For information about pricing for using Amazon Bedrock, see [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/).
Turn on the generative AI capabilities for your bot locale. To do so, follow the steps at [Optimize Lex V2 bot creation and performance by using generative AI](generative-features.md). 

The descriptive bot builder lets you take advantage of Amazon Bedrock's access to large language models to improve the efficiency of the bot creation process. You provide a prompt using natural language that includes the purpose of the bot and the actions that it should perform. Amazon Lex V2 harnesses Amazon Bedrock's capabilities to generate relevant intents and slot types for your bot based on your description. Once you choose the intents and slot types that you want to keep, you can then iterate upon the bot to modify it to your specific use-case. The descriptive bot builder saves you time by letting you avoid having to manually create intents and slot types for the bot.

The descriptive bot builder is available in the English locales (see the locales that begin with `en_` in the table in [Languages and locales supported by Amazon Lex V2](how-languages.md)).

Before you create your bot, do the following.

1. Check that your role has the correct permissions by reviewing the steps at [Permissions needed to create a bot with natural language description in Lex V2](nld-permissions.md).

1. Decide on the description to use. You can refer to [Example bot descriptions for descriptive bot builder](nld-examples.md) for sample bot descriptions.

Create a bot by using natural language to describe what the bot should be able to do. Amazon Lex V2 invoke Amazon Bedrock models to generate intents and slot types that fit your bot's use case. You can create the bot with either the console or the API.

------
#### [ Console ]

**Create a bot using the descriptive bot builder**

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

1. In the **Bots** page, select **Create bot**.

1. For the **Creation method**, choose **Descriptive Bot Builder - GenAI**.

1. Give your bot a name and optional description, configure the IAM permissions, and choose whether your bot is subject to COPPA or not. Then select **Next**.

1. Select a language to create the bot in, a voice for the bot, and a confidence threshold for intent classification (for more information, see [Using intent confidence scores to improve intent selection with Lex V2](using-intent-confidence-scores.md).

1. Under **Descriptive Bot Builder - GenAI**, provide a description for the bot you want to create. Your description should be both *detailed* and *precise* to help generate appropriate and sufficient intents for your bot. Include a list of actions to improve the intent creation process.

1. Select a model provider and model under **Select model**.

1. To create the bot in another locale, choose **Add another language**. When you are finished adding languages, select **Done**. Amazon Lex V2 creates your bot and the descriptive bot builder generates intents and slots for it. When the locale has been generated, the banner turns from blue to green. Select **Review** to see the generated intents and slot types.
**Note**  
The descriptive bot builder is currently only available in English locales. However, you can copy a bot to a non-English locale after creating it.

**Review the generated intents and slot types and add them to your bot**

1. If there are enough intents and slot types that are applicable for your bot's use-case, you can review the generated intents.

   1. Review the **Generated intents**.

      1. Choose a checkbox next to an intent to remove it from the list of intents to add to the bot.

      1. Choose an intent name to view the **Sample utterances** and **Slots** generated for the intent.

      1. By default, all the utterances and slots are selected. Choose a checkbox to remove that item from the intent. Select **Add to selection** to keep the checked items in the intent.

   1. Review the **Generated slot types**.

      1. Choose a checkbox next to a slot type to remove it from the list of intents to add to the bot.

      1. You can add values to a slot type after you have added it to the bot

1. When you're satisfied with your intents and slot types, select **Add intents and slot types** at the top of the page to add the intents and slot types to your bot.

1. When the resources are finished being added, a green success banner appears. Go to **Intents** and **Slot types** to edit the generated ones and to add more values.

1. If the **Generated intents** and **Generated slot types** are mostly inapplicable to the bot you want to create, carry out the following steps.

   1. Select **New generation** in the **Descriptive bot builder details** section.

   1. Rewrite the prompt and select **Re-generate** to generate new intents and slot types. The results differ if you use a different model.
**Important**  
There is no guarantee that the same intents and slots will be generated. You are charged each time you regenerate the intents and slot types.

------
#### [ API ]

**Create the bot using natural language description**

When you use the descriptive bot builder through the API, it creates a bot definition in a .zip file in an Amazon S3 bucket. You download this file and import the bot definition into Amazon Lex V2 to create your bot.

1. Send a [CreateBot](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateBot.html) request to create a new bot. Then send a [CreateBotLocale](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateBotLocale.html) request to create a locale for the bot.

1. Send a [StartBotResourceGeneration](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_StartBotResourceGeneration.html) request, specifying the ID, version, and locale of the bot. You can use `DRAFT` for the bot version. Provide your prompt in the `generationInputPrompt` field. Your description should be both *detailed* and *precise* to help generate appropriate and sufficient intents for your bot. Include a list of actions to improve the intent creation process.

1. Take note of the `generationId` in the response.

1. Send a [DescribeBotResourceGeneration](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_DescribeBotResourceGeneration.html) request using the `generationId` you received in the `StartBotResourceGeneration` response. Include the bot ID, version, and locale.

1. If the `generationStatus` in the `DescribeBotResourceGeneration` response is `Complete`, the `generatedBotLocaleUrl` field will also be populated. Use this Amazon S3 URI to download the bot definition by following the steps at [Downloading an object](https://docs.aws.amazon.com/AmazonS3/latest/userguide/download-objects.html).

**Check the generated bot definition and import it**

1. Use the Amazon S3 URI from the `generationStatus` in the `DescribeBotResourceGeneration` response to download the bot definition by following the steps at [Downloading an object](https://docs.aws.amazon.com/AmazonS3/latest/userguide/download-objects.html).

1. You can directly modify the generated content for your bot's specific use-case by editing the file. You can also send another `StartBotResourceGeneration` request to regenerate intents and slots.
**Important**  
There is no guarantee that the same intents and slots will be generated. You are charged each time you regenerate the intents and slot types.

1. To import the bot definition, follow the steps at [Importing bots in Lex V2](import.md).

1. After importing, you can modify the generated intents and slots by using the [UpdateIntent](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_UpdateIntent.html), [UpdateSlot](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_UpdateSlot.html), and [UpdateSlotType](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_UpdateSlotType.html) operations.

To list metadata about all the generated items for a bot locale, use the [ListBotResourceGenerations](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_ListBotResourceGenerations.html) operation. Use any of the returned `generationId` values in a `DescribeBotResourcGeneration` request to retrieve the Amazon S3 URI for a generated bot definition.

------

**Topics**
+ [

# Example bot descriptions for descriptive bot builder
](nld-examples.md)
+ [

# Permissions needed to create a bot with natural language description in Lex V2
](nld-permissions.md)

# Example bot descriptions for descriptive bot builder
Examples for descriptive bot builder

Here are some helpful example bot descriptions you can use with descriptive bot builder in Amazon Lex V2.


| Industry | Example prompt | 
| --- | --- | 
| Financial services | We are a financial card service that helps users perform with tasks when they receive a new card such as activate card, email or mail a pin, verify a new card (using a zip code). We also help them with tasks associated with their existing card, such as enquire about credit card benefits, report a lost card, request a new card, reset a card pin, or pay a card bill. | 
| Food services | I want a bot to help customers order food (using item ID, quantity, size), check order status, and cancel an order. Use Order ID for indexing orders. | 
| Airline | We are an airline domain that helps users book flight tickets, check details of a reservation, obtain receipt for a booked flight, enquire flight status, reschedule booked flights, elicit flight details, and cancel booked flights. You can also generate additional intents if they help support functions in the domain description. | 
| Insurance | Objective: We are an insurance company that sells car, home and annuity insurance policies. I want a bot that can check claim status, file a claim, make policy payments and cancel a policy. We use policy\$1id and last 4 of SSN for account identification and validation.I expect the bot to have at least the following intents and slots: authentication - policy\$1id, last4SSNpolicy type: car, home, annuitypolicy status: check balance, check due date, check coveragemake a payment: one-time payment, installments, amount | 
| Vehicle management | We are building a Towed Cars Lookup bot that helps drivers in a city with whose car has been towed to find where the car is located. This bot should ask the address or location of where the automobile was towed from, and details about the vehicle such as license plate and make, model, and year of car. The bot should reply with location of the towed car parking lot, and hours of operation. | 
| Travel | I am a travel agent and I want a bot to help my customers book a trip to Disney. Disney has several parks all over the world to choose from, and also has hotels, dining, and special entertainment that can be reserved. Users of the bot should be able to modify or cancel their booking. Bookings must include at a minimum the park, dates, and hotel. Including dining or entertainment is optional and can be added or changed later. | 

# Permissions needed to create a bot with natural language description in Lex V2
Permissions needed for NLD
+ To access this feature on Amazon Lex V2 console, ensure your console role has `bedrock:ListFoundationModels` and `bedrock:ListInferenceProfiles` permissions.
+ The IAM role associated with the bot should have `bedrock:InvokeModel` permission. When you enable the feature with the Amazon Lex console the policy will get automatically added to the bot role provided your bot is using a service-linked role generated by Amazon Lex.

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

****  

  ```
  {
      "Version":"2012-10-17",		 	 	 
      "Statement": [
          {
              "Effect": "Allow",
              "Action": [
                  "bedrock:InvokeModel"
              ],
              "Resource": [
                  "arn:aws:bedrock:us-east-1::foundation-model/model-id"
              ]
          }
      ]
  }
  ```

------

# Use utterance generation to generate sample utterances for intent recognition


**Note**  
Before you can take advantage of the generative AI features, you must fulfill the following prerequisites  
For information about pricing for using Amazon Bedrock, see [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/).
Turn on the generative AI capabilities for your bot locale. To do so, follow the steps at [Optimize Lex V2 bot creation and performance by using generative AI](generative-features.md). 

Use utterance generation to automate the creation of sample utterances for your intent. Instead of manually inputting sample utterances, Amazon Lex V2 generates sample utterances for you based off the intent name, description, and existing sample utterances, so that you can reduce the time and effort you spend in discovering and writing your own sample utterances. After Amazon Lex V2 generates utterances, you can edit and delete the utterances. Use this tool to expedite the creation of sample utterances for the intent recognition process.

To allow utterance generation, follow the steps at [Optimize Lex V2 bot creation and performance by using generative AI](generative-features.md) to activate generative AI capabilities.

To access this feature on Amazon Lex V2 console, ensure your console role has `bedrock:ListFoundationModels`, `bedrock:ListInferenceProfiles`, and `bedrock:InvokeModel` permissions.

You can generate utterances with either the console or the API.

------
#### [ Console ]

1. Navigate to the **Sample utterances** section of any intent in your bot (in the Visual conversation builder, it is in the **Start** block).

1. Select the **Generate utterances** button to generate 5 sample utterances. If your intent has over 25 sample utterances, the **Generate utterances** button becomes disabled.

1. Generated utterances are displayed with a green banner that differentiates the generated utterances from the existing utterances.

1. Hover over an utterance to display the options to edit, delete, and sort the generated utterances.

------
#### [ API ]

1. Send a [GenerateBotElement](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_GenerateBotElement.html) request, filling in the intent and bot ID, version, and locale for which you want to generate sample utterances.

1. The response returns a list of [ SampleUtterance](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_SampleUtterance.html) objects, each of which contains a generated utterance.

1. To add the utterances to the intent, send an [UpdateIntent](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_UpdateIntent.html) request and add the utterances to the `sampleUtterances` field.

------

# Using assisted slot resolution to clarify slot values in Amazon Lex V2
Using assisted slot resolution for slot values

**Note**  
Before you can take advantage of the generative AI features, you must fulfill the following prerequisites  
For information about pricing for using Amazon Bedrock, see [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/).
Turn on the generative AI capabilities for your bot locale. To do so, follow the steps at [Optimize Lex V2 bot creation and performance by using generative AI](generative-features.md). 

You can improve the accuracy of some built-in slots in your bot's conversation flow by using assisted slot resolution. Assisted slot resolution uses Amazon Bedrock large language models (LLMs) to improve recognition of some built-in slots, which results in an improved interpretation of customer responses during slot elicitation. For utterances that could not be resolved normally, Amazon Lex V2 will attempt to resolve them a second time using Amazon Bedrock.

Assisted slot resolution allows you to use the power of Amazon Bedrock foundation models to improve the accuracy of the following built-in slots:
+ `AMAZON.Alphanumeric` without regex support
+ `AMAZON.City`
+ `AMAZON.Country`
+ `AMAZON.Date`
+ `AMAZON.Number `
+ `AMAZON.PhoneNumber`
+ `AMAZON.Confirmation`

You can enable assisted slot resolution for any intent that uses the above listed built-in slots. Assisted slot resolution does not apply to custom slots or Amazon built-in slots not listed above.

You can gather data on the accuracy improvements after you enable assisted slot resolution in your Amazon Lex V2 bot by using conversation logs and metrics.
+ Conversation logs - Interpretations will have the `interpretationSource` as `Bedrock`, if Amazon Bedrock was used to resolve the slot.
+ CloudWatch metrics - Metrics will be published under the dimentions listed in CloudWatch metric. To learn more, see [Monitoring Amazon Lex with Amazon CloudWatch](https://docs.aws.amazon.com/lex/latest/dg/monitoring-aws-lex-cloudwatch.html).

To use the descriptive bot builder, ensure that your IAM role has the proper permissions by following the steps at [Permissions needed in Lex V2 for assisted slot resolution](assisted-slot-permissions.md).

**Topics**
+ [

# Examples of assisted slot resolution used in Lex V2
](assisted-slot-examples.md)
+ [

# Enable assisted slot resolution in the Generative AI configuration screen
](assisted-slot-genai.md)
+ [

# Enable assisted slot resolution in the slot settings in Lex V2
](assisted-slot-level.md)
+ [

# Permissions needed in Lex V2 for assisted slot resolution
](assisted-slot-permissions.md)

# Examples of assisted slot resolution used in Lex V2
Examples of assisted slot resolution

Below are some examples where assisted slot resolution is able to intelligently resolve user utterances into a value.

AMAZON.Number


| Vertical | slotType | slotName | slotPrompt | utterance | Resolved Value | 
| --- | --- | --- | --- | --- | --- | 
| Travel | AMAZON.Number | numberOfNightsStayed | How many nights did you stay for the trip? | A whole week, 7 nights. | 7 | 
| Banking | AMAZON.Number | numberOfPeopleOnTheAccount | How many people are on the account? | Me and my wife. | 2 | 
| Travel | AMAZON.Number | numberOfStops | How many stops? | Once in Japan. Once in LA. | 2 | 

AMAZON.AlphaNumeric


| Vertical | slotType | slotName | slotPrompt | utterance | Resolved Value | 
| --- | --- | --- | --- | --- | --- | 
| Car Rental | AMAZON.Alphanumeric | transactionId | What is your transaction id? | I believe it was alpha whiskey echo eight three four nine romeo juliet. | AWE8349RJ | 
| Travel | AMAZON.Alphanumeric | confirmationCode | What is the confirmation number for your reservation? | The confirmation number is BLT2UE. | BLT2UE | 

AMAZON.Date


| Vertical | slotType | slotName | slotPrompt | utterance | Resolved Value | currentDate | 
| --- | --- | --- | --- | --- | --- | --- | 
| Car Rental | AMAZON.Date | dueDate | When is the rental agreement due to expire? | The lease is up on the 1st of next month. | 2023-12-01 | 2023-11-09 | 
| Travel | AMAZON.Date | returnDate | When are you returning? | Later today around 7. | 2023-11-09 | 2023-11-09 | 

AMAZON.PhoneNumber


| Vertical | slotType | slotName | slotPrompt | utterance | Resolved Value | 
| --- | --- | --- | --- | --- | --- | 
| Insurance | AMAZON.PhoneNumber | policyHolder | What is the phone number of the policy holder? | The phone number for the policy holder is 123-456-7890. | 1234567890 | 
| Retail | AMAZON.PhoneNumber | phoneLookup | What is your phone number so I can find your account? | I think it's under 413-570-9617, let me double check. | 4135709617 | 

AMAZON.Country


| Vertical | slotType | slotName | slotPrompt | utterance | Resolved Value | 
| --- | --- | --- | --- | --- | --- | 
| Travel | AMAZON.Country | nativeCountry | What is your country of origin? | I am Indian. | India | 
| Banking | AMAZON.Country | countryItinerary | What countries will you be traveling to with your debit card? | I will be travelling to New Delhi. | India | 

AMAZON.City


| Vertical | Slot Type | Intent | Question | Response | Resolved Value | 
| --- | --- | --- | --- | --- | --- | 
| Insurance | AMAZON.City | policyHolderCity | What city does the policy holder reside in? | I live in Springfield. | Springfield | 
| Travel | AMAZON.City | destinationCity | Which city are you traveling to? | I'm traveling to Tokyo. | Tokyo | 

AMAZON.Confirmation


| Vertical | slotType | slotName | slotPrompt | utterance | Resolved Value | 
| --- | --- | --- | --- | --- | --- | 
| Insurance | AMAZON.Confirmation | policyExpired | Has the insurance policy expired? | Yes, unfortunately it has expired. | Yes | 
| Banking | AMAZON.Confirmation | hasInvestments | Do you have any investments? | I haven't invested in anything yet. | No | 

# Enable assisted slot resolution in the Generative AI configuration screen
Enable in generative AI configurations

You can enable assisted slot resolution for supported built-in slots by navigating to the Generative AI screen.

If the slot is an supported built-in slot, you will have the option to activate the assisted slot resolution at the slot level.

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

1. In the navigation pane under **Bots**, select the bot you want to use for assisted slot resolution.

1. Select the language **English (US**) for the bot you want to enable.

1. Go to the **Generative AI configuration** section on the screen.

1. Select **Go to Amazon Bedrock** to sign up and enable the feature, if the feature has not been enabled.
**Note**  
If you do not have access to Amazon Bedrock foundation models, you should see **Go to Amazon Bedrock**. Click on **Go to Amazon Bedrock** to go to the Amazon Bedrock page where you can sign up for access to foundation models. Assisted slot resolution currently supports Anthropic Claude. We suggest using Anthropic Claude for best results.

1. If you already have access to Amazon Bedrock Foundation models, you should see a **Configure** button. Click on this button to go the generative AI configuration page to activate generative AI features in Lex.  
![\[Image of configure button for generative AI.\]](http://docs.aws.amazon.com/lexv2/latest/dg/images/assist-slot/assist-slot-genai.png)

1. In the upper right corner of the box, move the slider to the right to choose the **Enabled** setting.

1. Choose the **Enable** button to activate assisted slot resolution for the selected slots.

1. You can disable assisted slot resolution by selecting the slots from the list and selecting the **Disable** button.

# Enable assisted slot resolution in the slot settings in Lex V2
Enable assisted slot resolution for your slot

You can enable assisted slot resolution for supported built-in slots by navigating to the slot level for each intent that has slots. The slots must be one of the supported built-in slots listed above to have the option of activating assisted slot resolution. If the slot does not have the option to activate assisted slot resolution, the option will be greyed out.

**Note**  
You must first activate the assisted slot resolution feature on the Generative AI panel in order to activate the feature for individual slots. 

1. Sign in to the AWS Management Console and open the Amazon Lex V2 console at https://console.aws.amazon.com/lexv2/home.

1. In the navigation pane under **Bots**, select the bot you want to use for the assisted slot resolution.

1. Under All languages, select **English (US**) to expand the list.

1. In the left side panel, choose **Intents** to view a list of intents in the bot you selected.

1. In the **Intents** screen, choose the intent that contains the slots you want to modify.

1. Select the intent name to view the slots for that intent.

1. Select the **Advanced Options** button in the **Slots** section.

1. Select the check box for **Enable assisted slot resolution** to enable the feature.  
![\[Image of enable button for assisted slot resolution.\]](http://docs.aws.amazon.com/lexv2/latest/dg/images/assist-slot/assist-slot-enable.png)

1. Choose the **Update Slot** button in the bottom right corner of the screen. This will activate assisted slot resolution for the slots you have chosen.

**You can enable assisted slot resolution for supported built-in slots by making API calls.**
+ Follow the steps at [Optimize Lex V2 bot creation and performance by using generative AI](generative-features.md) to enable assisted slot resolution for your bot locale.
+ Send an [UpdateSlot](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_UpdateSlot.html) request, specifying the slot for which you want to enable assisted slot resolution. In the `slotResolutionSetting` field, set the `slotResolutionStrategy` value as `EnhancedFallback`. To create a new slot with assisted slot resolution enabled, send an [CreateSlot](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateSlot.html) request instead.

# Permissions needed in Lex V2 for assisted slot resolution
Permissions for assisted slot resolution
+ To access this feature on Amazon Lex V2 console, ensure your console role has `bedrock:ListFoundationModels` and `bedrock:ListInferenceProfiles` permissions.
+ The IAM role associated with the bot should have `bedrock:InvokeModel` permission. When you enable the feature with the Amazon Lex V2 console the policy will get automatically added to the bot role provided your bot is using a service-linked role generated by Amazon Lex V2.

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

****  

  ```
  {
      "Version":"2012-10-17",		 	 	 
      "Statement": [
          {
              "Effect": "Allow",
              "Action": [
                  "bedrock:InvokeModel"
              ],
              "Resource": [
                  "arn:aws:bedrock:us-east-1::foundation-model/modelId"
              ]
          }
      ]
  }
  ```

------

# Using BedrockAgentIntent to use a Amazon Bedrock Agent in Amazon Lex V2
Using BedrockAgentIntent to use a Bedrock Agent in Amazon Lex V2

**Note**  
Before you can take advantage of the generative AI features, you must fulfill the following prerequisites  
For information about pricing for using Amazon Bedrock, see [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/).
Turn on the generative AI capabilities for your bot locale. To do so, follow the steps at [Optimize Lex V2 bot creation and performance by using generative AI](generative-features.md). 

You can take advantage of Amazon Bedrock Agents to handle complex workloads requested by customers without having to go through a comprehensive task definition process. Amazon Lex V2 offers a built-in `AMAZON.BedrockAgentIntent` that you can add to your bot. This intent harnesses generative AI capabilities from Amazon Bedrock by recognizing customer requests, analyzing them, reasoning them, and finally responding. It also has the capability to ask any follow-up questions in order to achieve the task needed (for example, image you defined a retail agent that can check customer’s order status. When the customer asks for order status, agent first requests `customerId` or associated `emailId` to retrieve the details, and finally responds with correct order status). You can also decide to integrate your AMAZON.BedrockAgentIntent with a Bedrock Knowledge Base to directly answer any customer queries.

Ensure that your IAM role has the proper permissions to access the AMAZON.BedrockAgentIntent by following the steps at Permissions for the AMAZON.BedrockAgentIntent

To take advantage of the AMAZON.BedrockAgentIntent you must have set up one of the following knowledge stores.
+ Amazon Bedrock Agents – For more information, see [Creating Bedrock Agents](https://docs.aws.amazon.com/bedrock/latest/userguide/agents.html).
+ Amazon Bedrock Knowledge Base – For more information, see [Building a Knowledge Base](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-create.html).

To use the AMAZON.BedrockAgentIntent, ensure that your IAM role has the proper permissions by following the steps at [Permissions needed in Lex V2 for Bedrock Agent Intent](https://docs.aws.amazon.com/lexv2/latest/dg/bedrock-agent-intent-permissions.html).

**Topics**
+ [

# Enable Bedrock Agent Intent in the Generative AI configuration screen
](bedrock-agent-intent-genai.md)
+ [

# Enable Bedrock Agent Intent by adding a built-in intent to your bot
](bedrock-agent-intent-level.md)
+ [

# Permissions needed in Lex V2 for Bedrock Agent Intent
](bedrock-agent-intent-permissions.md)
+ [

# Sample request with session attributes
](bedrock-agent-intent-sample.md)

# Enable Bedrock Agent Intent in the Generative AI configuration screen
Enable in generative AI configurations

You can enable Bedrock Agent Intent by navigating to the Generative AI screen.

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

1. In the navigation pane under **Bots**, select the bot you want to use for Bedrock Agent Intent.

1. Select the language for the bot you want to enable. 

1. Go to the **Generative AI configuration** section on the screen, and select **Configure**.

1. In the BedrockAgentIntent configuration section, select **Create BedrockAgent intent**.

# Enable Bedrock Agent Intent by adding a built-in intent to your bot
Enable Bedrock Agent Intent for your bot

You can enable Bedrock Agent Intent by adding a built-in intent to your Amazon Lex V2 bot.

**Note**  
You must first activate the Bedrock Agent Intent feature on the Generative AI panel in order to activate the feature for individual bots. 

1. Sign in to the AWS Management Console and open the Amazon Lex V2 console at https://console.aws.amazon.com/lexv2/home.

1. In the navigation pane under **Bots**, select the bot you want to use for the Bedrock Agent Intent.

1. Under All languages, select **English (US**) to expand the list.

1. Select **Add intent** and choose **Use built-in intent** from the dropdown menu.

1. For more details about configurations for the AMAZON.BedrockAgentIntent, see [AMAZON.BedrockAgentIntent](built-in-intent-bedrockagent.md).

# Permissions needed in Lex V2 for Bedrock Agent Intent
Permissions for Bedrock Agent Intent
+ To access this feature on Amazon Lex V2 console, ensure your console role has `bedrock:ListFoundationModels` and `bedrock:ListInferenceProfiles` permissions.
+ The IAM role associated with the bot should have permissions required for `AMAZON.BedrockAgentIntent`.

  The bot role should have permissions for calling `bedrock:InvokeAgent` if using Amazon Bedrock Agents, and `bedrock:InvokeModel` and `bedrock:RetrieveAndGenerate` if using Amazon Bedrock Knowledge Bases in the intent. You should also attach a statement for each of the agents that you specify in your bots' `AMAZON.BedrockAgentIntent` (see the Permissions to access Amazon Bedrock Agent or Permissions to access Amazon Bedrock Knowledge Bases statement in the policy below). 

  When you enable the feature with the Amazon Lex console the policy will get automatically added to the bot role provided your bot is using a service-linked role generated by Amazon Lex.

# Sample request with session attributes
Sample request

The following example shows how to invoke the AMAZON.BedrockAgentIntent and demonstrates the session and request attributes that are populated in the response. These attributes contain the Bedrock Agent's response data and can be used to access the agent's output, Amazon Bedrock Knowledge Base sources, and action group invocation details.

```
{
    "sessionId": "user-session-123",
    "messages": [{
        "content": "Your order #12345 is currently being processed and will ship within 2-3 business days. You will receive a tracking number via email once it ships.",
        "contentType": "PlainText"
    }],
    "sessionState": {
        "sessionAttributes": {
            "x-amz-lex:bedrock-agent-search-response": "Your order #12345 is currently being processed and will ship within 2-3 business days. You will receive a tracking number via email once it ships.",
            "x-amz-lex:bedrock-knowledge-base-search-response-source": "[{\"title\": \"Order Processing Guide\", \"uri\": \"s3://knowledge-base/orders/processing.pdf\", \"excerpt\": \"Standard orders typically ship within 2-3 business days...\"}]",
            "x-amz-lex:bedrock-agent-action-group-invocation-input": "{\"actionGroupName\": \"OrderLookup\", \"function\": \"getOrderStatus\", \"parameters\": {\"orderId\": \"12345\", \"customerId\": \"67890\"}}",
            "x-amz-lex:bedrock-agent-knowledge-base-lookup-input": "{\"knowledgeBaseId\": \"KB123456\", \"query\": \"order status processing time\", \"numberOfResults\": 3}"
        },
        "intent": {
            "name": "BedrockAgentIntent",
            "slots": {},
            "state": "Fulfilled",
            "confirmationState": "None"
        },
        "dialogAction": {
            "type": "ElicitIntent"
        }
    },
    "interpretations": [{
        "intent": {
            "name": "FallbackIntent",
            "slots": {}
        },
        "interpretationSource": "Lex"
    }],
    "requestAttributes": {
        "x-amz-lex:channels:platform": "Web",
        "x-amz-lex:accept-content-types": "PlainText",
        "x-amz-lex:bedrock-agent-search-response": "Your order #12345 is currently being processed and will ship within 2-3 business days. You will receive a tracking number via email once it ships.",
        "x-amz-lex:bedrock-knowledge-base-search-response-source": "[{\"title\": \"Order Processing Guide\", \"uri\": \"s3://knowledge-base/orders/processing.pdf\", \"excerpt\": \"Standard orders typically ship within 2-3 business days...\"}]",
        "x-amz-lex:bedrock-agent-action-group-invocation-input": "{\"actionGroupName\": \"OrderLookup\", \"function\": \"getOrderStatus\", \"parameters\": {\"orderId\": \"12345\", \"customerId\": \"67890\"}}",
        "x-amz-lex:bedrock-agent-knowledge-base-lookup-input": "{\"knowledgeBaseId\": \"KB123456\", \"query\": \"order status processing time\", \"numberOfResults\": 3}"
    }
}
```

In this example, the session attributes show how the BedrockAgentIntent populates response data including the agent's answer, Amazon Bedrock Knowledge Base sources used, action group invocations, and Amazon Bedrock Knowledge Base lookup details that were used to generate the response.

For more information, see [AMAZON.BedrockAgentIntent](https://docs.aws.amazon.com/lexv2/latest/dg/built-in-intent-bedrockagent.html).

# Improve intent classification and slot resolution in Lex V2 with assisted NLU
Improve intent classification and slot resolution

Assisted NLU is a feature that uses Large Language Models (LLMs) to improve Amazon Lex V2's intent classification and slot resolution capabilities. It enhances accuracy while staying within your bot's configured intents and slots. The feature does not generate or modify any bot content. This feature helps to improve the overall accuracy of the NLU system, resulting in a more seamless and effective conversational experience for users.

The assisted NLU feature is available in English, Spanish, Portuguese, Catalan, French, Italian, and German locales. Specifically, it supports locales that begin with `en_`, `es_`, `pt_` (pt\$1BR, pt\$1PT), `ca_` (ca\$1ES), `fr_` (fr\$1CA, fr\$1FR), `it_` (it\$1IT), `de_` (de\$1AT, de\$1DE), `zh_` (zh\$1CN, zh\$1HK), `ja_JP`, and `ko_KR`. For the complete list of supported locales, see the table in [Languages and locales supported by Amazon Lex V2](how-languages.md).

Use assisted NLU to improve intent classification and slot resolution. Amazon Lex V2 invokes Amazon Bedrock models to help classify intents and resolve slot types that fit your bot's use case. You can enable assisted NLU for your bot with the console.

**Assisted NLU Mode**

In Primary mode, Lex will default to utilizing the LLM as the primary means of processing the user input to determine the user Intent, as well as to fill slot values.

In Fallback mode, Lex will use the LLM for determining user intent if the confidence score determined by NLU is lower than the configured threshold or otherwise routing to the FallbackIntent, as well as to determine slot values from user inputs if the traditional NLU does not capture a value. 

------
#### [ Console ]

**Using assisted NLU with your Amazon Lex V2 bot**

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

1. In the **Bots** page, select the bot you want to use with assisted NLU.

1. On the **Bot Locale** page, click on **Configure** under the **Assisted NLU** section.

1. Under the Runtime generative AI features section, you can see the Assisted NLU feature. Use the toggle button beside it to enable LLM Assisted NLU feature. You can then select Primary or Fallback mode, and click **Save**.

1. Verify that the LLM Assisted NLU feature is enabled under Assisted NLU section in the Bot Locale page.

1. Build the bot to see the changes are reflected in your bot in Runtime.

1. Once the bot build is completed, you can use the test panel in the console or run a test set to see the improvements after enabling LLM Assisted NLU feature.

------

**Guidance to improve the accuracy of your bot when using the LLM Assisted NLU Feature**

The following best practices can help you maximize the effectiveness of the Assisted NLU feature:

1. **Make Intent Names Self-Explanatory** — Use names that immediately convey the action or purpose of the intent. For example, if you're creating an intent for booking flights, simply call it "BookFlight".

1. **Keep Names Clean and Simple** — Avoid adding prefixes, suffixes, or unnecessary words to your intent and slot names. Extra elements like "Dev" or "Test" can confuse the LLM and make the purpose less clear.

1. **Provide Detailed Descriptions** — For each custom intent and slot, include a brief but informative description. This helps explain its specific use and context, making it easier for both humans and the LLM to understand its purpose.

**Note**  
When you enable this feature, your data might be processed across AWS Regions. For more information on Cross-Region Inference, see [https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html).

**Important**  
Enable this feature in a draft version of the bot. Test it before using it in a production alias.

## Disabling Assisted NLU


To disable the Assisted NLU feature, follow these steps:

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

1. In the **Bots** page, select your bot.

1. On the **Bot Locale** page, click on **Configure** under the **Assisted NLU** section.

1. Under the Runtime generative AI features section, toggle off the Assisted NLU feature, and click **Save**.

1. Build the bot to apply the changes.

# Resolve ambiguous user inputs with Intent Disambiguation
Resolve ambiguous user inputs with Intent Disambiguation

Intent Disambiguation is an improvement to Assisted NLU that helps resolve ambiguous user inputs when multiple intents could match. When enabled, the system presents clarifying questions to users, helping them specify their exact intent for improved conversation accuracy. The system uses a large language model (LLM) that analyzes the intent names and descriptions as context, and based on the ambiguity of the user utterance, returns the most likely matching intents. The LLM evaluates whether the user input clearly matches a single intent or multiple intents and is ambiguous enough to require disambiguation, then provides the candidate intents.

The Intent Disambiguation feature is available in English, Spanish, Portuguese, Catalan, French, Italian, German, Chinese, Japanese, and Korean locales. Specifically, it supports locales that begin with `en_`, `es_`, `pt_` (pt\$1BR, pt\$1PT), `ca_` (ca\$1ES), `fr_` (fr\$1CA, fr\$1FR), `it_` (it\$1IT), `de_` (de\$1AT, de\$1DE), `zh_` (zh\$1CN, zh\$1HK), `ja_JP`, and `ko_KR`. For the complete list of supported locales, see the table in [Languages and locales supported by Amazon Lex V2](how-languages.md).

You can configure the following options for Intent Disambiguation:

**Number of Intent Options**

Configure the maximum number of intents (2-5) to present to users when disambiguation is needed. This setting determines how many intent options will be shown to users when the system detects ambiguous input. The default value is 3, which provides a good balance between giving users sufficient options while keeping the selection manageable.

**Disambiguation Message**

 Provide a custom message that will be displayed before presenting the disambiguation options to users. This message helps set the context for users and can be customized to match your bot's tone and brand. If not specified, a default message will be used.

**Intent Display Names**

Configure user-friendly display names for your intents to improve the disambiguation experience. This is recommended when your intent names are technical or not suitable for display to end users. Display names will be shown to users during disambiguation instead of the technical intent name.

------
#### [ Console ]

**Using Intent Disambiguation with your Amazon Lex V2 bot**

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

1. In the **Bots** page, select the bot you want to use with Intent Disambiguation.

1. On the **Bot Locale** page, click on **Configure** under the **Assisted NLU** section.

1. Enable [Assisted NLU](assisted-nlu.md) and select either Primary or Fallback mode (Intent Disambiguation works with both modes).

1. In the **Intent Disambiguation** section within the Assisted NLU configuration, use the toggle button to enable the Intent Disambiguation feature.

1. Configure the following optional settings:
   + **Number of Intent options:** Select the maximum number of intents (2-5) to present to users during disambiguation. Default is 3.
   + **Disambiguation Message:** Provide a custom message that will be displayed when presenting intent options. If not specified, a default message will be used.

1. Click **Save** to apply the configuration.

1. Optionally configure Intent Display Names for better user experience:

   1. Navigate to each intent in your bot that you want to configure.

   1. In the Intent Editor Page, locate the **Display name** field.

   1. Enter a user-friendly name that will be shown to users during disambiguation instead of the Intent name.

1. Build the bot to see the changes reflected in your bot at runtime.

------

**Guidance to improve the effectiveness of your bot when using the Intent Disambiguation Feature**

The following best practices can help you maximize the effectiveness of the Intent Disambiguation feature:

1. **Clear Intent Names and Descriptions:** Ensure intent names and descriptions are clean, clear and do not overlap with other intents, as these are the main inputs provided to the LLM for disambiguation.

1. **Descriptive Display Names:** If current Intent names are technical, use descriptive display names that clearly communicate the intent's purpose. Display names should resemble or match the intent names.

1. **Appropriate Maximum Intents:** Set max number of intent options based on your preference and testing.

1. **Custom Messages:** Create concise disambiguation messages that acknowledge the user's input and lead to the intent options.

1. **Test Scenarios:** Test with ambiguous utterances to ensure the disambiguation experience feels natural with intent names or intent display names and custom messages, and verify that the correct intent options are being presented during disambiguation prompt.

**Important**  
Enable this feature in a draft version of the bot. Test it before using it in a production alias.

## Disabling Intent Disambiguation


To disable the Intent Disambiguation feature, follow these steps:

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

1. In the **Bots** page, select your bot.

1. On the **Bot Locale** page, click on **Configure** under the **Assisted NLU** section.

1. In the **Intent Disambiguation** section within the Assisted NLU configuration, toggle off the Intent Disambiguation feature, and click **Save**.

1. Build the bot to apply the changes.

# Optimize Bot using AI-powered Bot Analyzer


Analyze your Amazon Lex V2 bot configuration against AWS best practices using AI-powered recommendations. Bot Analyzer uses Amazon Bedrock's generative AI capabilities to identify configuration issues and provide actionable guidance to improve intent classification and slot resolution performance.

Bot Analyzer automatically evaluates your bot's intent configurations and provides recommendations to:
+ **Improve intent separation** - Identify and resolve generic intents that group multiple concepts
+ **Eliminate intent overlap** - Detect similar meanings and phrasings between intents that cause routing errors
+ **Optimize slot usage** - Recommend proper use of slots to combine similar intents and improve entity extraction
+ **Enhance utterance quality** - Analyze sample utterance coverage and diversity for better intent classification

Before using Bot Analyzer, ensure:
+ Your bot locale is built successfully
+ Your bot version for analysis is `DRAFT`
+ Your bot locale is one of the supported English locales: `en_AU`, `en_GB`, `en_IN`, `en_US`, `en_ZA`

You can use Bot Analyzer with either the console or the API.

------
#### [ Console ]

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

1. Select your bot and navigate to the bot locale you want to analyze.

1. In the bot locale editor, click the **Analyze** dropdown menu.

1. Select **Start** to begin the analysis.

![\[Analyze dropdown with Start option\]](http://docs.aws.amazon.com/lexv2/latest/dg/images/bot-analyzer/analyze-dropdown-start.jpeg)


The analysis typically completes within minutes. During analysis, the **Start** button changes to **Stop Analyzing** if you need to cancel.

Once analysis completes, recommendations appear in the **Recommendations** panel on the right side.

![\[Recommendations panel\]](http://docs.aws.amazon.com/lexv2/latest/dg/images/bot-analyzer/recommendations-panel.jpeg)


Each recommendation includes:
+ **Priority** - High, Medium, or Low severity
+ **Issue Location** - The specific intent affected
+ **Issue Description** - What configuration problem was detected
+ **Proposed Fix** - Actionable steps to resolve the issue

To see previous analyses:

1. Click the **Analyze** dropdown menu.

1. Select **History**.

1. The **Analysis History** panel displays past analysis requests with their status and timestamps.

![\[Analysis History panel\]](http://docs.aws.amazon.com/lexv2/latest/dg/images/bot-analyzer/analysis-history-panel.png)


To remove analysis results:

1. Click the **Analyze** dropdown menu.

1. Select **Delete**.

1. Confirm deletion of the current recommendations.

![\[Delete confirmation dialog\]](http://docs.aws.amazon.com/lexv2/latest/dg/images/bot-analyzer/delete-confirmation.png)


------
#### [ API ]

Send a `StartBotAnalyzer` request to initiate analysis for your bot locale. The response returns an HTTP 202 status with a `botAnalyzerRequestId`. Take note of this ID and you'll need it to check the analysis status and retrieve recommendations.

Send a `DescribeBotAnalyzerRecommendation` request using the `botAnalyzerRequestId` from the previous step. Include the `botId` in the request path.

If the `botAnalyzerStatus` in the response is `Available`, the analysis is complete and the `botAnalyzerRecommendationList` field will be populated with recommendations. Each recommendation includes:
+ `issueLocation` - The location where the issue was detected
+ `priority` - High, Medium, or Low severity
+ `issueDescription` - Details about the configuration problem
+ `proposedFix` - Actionable guidance to resolve the issue

If you need to cancel an analysis in progress, send a `StopBotAnalyzer` request with the `botId` and `botAnalyzerRequestId`.

To retrieve a list of previous analyses for a bot locale, send a `ListBotAnalyzerHistory` request. Specify the `botId` and `localeId` to see all past analysis requests with their status and timestamps.

To remove analysis results, send a `DeleteBotAnalyzerRecommendation` request with the `botId` and `botAnalyzerRequestId`. This permanently deletes the recommendations associated with that analysis.

**Note**  
Recommendations are automatically deleted after 15 days.

------
+ [Best practices for creating Amazon Lex interaction models](https://aws.amazon.com/blogs/machine-learning/best-practices-for-creating-amazon-lex-interaction-models/)
+ [Improve intent classification and slot resolution in Lex V2 with assisted NLU](assisted-nlu.md)
+ [Using assisted slot resolution to clarify slot values in Amazon Lex V2](assisted-slot.md)

# AMAZON.QnAIntent


**Note**  
Before you can take advantage of the generative AI features, you must fulfill the following prerequisites  
For information about pricing for using Amazon Bedrock, see [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/).
Turn on the generative AI capabilities for your bot locale. To do so, follow the steps at [Optimize Lex V2 bot creation and performance by using generative AI](generative-features.md). 

You can take advantage of Amazon Bedrock FMs to help answer customer questions in a bot conversation. Amazon Lex V2 offers a built-in `AMAZON.QnAIntent` that you can add to your bot. This intent harnesses generative AI capabilities from Amazon Bedrock by recognizing customer questions and searching for an answer from the following knowledge stores (for example, **Can you provide me details on the baggage limits for my international flight?**). This feature reduces the need to configure questions and answers using task-oriented dialogue within Amazon Lex V2 intents. This intent also recognizes follow-up questions (for example, **What about domestic flight?**) based on the conversation history and provides the answer accordingly.

Ensure that your IAM role has the proper permissions to access the `AMAZON.QnAIntent` by following the steps at [Permissions for the AMAZON.QnAIntent](qna-permissions.md).

To take advantage of the `AMAZON.QnAIntent` you must have set up one of the following knowledge stores.
+ Amazon OpenSearch Service database – For more information, see [Creating and managing Amazon OpenSearch Service domains](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/createupdatedomains.html).
+ Amazon Kendra index – For more information, see [Creating an index](https://docs.aws.amazon.com/kendra/latest/dg/create-index.html).
+ Amazon Bedrock knowledge base – For more information, see [Building a knowledge base](https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base.html).

You can set up the `AMAZON.QnAIntent` in one of two ways:

**To set up using Generative AI configurations**

1. In the Amazon Lex V2 console, select **Bots** from the left navigation pane and choose the bot for which you want to add the intent from the **Bots** section.

1. From the left navigation pane, select the language for which you want to add the intent.

1. In the **Generative AI configurations** section, select **Configure**.

1. In the **QnA configurations** section, select **Create QnA intent**.

**To set up by adding a built-in intent to your bot**

1. In the Amazon Lex V2 console, select **Bots** from the left navigation pane and choose the bot for which you want to add the intent from the **Bots** section.

1. From the left navigation pane, select **Intents** under the language for which you want to add the intent.

1. Select **Add intent** and choose **Use built-in intent** from the dropdown menu.

1. For more details about configurations for the `AMAZON.QnAIntent`, see [AMAZON.QnAIntent](built-in-intent-qna.md).

**Note**  
The `AMAZON.QnAIntent` is activated when an utterance is not classified into any of the other intents present in the bot. This intent is activated when an utterance is not classified into any of the other intents present in the bot. Note that this intent will not be activated for missed utterances when eliciting a slot value. Once recognized, the `AMAZON.QnAIntent` uses the specified Amazon Bedrock model to search the configured knowledge base and respond to the customer question.

**Topics**
+ [

# Permissions for the AMAZON.QnAIntent
](qna-permissions.md)

# Permissions for the AMAZON.QnAIntent
Permissions

To access this feature on Amazon Lex V2 console, ensure your console role has `bedrock:ListFoundationModels` and `bedrock:ListInferenceProfiles` permissions.

The IAM role associated with the bot should have the following permissions required for `AMAZON.QnAIntent`. The bot role should have permissions for calling `bedrock:InvokeModel`. You should also attach a statement for each data stores that you specify in your bots' `AMAZON.QnAIntent` (see the `Permissions to access Amazon Kendra index`, `Permissions to access OpenSearch Service index`, and `Permissions to access knowledge base in Amazon Bedrock` statements in the policy below). When you enable the feature with the Amazon Lex console, the policies will automatically get added to the bot role provided your bot is using a service-linked role generated by Amazon Lex.