Considerations For Chatbot Migration from Amazon Lex to Rasa

And Using The Migration Process As An Opportunity for Chatbot Improvement

Introduction

Migration of a chatbot or any Conversational AI/UI environment is not something which will happen often. Invariably during the initialization of the chatbot process, organizations opt for a familiar and mainstream solution technology.

Image for post
Image for post
Amazon Lex Listed Under The Machine Learning Services on AWS.
  • Some cloud providers charge per functionality added.
  • Lack of collaboration tools.
  • Waiting & being dependent on cloud providers to roll out required features and functionality.
  • Introduction of languages and vernacular.
  • Difficulty in offsetting cost with savings or revenue from the chatbot.
  • The challenge with the big cloud NLU/NLP solutions will always remain the issue of protection of personal information and control of data.

Lex Architecture

There are two general approaches to chatbot architecture. The first being a situation where the elements are combined and cannot be decomposed.

Image for post
Image for post
Rasa architecture with the Amazon Lex approach overplayed. With the script being the notable exception.

Intents

Image for post
Image for post
Amazon Lex: Adding A New Intent
Image for post
Image for post
Amazon Lex: Sample Utterances Can Be Added For Intents

Entities

Firstly, if intents are the verbs, entities are the nouns. In the case of a travel chatbot, entities will be dates, places, modes of transport etc. Lex does not refer these nouns as entities; but rather slots.

Image for post
Image for post
Entity slots are color coded and contextually defined.

Script

The script for the chatbot will mostly be defined within Lex, and ample provision is made for confirmation prompts, follow-up prompts, and final prompts.

Image for post
Image for post
Testing basic dialog within the Amazon Lex console.

Dialog Management

The dialog flow (also known as state management or dialog management) is analogous to how Microsoft LUIS fits into the Microsoft bot framework.

Image for post
Image for post
The Business Logic Required To fulfill the User’s Intent
Chatbot Using Amazon Lex & Lambda Functions

Migration

Let’s look at the migration process in two parts:

  • Dialog

NLU

Before you export the Amazon Lex bot, you need to ensure that it is built and published within the console. If not, the elements you see in the console might not reflect in the JSON export file.

Image for post
Image for post
Ensure the bot is built and published to ensure all changes are reflected in the exported JSON
Image for post
Image for post
Exporting Amazon Lex bot from the AWS console
{"intents":
[{"name":"BookCar",
"samples":[
"I am getting the car in {PickUpCity} on {PickUpDate} and dropping at George. I am {DriverAge} and I want {CarType}",
"I will be getting the car in {PickUpCity} on {PickUpDate} and dropping at George. I am {DriverAge} and I want {CarType}", "I will pick up the car in {PickUpCity} on {PickUpDate} and return it at George. I am {DriverAge} and I want {CarType}", "I am getting the car in {PickUpCity} on {PickUpDate} and dropping at Cape Town."],
{"name":"BookHotel",
"samples":[
"Book a hotel",
"I want a make hotel reservations", "Book a {Nights} night stay in {Location}"],
[{"name":"RoomTypeValues",
"values":[
{"name":{"value":"deluxe","synonyms":[]}},
{"name":{"value":"queen","synonyms":[]}},
{"name":{"value":"king","synonyms":[]}}]},

{"name":"CarTypeValues",
"values":[
{"name":{"value":"standard","synonyms":[]}},
{"name":{"value":"full size","synonyms":[]}},
{"name":{"value":"midsize","synonyms":[]}},
{"name":{"value":"luxury","synonyms":[]}},
{"name":{"value":"economy","synonyms":[]}},
{"name":{"value":"minivan","synonyms":[]}}]}],

Dialog Management

The chatbot elements which falls outside of NLU will have to be approach based on the methods employed. It can be assumed that for an Amazon Lex chatbot, the dialog, context and integration portions will most probably vest in a AWS Lambda function.

Slots & Forms

With Amazon Lex, slots/entities can be set to mandatory and individual prompts can be set to solicit a response from the user. It all depends on how these individual prompts are employed in your Lex bot.

Conclusion

The upside is that intents and training examples can easily be migrated to Rasa. From an entity perspective, the data is available, with some effort it can also be migrated.

Written by

NLP/NLU, Chatbots, Voice, Conversational UI/UX, CX Designer, Developer, Ubiquitous User Interfaces. www.cobusgreyling.me

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