Search code examples
amazon-web-servicesamazon-lex

Branching conversation in Amazon Lex


Is there a way to branch a conversation depending on a user input on an intent?

For example: Consider a binary intent such as "isRent" with an utterance "Are you renting right now?". The user is likely to answer either "yes" or "no". At this point, I have some more slots to ask the user. How do I update the prompt to ask for slots after this depending on the user's answer?

isRent

  • yes - What is your monthly rent? (collecting a value for slot {payment})

  • no - What is your monthly mortgage payment? (collecting the value for same slot as above)


Solution

  • You can create a Lambda function to handle Initialization and validation code hook and do the branching in here.

    The make-appointment example blueprint has some good hints for how to rephrase a question based on previous responses.

    As an aside, I've noticed that AWS Lex has trouble with yes/no questions so you may need to rephrase your question to get around this problem. (Also, if you find the solution to this please answer the unanswered SO questions about this)