Here at Zuto we recently had a hackday. For anyone not familiar with the concept it simply meant we had a day to work on projects outside of our day to day. The only steer we had was use AWS as our cloud provider where appropriate.
Several of us decided we would try writing a bot which could be integrated with via different channels (SMS, facebook messenger, voice, etc...) to get a quote for car finance.
The first step was to get a bot running in the AWS Lex platform.
Setting up the bot
AWS is a mature platform (even if elements are new) and comes with some pretty good documentation, including a good guide for building a custom bot -
AWS Lambda provides the ability to run code in the cloud without the overhead of managing servers etc. This is where we can put complex business logic that can use the data captured from the user by Lex's basic request & response based conversation.
We used NodeJS for our language. Lambda provides two ways to upload your NodeJS code:
Inline in the AWS console
Upload a zip file
For us, the much faster feedback route was to use the online editor. This lead to fairly messy code, and had we had more time we would have set up a neater editing/deployment process using a zip file upload.
Testing of the lambda was done by providing a typical test message from Lex and applying this data to the function using the online console. The test data is stored with the Lambda function, so whenever we changed the Lex bot in a way the interface to the Lambda function changed, we would update our sample test data accordingly.
Lex itself is fairly straightforward to configure in simple cases. You have -
Utterances - These are the statements to respond to initiate any interaction (and can be changed together in more complex cases). These are simply text value which can be entered which are matched to the text/voice input. These can contains slots or not.
Slots - These are the parameters which are going to be supplied by the user during the interaction. E.g. in a pizza ordering example the size of the pizza. In our case we defined three. Some custom data types so using the long list of built in data types (more on this in "What we learnt")
Fulfilment - What to do with the result of the interaction. To use AWS Lambda as the back end you simply pick the function from a drop down. It's that easy.
There are further options but this was all we needed to get the basic bot working.
Once this is all done you can simply build your bot and use the in built test tool to try it out via voice or text.
Our bot wasn't much use without something demonstrable. Lex's test tool is fine for testing but when you're showing your work off to other people you really need to have something driving the bot otherwise the whole thing feels a little fake and unimpressive. We tried a few approaches:
Having previously had experience with integrating Microsoft's bot framework with Facebook Messenger we thought this would be straight forward. Unfortunately we were wrong.
We found a guide and followed it closely but despite entering all the correct keys in the correct boxes (as far as we can tell - the guide was not entirely clear and out of date from a facebook point of view), we had no luck. The worst part was there is no easy way to gain insight into what was going wrong. We could see no requests hitting our Lex bot but had no way to determine why.
This combined with the time limitations of a hack day meant we decided to move on.
Unfortunately this integration also proved fruitless. Lex provides a Twilio integration, but after signing up for a Twilio account the console just hung on connecting Lex to the account. Without this fundamental step there was no chance we would get this working so dropped the SMS integration.
Amazon makes it exceptionally easy to create a mobile app for your bot. In literally a couple of clicks you can generate a basic unbranded Android or iOS app which adds voice and natural language interface to your bot.
We found this overview and followed these steps:
- Headed over to the AWS Mobile Hub
- Chose QuoteCalculator from the list of our projects.
- Clicked on the Integrate link.
- Clicked on the Download your example mobile app project link
- Built the project. We created an Android app - additional info on getting started with this here
- Copied the APK to our device and talked to our bot!
We aren't mobile app experts by any means but it was trivial to get this up and running. We spent a few minutes ammending some of the assets to add some Zuto branding and ended up with a pretty kickass demo!
What we learnt
- Slot types - there is a long list of slot types predefined in AWS, such as cities, actors etc. One glaring omission for us though was currency. In a natural conversation, the user will say something like "five hundred pounds", but in a text input field they would expect the currency to be there and just enter 500. Lex does not support currency at all currently, so the closest we could get was integers. The second slot type we had issues with was time duration. It's impressive in the way it can take a variety of phrases that mean the same thing (such as 1 year and 12 months) and produce an ISO standard time duraton, but the voice recognition just seemed to be a bit weak and caused us more misreadings than any of the other slot types we used.
- The first time we built the Lex bot we could not understand why all the controls are now read only. There is an irritating feature which means each time you builds it switches to the built version and you need to pick "Latest" from the version drop down -
- The integrations with third parties are still unreliable with little to no feedback available if everything does not work.
- The number of integrations is very limited right now - Twilio, Slack and Facebook Messenger being the only ones. We expect this to improve with time.