JAO
JAO

Reputation: 39

How to make AWS Lex bot prompt for followup after intent fulfillment (using Lambda)?

The bot is not presenting the follow-up prompt even though it is set up in the 'Response' section in the Intent. This is working if the 'ReturnParametersToClient' is selected as the Fulfillment option. When the fulfillment is changed to AWS Lambda function, it does not present the follow-up question anymore.

For example: If my user inputs

3x10

I have a Lambda function to do this calculation and return results in the JSON format Lex expects. Thus it displays

30

Then, it should present the follow-up question

Would you like me to do another calculation?

To which the user can respond

No

From what I understand, the 'Response' section in the Intent editor page is precisely where I should be able to configure the question 'Would you like me to do another calculation?' and another message (in the 'Wait for user reply' section if the user replies in the negative.

Upvotes: 2

Views: 3334

Answers (1)

Jay A. Little
Jay A. Little

Reputation: 3277

Yes, everything is working as it is meant to.

You can do one or the other.
Either (1) set up a response in the Lex Console when the intent is fulfilled.
Or (2) build your own response in Lambda when the intent is fulfilled.

Using a Lambda function gives you much more control over your bot and lets you respond with more dynamic and tailored messages.

So if you are switching to use Lambda, you will have to create that response yourself when fulfilling the intent. You may want to use confirmIntent for that type of yes/no question.

Check out Lambda-Lex Response Format (confirmIntent about half-way down the page)

ConfirmIntent — Informs Amazon Lex that the user is expected to give a yes or no answer to confirm or deny the current intent.

Sending that response as a confirmIntent would be something like this:

"dialogAction": {
    "type": "ConfirmIntent",
    "message": {
      "contentType": "PlainText",
      "content": "Would you like me to do another calculation?"
    },
    "intentName": "intent-name",
    "slots": {
       "slot-name": "value",
       "slot-name": "value",
       "slot-name": "value"  
   },
}

Your Lambda would then need to handle the answer to that question.
The user's answer will be returned to the same intent and confirmationStatus will be:
None - no confirmIntent used
Confirmed - user said 'yes' to the confirmIntent question
Denied - user said 'no' to the confirmIntent question

Check out the same link above near the top of the page for the format of the Lex to Lambda Input Event.


Just a tip:

You could instead just fulfill the intent with a close message and ask the user something like "How else may I help you?"

Then the user can ask another calculation immediately without having to say yes or no before each calculation question.

Upvotes: 1

Related Questions