user2701949
user2701949

Reputation: 1

Amazon Connect / Lex: Need to trigger intent from another bot, chain intents, remove redundant question

I have a scenario where I have to call two Lex bots back to back using two 'Get Customer Input' blocks in Connect.

The first is simply handling a yes/no question("Do you want to use this number for this action? - yes"). Then I branch based on the yes/no answer to go to the 2nd Lex bot.

To trigger that 2nd bot I ask in a 2nd question("Are you ready to proceed with that action? - yes") in a second 'Get Customer Input' block. With the second bot, the user is prompted for a time and a temperature.

The issue is that the caller needs to say "yes" twice - once each time to trigger each bot.

I'd like to find a way to trigger the intent of the 2nd bot without prompting the user with a redundant question.

Hope not to have to use a lambda function.

Specific guidance would be greatly appreciated.

Simplified contact flow

Upvotes: 0

Views: 1262

Answers (1)

MVS
MVS

Reputation: 66

Based on your description and simplified contact flow diagram, this is my interpretation of the lex bots:


Get Customer Input Block for Bot1 with prompt "Do you want to use this number for this action?"

Bot1:

  • Intent1: Sample utterances corresponding to Yes (E.g. Yes, Yeah, Yes sure, okay)
  • Intent2: Sample utterances corresponding to No (E.g. No, Nope, Nah, no I want to use a different one)

Get Customer Input Block for Bot2 with prompt "Are you ready to proceed with that action?"

Bot2:

  • Intent1: Sample utterances corresponding to Yes

    Slot1: To capture time

    Slot2: To capture temperature

  • Intent2: Sample utterances corresponding to No


Solution 1: From what you have mentioned above, in my experience I would build a single bot with same structure as Bot2. In the connect flow you can invoke this bot with the prompt "Do you want to use this number for this action?"

If the caller says Yes, Lex will prompt for the 2 slots that you need in case of Yes. If no, it will not ask any further question and return control back to Connect.

You can access the slot values in connect using Lex slot attributes https://docs.aws.amazon.com/connect/latest/adminguide/how-to-reference-attributes.html

Solution 2: If for some reason, you cannot merge the 2 bots to 1 (I can't think of a reason why) , you can pre-set intent of a Lex bot by invoking PostText Lex API for Bot2 with inputText value as "Yes" prior to calling the second Lex Bot with userId input field set as connect contact id. Note: Sending userid=contact id is the way same lex session/context will be continued when you invoke it later via "Get Customer Input" block from connect, note that this is not documented by AWS and something which happens today under the hood, so there is a risk if this implementation is changed by AWS.

This solution will need a lambda function to be created to invoke "PostText" API before invoking "Get Customer Input" block from contact flow for Bot2. Currently, there is no way to do preset intent directly from connect, without invoking a lambda function. The prompt for "Get Customer Input" block should play the prompt returned by PostText response (the prompt for first slot for Yes intent, i.e. prompt for time), you can return it from the lambda function and reference it in the "Get Customer Input" block. API Reference: https://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostText.html

Solution1 is what I would recommend from my experience, you do not need solution2 as this seems to be a straightforward problem that can be solved by changing the way lex bots are built and used.

Upvotes: 1

Related Questions