Duzzy
Duzzy

Reputation: 11

Amazon Lex to use utterance from Amazon Connect

I have a lex bot in a Connect flow that asks for the person's name after they have said "hi".
I would like my Lex bot to ask for the person's name without them having to say "hi" first.
I basically want to remove the utterance and go straight to the prompt. My bot only has one intent.

This is my lex intent This is my lex intent

This is my Connect contact flow

This is my Connect contact flow

Upvotes: 1

Views: 1005

Answers (1)

MVS
MVS

Reputation: 66

Here is what you can do:

  1. Integrate a Lambda function in your Connect Flow before your GetCustomerInput block. Documentation to do this: https://docs.aws.amazon.com/connect/latest/adminguide/connect-lambda-functions.html
  2. From the Lambda function, make a call to Lex using PostText API (https://docs.aws.amazon.com/lex/latest/dg/API_runtime_PostText.html) with the appropriate inputText- "hi" in your case. For the API call, use the value of ContactID (https://docs.aws.amazon.com/connect/latest/adminguide/connect-lambda-functions.html#funtion-contact-flow) to set userID. In response from Lex, you should see Action as 'ElicitSlot' with message text for eliciting the first slot in the intent (or any other action and logic if you have implemented a code-hook for your intent). You can return this message from your lambda function back to connect 3.Configure an appropriate prompt in your GetCustomerInput block asking for the slot value - you can use the attribute for message returned by function in step2. The same session that you had set in step #2 will continue here as the userID remains the same. Using this, you will be able to use Lex (via GetCustomerInput block) to directly elicit slot values and fulfill the intent.

Reference: I had asked this question long ago on one of the AWS forums. Here is the link. There API PutSession is mentioned. However, from my experience postText works better in this use case if you want to delegate the prompting for slots on the bot.

Caution: It is nowhere mentioned in offical AWS documentation that Lex user id is same as Connect contact ID when invoked from connect using 'Get Customer Input'. However, that is something which happens today under the hood. In future, it is possible AWS may change the internal implementation.

Upvotes: 2

Related Questions