Amazon Connect Contact Flow - Loop intents until user explicitly exits - amazon-web-services

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:
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.
I have tried looping BookHotel and BookCar back to the beginning of the "Get customer" input block but that errors out.

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:
Get slot values for initial booking
Use lambda to fullfil the intent (write to database, etc.) and clear the slot values
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.

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!
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.

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.
P.S. Didn't test it in production.

Related

AWS Lex, Amazon Connect, and Lambda. Dialog flow freezes after intent is fulfilled

I have an Amazon connect instance which uses a Lex v2 bot in the get customer input block. There is only one intent, which is triggered and reaches fulfillment fine. It is fulfilled by a lambda function and there are no errors there. It executes fully and there are not errors in the code.
I tested in the Lex v2 console and the bot works fine and returns the intent fulfilled message and the closing response. In the connect dialog flow, I get the intent fulfilled message and then nothing. No closing response and the dialog flow does not continue to the next prompt block, even when I remove the closing response. The call doesn't even hang up it just keeps the user on the line and is unresponsive. The lambda code fulfillment runs all the way through with no errors.
I suspect the issue is occurring somewhere between fulfilling the intent and sending the closing response. I don't know what could be holding up the bot at this point. I have a closing message I want to play for the user before I disconnect/terminate the call but the dialog flow is never getting to this point for reasons I cannot seem to find.
Any help is appreciated even just a point in the right direction. I have been looking through docs but haven't found anything regarding this specific issue. Thanks!

Amazon Connect Stop Call Recording

