AWS Lex Chatbots

An Overview of Building a chatbot on AWS and the Tools Required

Image for post
Image for post
Credit: Amazon.com
Image for post
Image for post

Building with Lex

Building a chatbot on AWS is simultaneously incredibly easy and incredibly difficult.

Building a Chatbot in the chatbot builder UI

You can quite easily build the set of inputs and responses that your chatbot will respond to. The bot framework provided by amazon revolves around what are called ‘intents’, or otherwise user goals that are sensed by the chatbot as it is receiving input from the user.

Image for post
Image for post
Credit https://miro.medium.com/max/

Connecting Lex to other AWS services to build your Application

Here is where things get a bit more tricky. The strength of AWS is in its flexibility, modularity and security, but that makes the infrastructure around a project like this a bit more complicated to set up. Let’s take another look at our trusty architecture diagram.

Image for post
Image for post
  1. Server makes a request to Cognito
  2. Cognito checks the authentication status of the user, and returns a credentials object with the allowed access of that user. If you have not allowed unauthenticated access, the Cognito service will try to redirect the user to a login page to obtain that authentication. Note: as far as I can tell there is no way to spoof this credentials object for the sake of testing.
  3. User inputs text or audio into your application or and presses ‘send’.
  4. Your application calls the Lex API (API URLs can be found here) with the input text/audio content, and an accompanying OPTIONS request that confirms the access rights of the user that recieved the credentials when your app was initialized.
  5. The Lex bot will take the text input and perform the logic that you built into the bot in the bot builder UI.
  6. (optional) The Lex service can optionally call a lambda function as part of each call to the Lex API. In this model lex will handle the output of the lambda function and then relay that back as the response, instead of building its own response object to send to the client.
  7. Steps 4–7 repeat until the intent is fulfilled
  8. Finally, once an intent is complete, fulfilled, the Lex chatbot can perform a special action called ‘fulfillment’ in the documentation.

Product Manager + Software Developer. Interested in Travel, Culture, and the Internet.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store