Create a chatbot that translates languages using Amazon Translate and Amazon Lex

Tigerine
3 min readMar 23, 2023

Link to online tutorial can be found here

Warning!!!!!! Amazon Lex console has been upgraded! Amazon Lex console has been upgraded!! Amazon Lex console has been upgraded!!!

Why this dramatic warning? Just to give you a heads up that the online tutorial is difficult to follow considering the Amazon Lex console has a new UI and some things are not applicable

Let me walk you through the steps I took and how it all played out

Step 1: Downloading and preprocessing your dataset

I used the Sherlock Holmes e-book as recommended by the tutorial and used python to clean up the data and zip the 100 randomly selected sentences into a zip file.

The python script suggested in the tutorial gave an error when I ran it so I had to replace the “r” in the block of code below with “utf-8”

Block of code as seen in tutorial
Updated block of code I used

After running the code successfully, 2 new files were created (a json file and a zip file)

Step 2: Creating the Amazon Lex translator bot

The UI shown in the tutorial was the Amazon Lex V1 console. Today, there is a V2 console which is tad different. I had no issues figuring out how to complete the tasks like creating an intent, a slot type, sample utterances etc

However I needed to create a new slot type with the zip file created from Step 1. In the new Amazon Lex console, the option to import a zip file as a slot type isn’t available (yet) and I couldn’t figure out how to go about it. My research didn’t show any clear way to go around this and when I used chatGPT, it gave instructions with the assumption that the Amazon Lex console was still in Version 1.

So what did I do?

I saw the option of returning to the V1 console and I quickly jumped on the offer.

Everything went well after the switch (although I still had to figure some little things out) and I successfully completed the project.

In the course of my research, I bumped into this interesting tutorial on another Amazon Lex use case. You can check it out here

Disclaimer: This article describes my personal journey and recommendations made are merely suggestions.
Please feel free to share your thoughts, feedback or criticisms. Look forward to hearing from you

--

--

Tigerine

Just here to express my thoughts and all the chaos that goes on in my head. Baring it all out here so I hope you get to relate with my content.