Is it possible to stop call recordings in Amazon Connect so the customer and agent can discuss sensitive material without being recorded?
I am aware of the set call recording behaviour blocks, but they don't seem to work on a call that has already been started with an agent with call recording enabled. Transferring to another contact flow with the recording type set to none doesn't seem to make a difference and the call carries on being recorded.
I am aware of the sample workflow Sample secure input with agent as outlined in this AWS blog https://aws.amazon.com/premiumsupport/knowledge-center/disable-recording-amazon-connect. This does work, however it relies on the customer entering payment details whilst the agent is on hold - preventing the agent and customer from having a sensitive conversation.
It seems the only way to stop recording once it has been enabled is to put the agent on hold?
Do not know if you have not solved your issue yet, but amazon has update their Amazon Connect API that would allow you to suspend the recording.
Boto3 implementation
response = client.suspend_contact_recording(
InstanceId='string',
ContactId='string',
InitialContactId='string'
)
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/connect.html#Connect.Client.suspend_contact_recording
They have also allow you to Start, Pause, Stop. (
We have just started to review this for a POC, turn recording off be default for a group of queues. Allow to Agents to start and stop and pause recording as needed.
You can also read this in an Amazon Blog post that should be able to help you fully implement the solution.
https://aws.amazon.com/blogs/contact-center/pausing-and-resuming-call-recordings-with-a-new-api-in-amazon-connect/#:~:text=is%20not%20recorded.-,End%20the%20call.,you%20start%20and%20stop%20it.
After speaking with Architects at AWS, the desired and designed for solution is to have the customer automatically enter sensitive information with the agent on hold and call recording turned off to remain PCI compliant.
If that is not an option there are workarounds possible that go against the way Amazon Connect has been designed. In order to turn off call recording once it has been enabled on a call, a new contact ID must be established. To do this you would need to transfer the user to your external phone number again or transfer to a queue and disable call recording in that new flow.
This brings in extra issues around how to get the customer back to the original agent once the sensitive information has been discussed. It also means you would potentially have 3+ contact IDs for the same transaction, with call recording spread across them.

Get User Input From Lambda in AWS Connect

I was wondering if anybody has ever experimented with this issue I'm having and could give me any input on the subject.
As it stands right now I'm trying to see if there is a way to grab a users input through the AWS Connect. I understand that there is already a "Get User Input" block in the GUI that is available for me to use, unfortunately it does not offer the fine grain control I am looking for with requests and responses from Lex.
Right now I am able to Post Content to Lex and get responses just fine, as well as output speech using Amazon Polly via my Lambda. This works great for things that do not require a user to have to give feedback for a question.
For example if a client asks
"What time is my appointment?"
and we give back
"Your appointment is for X at X time, would you like an email with
this confirmation?"
I want to be able to capture what the user says back within that same lambda.
So the interaction would go like so:
User asks a question.
Lambda POST's it to Lex and gets a response
Amazon Polly says the response - i.e: 'Would you like an email to confirm?'
Lambda then picks up if the user says yes or no - POST's info to Lex
Gets response and outputs voice through Polly.
If anybody has any information on this please let me know, thank you!
Why do you make so much complications to implement IVR system using Amazon Connect. I have done the complete IVR automated system to one of my biggest US banking client. Use the below procedure to achieve what you desire.
Build a complete interactive lex bot(So that you can avoid amazon poly & using lex post content api). It is advised to build each bot has only one intent in it.
In connect using "Get User Input" node map the lex bot which you have created earlier with the question to be asked "What time is my appointment?". Once this question has been played the complete control goes to lex and then you fulfilled your intent from lex side, you can come back to connect as like that.
Refer AWS contact center for the clear idea.

Prevent Amazon Echo from starting in the middle of program flow

I made a quiz skill where a user is first prompted with a response from Alexa asking if they are ready to proceed. From there, the user must either say yes or no to activate a corresponding AMAZON.YesIntent or AMAZON.NoIntent respectively. The quiz then begins, and a user says an answer letter followed by the answer for each question. I use a server to simulate state within my skill.
Normally I start my skill by saying:
"Alexa, start Quiz Skill"
But, I am finding that simulating state using a server does not make a very robust voice interface for the Echo. If a user says:
"Alexa, ask Quiz Skill yes"
The skill will jump to whatever I have setup to trigger when Amazon detects an AMAZON.YesIntent. This is not what I want! I want the user to follow the flow of the skill I have set out.
Is there a way to govern what intents can be activated at what time? A thought I had was to use attributes to basically set what intents are allowed to be invoked next.
There is a session object on each Alexa request. That session object has a new property that is either true or false depending on whether it's a brand new session for your Skill.
If you happen to be using the alexa-sdk node module to build your skill you can also use a NewSession handler to catch the new session and divert flow to what ever event/intent you want interaction to begin at. More on the state handlers can be found on the github page here
While I don't think it is possible to enable/disable intents, you can certain change how they respond. It's easy to use the session object to keep track of what the last intent spoken was. Then your intent handler(s) can read the session object to see what the previous response was in order to choose how to respond.
In your example above, you might save the last question number to the session object. If 'yes' doesn't make sense based on the previous (or lack of) question, then your YesIntent handler could respond with "I'm sorry, I don't know what to do with that", or even maybe just ignore it and start the dialog from the beginning.

AWS Lex Simple Bot Statement / Intent

I was hoping to create an intent that only makes a statement to the user. I was thinking I could do this by having some utterances that trigger the intent with no slots, but with a "goodbye message". When I try to do that, when I save the intent, it deletes the goodbye message and reverts it to None. I also picked a "no-op" lambda function to call since it doesn't make sense for what I'm doing.
At this point, I'm not sure about how to do this, but it seems like the claudia-bot-builder has support for something like this, but I can't get it to deploy to my AWS account to see how it might do it.
Does anyone else here have an idea about how to have the bot just give information in response to an utterance instead of starting a dialog to retrieve information?
You can return simple messages to the user using only Amazon Lex Console without any Lambda Function selected.
Open your Lex Chat Bot in console.aws.amazon.com/lex/home....
1 Click the "Editor" Tab.
2 On the left, click on the Intent you want to return a message on.
3 On the right, scroll down to the "Fulfillment" section.
4 Click "Return parameters to client"
5 In "Response" section, type in the message(s) you want to respond with.
Note: Make sure the section "Lambda initialization and validation" is unchecked so that the intent goes directly to the "Fulfillment" response.