How can I use messaging construct features to customize my interactions in Amazon Lex?

6 minute read
0

I want to customize my interaction with the bot in Amazon Lex. How can I use messaging constructs like response cards, message groups, and intent contexts to customize my interactions with the bot?

Short description

Amazon Lex V2 provides you with a number of messaging construct features that allow you to customize user interactions with bots. Follow the steps in this article to customize messaging constructs like response cards, message groups, and intent contexts using the Amazon Lex V2 console.

Resolution

Response Cards

Response cards consist of a set of responses to a prompt. You can use response cards when you want Amazon Lex to provide a predefined set of applications to a client application. For example, in a taxi booking application, you can configure the types of vehicles available for a user, like compact, van, or SUV. The vehicle types are displayed as buttons in the response cards, and your application users chooses one of the available options. This option is then sent as input to Amazon Lex.

To create a response card using the Amazon Lex V2 console for slot prompt, follow these steps:

1.    Open the Amazon Lex V2 console, and then choose the intent where the slot is configured.

2.    From the slots section, choose the slot, and then choose Advanced options.

3.    From the to slot prompts section, choose More prompt options.

4.    Choose the Add dropdown, and then choose Add card group. You can now create cards and card groups, as needed.

Note: You can define up to three cards per group. A user selects one card during a conversation.

Message groups

A message group is a set of suitable responses to a specific prompt. You can use message groups when you want your bot to dynamically build the responses in a conversation. When Amazon Lex returns a response to a client application, it randomly chooses one message from each group.

For example, in a TaxiBooking bot, your first message group might contain different ways that the bot will greet the user. It might use “Hello”, “Hi” , "Hey", or “Greetings”. The second message group might contain different forms of introduction like “I am the TaxiBooking chatbot” or “This is the TaxiBooking chatbot.” A third message group might communicate capabilities like “I can help with the Taxi booking” or "I am here to assist you with taxi booking". Amazon Lex randomly selects one message from each group, and then uses them to give a response to the user.

Follow these steps to create multiple message groups for success fulfillment messages using the Amazon Lex V2 console.

1.    Open the Amazon Lex V2 console, and then choose the intent that you want to customize.

2.    From the fulfillment section, choose Advanced options.

3.    From the Success response section, choose More response options.

4.    Choose the Add dropdown, and then choose Add text message group. You can now create messages and message groups, as needed.

Contexts

A context is a state variable that can be associated with an intent when you define a bot. You can configure the contexts for an intent when you create the intent using the console or using the CreateIntent operation.

There are two types of relationships for contexts, output contexts and input contexts. An output context becomes active when an associated intent is fulfilled. After a context is activated, it stays active for the number of turns or for a time limit that you configure when you define the context.

An input context specifies the conditions under which an intent is recognized. An intent is only recognized during a conversation when all of its input contexts are active. An intent with no input contexts is always eligible for recognition.

Create an output context

Amazon Lex makes an intent's output contexts active when the intent is fulfilled. You can use the output context to control the intent's eligibility to follow up the current intent. You can configure an intent with more than one output context. When the intent is fulfilled, all of the output contexts are activated and returned in the RecognizeText or RecognizeUtterance response.

When you define an output context, you also define its time to live. This indicates the length of time or number of turns that the context is included in responses from Amazon Lex. A turn is one request from your application to Amazon Lex. Once the number of turns or the time has expired, the context is no longer active.

Your application can use the output context, as needed. For example, your application can use the output context to:

  • Change the behavior of the application based on the context. For example, a travel booking application might have one action for the context book_car_fulfilled and a different action for rental_hotel_fulfilled.
  • Return the output context to Amazon Lex as the input context for the next utterance. If Amazon Lex recognizes the utterance as an attempt to use an intent, it uses the context to limit the intents that can be returned to those with the specified context.

Follow these steps to create/specify output contexts:

1.    Open the Amazon Lex V2 console, and choose the intent that you want to customize.

2.    In the Context section, enter the output contexts that you want to create and assign to the intent.

Create an input context

You can set an input context to limit the points in the conversation where the intent is recognized. Intents without an input context are always eligible to be recognized.

Follow these steps to create or specify input contexts:

1.    Open the Amazon Lex V2 console, and choose the intent that you want to customize.

2.    From the Context section, enter the output contexts that you want to create and assign to the intent.

For an intent with more than one input context, all contexts must be active to trigger the intent. You can set an input context when you call the RecognizeText, RecognizeUtterance or PutSession operations.


Related information

ImageReponseCard

MessageGroup

OutputContext

InputContext

AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago