Lesson 2 of 4 Conversational Systems and Prompt Flows

Recognizing Intent and Asking for Clarification

This lesson covers intent recognition with Amazon Comprehend, Amazon Lex and FMs, and clarification workflows with Step Functions that ask for missing details instead of guessing.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose a service for intent recognition.
  • Build clarification workflows with Step Functions.

Recognizing intent

Intent recognition classifies a message into the action the user wants, such as track order, change address or ask a policy question, so the application can route it to the right workflow, prompt or agent. Amazon Comprehend custom classification trains a classifier on labelled examples and serves it from a real-time endpoint, giving fast, consistent and inexpensive classification for a fixed set of intents. A small FM classifier with a prompt listing the intents needs no training and adapts to new intents quickly, at a higher per-request cost.

Amazon Lex builds conversational interfaces with intents, slots (the parameters an intent needs, such as date or order number) and prompts that elicit missing slots, for voice and text channels including Amazon Connect contact centres. Lex can call a Lambda function for fulfilment and can hand off to an FM for open-ended questions.

Scenario questions

Recognising intent

Exam skills 1.6.2

Choose the intent recognition approach that fits each requirement.

Log in to try this activity Interactive activities are free with an account.

Clarification workflows with Step Functions

A clarification workflow checks whether a request has everything needed to act. In Step Functions, a task extracts parameters with an FM or Comprehend, a Choice state checks for missing or ambiguous values, and if something is missing a task sends a clarifying question to the user and waits. The wait uses the .waitForTaskToken integration: the token is stored with the session, and when the user replies, the application calls SendTaskSuccess with the answer, and the workflow continues to validation and fulfilment.

Clarification should be targeted: ask one specific question ("Which of your two orders, #1182 or #1190?") rather than a generic "please provide more details", and limit the number of rounds before handing off to a human. The following table compares intent recognition options.

OptionStrengthsConsiderations
Comprehend custom classificationFast, cheap, consistent for fixed intentsNeeds labelled training data and an endpoint
FM classifier promptNo training; easy to add intentsHigher cost per request; needs validation
Amazon LexIntents, slots, elicitation, voice and contact centreStructured dialogs rather than open-ended chat

The following diagram shows the clarification step in the workflow.

A clarification step for refund requests. Step Functions extracts the order reference; if it is missing or matches several orders, the workflow asks the customer with the candidate orders and waits with a task token. The customer's reply calls SendTaskSuccess, and the refund runs only for one confirmed order.
The refund never runs on a guessed order.
Put in order

A clarification workflow

Exam skills 1.6.2

Put the states of a Step Functions clarification workflow in order.

Log in to try this activity Interactive activities are free with an account.
Worked example

Ambiguous refund requests

A retail assistant issues refunds through an agent. When customers say "refund my order" and have several recent orders, the agent sometimes picks the wrong one.

The fix is a clarification step: a Step Functions workflow extracts the order reference; if it is missing or matches more than one order, it sends a question listing the candidate orders and waits with a task token; the refund runs only after the customer confirms a specific order.

Check yourself

Which service handles slot filling for structured dialogs, including voice?

Show answer

Amazon Lex.

Exam Tips

Remember for the exam

  • Fixed intents at low cost: Comprehend custom classification.
  • Slot filling for structured dialogs and voice: Amazon Lex.
  • Wait for the user's answer in a workflow: Step Functions waitForTaskToken.
  • Ask specific clarifying questions rather than guessing.