1

I built the BookTrip bot from Amazon Lex detailed here.

When chatting with the bot the user can continue to book hotel rooms or rent cars until they end the conversation. Here is an example of a successful reservation followed by another reservation attempt through the chatbot interface:

Book a second hotel chat screenshot

When I use this chatbot in an Amazon Connect contact flow the user is not able to continue booking anything past the first reservation. Logically, the contact flow would keep executing the BookHotel or BookCar intents until the ConnectToAgent or EndConversation intents are executed.

Contact flow screenshot

I have tried looping BookHotel and BookCar back to the beginning of the "Get customer" input block but that errors out.

ascripter
  • 5,665
  • 12
  • 45
  • 68
ajanick
  • 11
  • 4

3 Answers3

1

The best way to do this is keep the user in the bot until they have done all of their booking, and then exit back to Amazon Connect. You would do this in the following way:

  1. Get slot values for initial booking
  2. Use lambda to fullfil the intent (write to database, etc.) and clear the slot values
  3. Use ConfrimIntent to as ask “would you like to add another booking”

If the user responds “yes”, confirming the intent then you would elicit the slot values (starting over at step 1)

If the user responds “no”, you would exit back to Amazon Connect

You can check out the lambda request and response details here

There is also a good discussion about this pattern on the AWS developer forum here.


Aossey
  • 850
  • 4
  • 13
  • 1
    This method would work well if I only had one intent that need to be looped repeatedly. Since BookHotel and BookCar are two seperate intents, I need to fulfilled the current intent in order to step back up a level in the bot so it can branch back into BookTrip or BookCar. ConfirmIntent just leaves me in either BookHotel or BookCar. – ajanick Jun 11 '18 at 17:37
  • +1 for the suggested answer, but @ajanick is right, even the discussion assumes confirmIntent remains in a single function. I've considered creating a transitionIntent to handle any confirmIntents where they would normally go to fulfillment and close, but then that transitionIntent must act like Lex and correctly detect all other intent utterances in a slot. That just feels wrong, and going to double the amount of confirmation questions, making the bot feel less natural. Anyone find a better solution since this answer? – Jay A. Little Oct 06 '18 at 12:55
0

I found one way around this that works for when you have multiple intents, though there are a couple drawbacks.

Basically, create a dummy block in Amazon Connect. I use Set Contact Attributes with a dummy attribute I named 'continue' with the value of 'continuing'. It is never used. Then on Success, loop it back to restart the Lex block!

enter image description here

No error when saving and publishing and works well for my use case.

Here's how the image above's set up works:
A. Play welcome prompt (this used to be the prompt when the Lex block initiated)
B. "Get customer input" is the Lex block.
C. Lex ends any intent and moves to dummy block (Set contact attributes)
D. On Success of setting dummy attribute, move back to restart B. Lex block.

Here are the drawbacks:
1. The Lex block requires some prompt when it initiates so you will have to design that into your bot, since it will deliver a prompt at the close of your intent, then another prompt at the restart of the Lex block.
2. This creates an infinite loop, at least until the user ends the call, or the session times out. One way around this though is to create an intent specifically for saying goodbye and don't point that intent fulfillment to the dummy block.

Jay A. Little
  • 3,239
  • 2
  • 11
  • 32
0

What I have implemented and successfully tested is adding "Greeting", "Yes" and "No" intents. When a real intent is fulfilled, I transfer the contact to the next Get customer input block that ask if the bot can help with anything else and checks for "Yes" and "No" intents. "Yes" transfers to the main Lex block. "No" obviously exits. The key thing to me here is how do you set your text greetings so it doesn't seem confusing. Please see what I came up with on the flow diagram. Seems to be working to me.

flow diagram

P.S. Didn't test it in production.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
gevial
  • 125
  • 1
  • 6
  • 2
    I made the picture visible. Please review my choice of "flow diagram". Not sure whether you like the term. – Yunnosch Aug 04 '22 at 13:32
  • Thanks @Yunnosch, the term is fine. Although it's not really a flow diagram, I think the reader will get the point. – gevial Aug 10 '22 at 12:16