Considerations For Chatbot Migration from Amazon Lex to Rasa

Original article was published by Cobus Greyling on Artificial Intelligence on Medium


The SDK option yields a more generic and useable format from a Rasa perspective. JSON queries can be used to extract the data of interest.

Below is an extract from the Lex ASK export… The format is very convenient and similar to the Rasa nlu.md file.

{"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."],

And here is another example from book hotel intent.

{"name":"BookHotel",
"samples":[
"Book a hotel",
"I want a make hotel reservations", "Book a {Nights} night stay in {Location}"],

Creating intents will be a straight-forward process from the examples. It is convenient that the entity name is defined in the user utterance example denoted with curly brackets.

The only drawback is that entity examples are not included within the utterance examples. So for this step possible manual intervention is required. With file manipulation, entity values can be extracted.

Below is an example of entity/slot names and values. Again, with JSON queries these can be extracted.

[{"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":[]}}]}],

Amazon really encourages developers to use built-in slot types. When exported these are empty, and hence will demand manual intervention to complete.

On entities, Lex have specific prompts and confirmation prompts settings which will lost. Or at least have to be rebuilt.

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.

Each chatbot solution will have to examined to see how these elements can be best migrated to Rasa.

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.

Should it be used extensively, you might want to to consider using Forms in Rasa.

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.

The problem lies with the Amazon specific entities, and Lex specific entity prompt and confirmations; this functionality will have to be instituted.

And obviously the dialog, state management and integration elements will have to be assessed.