AWS Lex is a Amazon Cloud chat AI service. It gets user inputs via text(or voice), then form a json containing info user provided, now comes the Lambda service(Python2.7 case) which can process the data as json according to your coded business logic. i.e. Pizza order, flower order, take appointments…

Just follow the Lex get started document to get a basic understand of what the service does, the possible ways to work with other services i.e. Polly(AI text to speach service), and the deployment of Lex Bot.

The get started example - the Order* Bot is relatively simple but complete and it is a very good example to start with:

  1. Lex Bot text interface
  2. The json data and schema Lex collects and passes to Lambda service
  3. Lambda service entry point/function(handler configuration)
  4. Entry function of Lambda service load the json data(as event) that Lex Bot provides and returns result json data to Lex Bot, Lex Bot will then answer user via text(or voice)
  5. Entry function has another AWSLexBot object context which has predefined function by AWS
  6. CloudWatch service logs all for Lambda service, this function is very usefull when debugging

After finishing configuration of OrderFlowers, you should then do the deployment of a customer Bot example, pay attention to above listed points and you will find each step make more sense.

Before deployment AWS Lex, you can only interact with Bot via text which is much less interesting for me, because the cool thing should be talk and answer live conversation.

Actually AWS espects that you make Lex Bot available in a mobile APP which can take voice or create a Facebook page and add AWS Lex Bot into messenger of the page. When you browse the Facebook page you can then talk to the Bot.

Mobile APP Deployment case:

You will need mobilehub service and knowledge of IOS SDK or Android SDK or Web server Node.js(no example).

Facebook page and messenger deployment case:

To begin the steps here, you must make sure your AWS Lex Bot is working and pass already the test in AWS. If yes, now you should follow the steps of AWS deployment which involves Facebook page and messenger.

First login to facebook developer website and fowllow the Quick Start

PS: To create Facebook APP, your Facebook account must be verified which means associating your phone number to your Facebook account, otherwise you can’t create any APPs and a misleading error message is kind of “Sorry, we’re having issues.”

Create a new page on Facebook and generate page token for it: EAAcFJjuHwgYBAIucxJflcZBtohp7ZBZA6gJe2K4YIhdmfRsCX8OlMfJluUxReDBbLp1ZBlFZBM6xrZALpIrSlZAojUabpjBcNEKZAqmqW0wzPKQyKhiZBjXt20DfN2KjQfNZCuqz0AKN03I7y
FB_PAGE_TOKEN_GEN

Get familiar with the Facebook developer Dashboard, you will find your APP SECRET.

Now go back to AWS Lex - section channel - Facebook, specify above info and set a verify token then generate the callback uri.

Switch again to Facebook developper - section products - Messenger settings - webhooks, add the callback uri from AWS and give the same verify token. At last, subscribe this webhookthe to your created Facebook page.
FB_PAGE_WEBHOOK

You notice a new products WEBHOOK also appears on the left, try click and edit it. Double verify if it’s working with verify token. At the beginning I didn’t do this and the messenger responded nothing when I sent message.

Facebook API kit could also helpful, I didn’t use much, but guess it’s a must when debug. graph API Facebook

When you’re ready and pass test, you need to submit your app to Facebook review and then it will go public, before that it’s admin, tester, developer access only. Install Facebook messenger on your Iphone or Android, login it and search your Bot, let’s talk.
FP_CHAT

Similar deployment on different platform:
Google chat tutorial

slack chat tutorial

Twilio chat tutorial

Only AWS Lambda and Facebook Messenger withouts LEX

Normally smart phone can convert speach to text, but the Bot can’t answer in voice, the real talking communication needs the text to speach which means an AWS Polly service on top, how this is done in lamba or what ???

to be continued…

Deploy on a website enable voice chat function from users
reactjs nodejs aws-sdk-js aws-cognito aws-iam aws-lexruntime

Build your website with voice enabled Lex from AWS blog
aws-sdk aws-lexruntime

voice chat website audio API and issues

javascript sample