Select Page

And now for something completely different. Chat bots are a technology that I have not had the opportunity to use in the past. Recently I was given a opportunity to get one working for a proof of concept. There are a few different options in this space, but we chose to go forward with AWS Lex.

I had two main goals

  • Understand the technology stack and integration options.
  • Learn how to program Lex.

Terminology

There are a few key terms that you need to be familiar with when discussing AWS Lex based chat bots.

  • Intent – This is the context of the conversation. If a chat conversation is usually a more human friendly method for collecting information then the intent is the questionnaire to be filled in through the chat. A chat bot can have any number of intents. For example Purchase and Returns could be two intents for a shopping chat bot
  • Utterance – How a user might convey the intent. I think of them as trigger words/phrases to identify the intent
  • Slot – This is the information to be collected as part of the intent, you can have zero or more Slots as part of an intent. In developer terms this can be thought of as the variables to be populated for an intent.
  • Slot Value – This defines that expected values of a slot. In developer terms this is similar to the data type. These can range from a custom set of words including aliases for those words to a built in type such as date or numbers.

Getting Started

Thankfully creating a fully functional web accessible Chat bot was very painless. AWS has already spent some time writing some good starting material for Lex. In one of their posts has a link to a cloud formation template for creating a complete environment. You can just accept all the default settings during the deployment. One thing to note is that this will stand up the stack in region us-east-1. Lex is not available in all regions at this time.  This should only be a temporary restriction as AWS has a long history of rolling out their services to all regions over time.

The cloud formation template stands up everything you will need just accept all the defaults and deploy. To try out the Sample Chat bot just go to the ParentPageUrl that gets populated in the cloud formation template

All things working well you will be presented with web page and a chat bot built-in.

Observations

It’s good that Lex has got the basic smarts to translate textual versions of words to their slot type equivalents eg twelve = 12 , Noon = 12:00, Tuesday  = 19/2/2019
I did discover a small issue with the default chat bot. When talking about dates/times for a slot you can say things like “today” was evaluated based on the region where Lex is running not your locale. I haven’t investigated if there a way to change this setting.

The showcase integration with AWS Polly (Voice to text) was a nice touch and shows you the path from text based chat to voice based. However, other testers experience intermittent issues with the chat window not loading which I think are related to the sample JavaScript code needed to enable the microphone. It also felt a bit slow and had some problems understanding me. I’ll put in a disclaimer that I didn’t see if these issues could be resolved.

Customisation

The next step was to customise the default chat bot. Thankfully the basic chat bot can be controlled via the standard AWS console website. Changing the chat bot through the GUI was painless if you remember to change the version of your slots to Latest when you build the chat bot. Otherwise it will compile it with the version of the Slot from the last successful build meaning slot updates are never incorporated.  From the GUI you can edit the intents, Utterances, slots and slot values. Building a more advance chat bot which has conditional logic and any sort of dynamic validation requires Lambda compatible code to be written to implement the feature.  There is a lot or prebuilt types from Languages,  There is also the capability to test your chat bot within the console as well.

Overall impressions

I’m impressed with the easy foundations that AWS gives you for building a chat bot. Using Lambda Code hooks with Lex to integrate with other AWS services opens up options for what you can do. This means you can create some interesting chat bot functionality without too much pain. Lex meets the standard 80/20 rule. I can see making a chat box to deal with simple scenarios will be quick, but making it smarter to deal with the vagaries of human communication will take a lot effort in training/code. An example of this complexity is a simple intent which starts by the user typing a greeting. How many utterances could someone use to say hello to you? Hi, Hello, Good Morning, kia ora, greetings …..

Thanks, Ben.

 

Ben writes blogs on the technical side of BI, the code, all the code and not much other than the code.  Recently, he wrote a blog about getting started on relational databases and SQL which might help a recent grad looking for a Junior Dev role.

%d bloggers like this: