The use case is for a chatbot the retains state and uses authorisation already established with member on a Ghost website.

BTW - what is driving the use case is to replace a series of forms with a chatbot. On the website the planner is only available to subscribed members. Once a person is logged into the website they should not need to re-authenticate with the chatbot.

Following are notes for embedding AWS Lex in a chatbot on a website and as mentioned in the title I am assuming that it is possible.

Previously had attempted with Claudia Bot Builder and whilst chatbot was easy to setup with AWS Lambda and Facebook messenger it was appearing that authentication would be required twice, once for the website and then again for Facebook.

If use case doesn't work with AWS Lex then will keep looking.

Embedding Lex in a chatbot on a website

Accord to the following, it is possible ( and the ordering flower chatbot sample app does work ) to embed an AWS Lex in a chatbot on a website.

Deploy a Web UI for Your Chatbot | Amazon Web Services
Update March 2021: Introducing support for Amazon Lex V2 – See New features You’ve built a very cool chatbot using Amazon Lex. You’ve tested it using the Amazon Lex console. Now you’re ready to deploy it on your website. Although you could build your own bot user interface (UI), that seems like a lo…

It was important to set WebAppParentOrigin to website where the chatbot will be embedded when configuring for build. If left empty then result will be a CORS issue causing chatbot not to show.

Was impressed with natural language recognition used with chat dialog in demo. Also interesting to see that voice can be used with the chatbot.

Amazon Lex: developer Guide worth a read

If you are following along and for some lite reading put Amazon Lex: Developer Guide into your Kindle and have a scan through all the tech details. Of interest will be Exercise 1: Create an Amazon Lex Bot Using a Blueprint (Console) which references the ordering flowers chatbot this time with some explanation about each part. Next I will be working through this blueprint step by step toto understand more about what is going on,

I am starting to wonder if I should retitle this post to my getting started with AWS Lex guide.

Back at it and had a chance to work through some of the exercises in the Amazon Lex: Developer Guide.

Quick tip about configuring Lex ( at least at the time of writing ) if you want to use a Lambda function with Lex use V1 of the online console bot editor so that you can select the function from the bot's intents function list as they don't appear in V2 of the editor. Lex can also be configured from the command line which from an overall code management point of view will be my preference. Once again if you are following along with the Amazon Lex: Developer Guide refer to the AWS CLI section.

Learnings so far

  • Lex is an environment where chat slots (to be filled), intents (to control flow) and Lambda functions (for everything else) can be managed together to create a conversation with different channels.
  • Lex can be exposed in an iframe.

Passing variables to Lex chatbot iframe

According to the following it is possible to pass variables/options to Lex when the iframe chatbot object is initiated.

aws-lex-web-ui/ at master · aws-samples/aws-lex-web-ui
Sample Amazon Lex chat bot web interface. Contribute to aws-samples/aws-lex-web-ui development by creating an account on GitHub.

API when chatbot object is initiated includes:

  • toggleMinimizeUi() - toggles from minimised to maximised.
  • postText() - posts some text to the channel.

To validate this will go back to the sample flower ordering blue print bot and check to see if I can send a message.

Finding is that the postText() works and when sent triggers the Lex intent. For example if I post the text roses then Lex responds with What day do you want the roses to be picked up? which means that it is interpreting the text.

What this means is that the use case is doable with AWS Lex.

Hopefully these notes are of help.

I will start a new post with more AWS Lex chatbot learnings shortly.

Onwards and upwards.

For an update when complete subscribe.

Got a suggestion?

Share a comment.

Let's continue the conversation.