

# Sample utterances


You create sample utterances that are variations of phrases that you expect users to use to initiate an intent. For example, for a **BookFlight** intent, you might include utterances such as the following:

1. I want to book a flight

1. help me get a flight.

1. plane tickets, please\$1

1. flight from \$1*DepartureCity*\$1 to \$1*DestinationCity*\$1

You should provide 10 or more sample utterances. Give samples that represent a wide range of sentence structures and words that users may utter. Consider incomplete sentences as well, such as in examples 3 and 4 above. You can also use slots that you have defined for the intent in a sample utterance by wrapping curly braces around the slot name, as in \$1*DepartureCity*\$1 in example 4. If you include slot names in a sample utterance, Amazon Lex V2 fills the slots of the intent with the values that the user provides in the utterance.

A variety of sample utterances helps Amazon Lex V2 generalize to effectively recognize that the user wants to initiate the intent.

You can add sample utterances in the intent editor, visual conversation builder, or with the [CreateIntent](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateIntent.html) or [UpdateIntent](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_UpdateIntent.html) API operations. You can also generate sample utterances automatically by taking advantage of Amazon Bedrock's generative AI capabilities. For more information, see [Use utterance generation to generate sample utterances for intent recognition](utterance-generation.md).

**Use the Intent editor or Visual conversation builder**

1. In the Intent editor, navigate to the **Sample utterances** section. In the Visual conversation builder, find the **Sample utterances** section in the **Start** block.

1. In the box with the transparent text **I want to book a flight**, type a sample utterance. Select **Add utterance** to add the utterance.

1. View the sample utterances you have added in either **Preview** or **Plain text** mode. In **Plain text**, each line is a separate utterance. In **Preview mode**, hover over an utterance to reveal the following options:
   + Select the text box to edit the utterance.
   + Select the x button on the right of the text box to delete the utterance.
   + Drag the button on the left of the text box to change the order of sample utterances.

1. Use the search bar at the top to search through your sample utterances and the dropdown menu next to it to sort by the order you added the utterances or in alphabetical order.

**Use an API operation**

1. Create a new intent with the [CreateIntent](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_CreateIntent.html) operation or update an existing one with the [UpdateIntent](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_UpdateIntent.html) operation.

1. The API request includes a `sampleUtterances` field, which maps to an array of [SampleUtterance](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_SampleUtterance.html) objects.

1. For each sample utterance that you want to add, append a `SampleUtterance` object to the array. Add the sample utterance as the value of the `utterance` field.

1. To edit and delete sample utterances, send an `UpdateIntent` request. The list of utterances you provide in the `sampleUtterances` field replaces the existing utterances.
**Important**  
Any field that you leave blank in the `UpdateIntent` request will cause existing configurations in the intent to be deleted. Use the [DescribeIntent](https://docs.aws.amazon.com/lexv2/latest/APIReference/API_DescribeIntent.html) operation to return the bot configuration and copy any configurations that you do not want to be deleted into the `UpdateIntent` request.