Build a Star Trek custom bot with Amazon Lex Automated Chatbot Designer (Preview) - Conversational AI - Part 2
Tags: beginners, tutorial, ai, programming
Published: 2022-03-14 13:53:08

## Introduction

In the previous blog, we explored building a chabot with existing data using Amazon Lex Automated Chatbot Designer (Preview) to book a flight recommended for development and not for production workloads.

### Where do I find audio transcripts?

The challenge in any data analytic or machine learning project is to find quality data. You may search for possible audio transcripts in JSON file format from the following sources:

* Google Data Search
* Github
* Kaggle.com
* [AWS Data Exchange](https://console.aws.amazon.com/dataexchange)

![AWS Data exchange](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18p5c67tv3unrtoevjc1.png)

### Pre-requisite - Create an Amazon S3 bucket

Ensure that you are able to source quality audio transcripts in JSON file format which you can store in an Amazon S3 bucket.

I was able to locate a Star Trek audio transcript from Github but the link is no longer available as at 18 April 2024.

Step 1: Sign in with IAM user role
Step 2: In navigation bar search for Amazon S3
Step 3: In Amazon S3 console click **Create Bucket**
Step 4: Name your bucket e.g. startrekmovie and change the region to US East (N.Virginia) us-east-1 


![give bucket name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rpx40x3dpmbt0qw93ofl.png)

Step 5: Scroll to the bottom of the screen and click **Create Bucket**.

Step 6: Click the Startrekmovie bucket and click **Upload** then click **Add file** and finally click **Upload**.

The startrekdialogue_v2.json file will be uploaded into your Amazon S3 bucket

![upload](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z18zbadbhdmo88wm5j9h.png)

Step 7: The Amazon S3 bucket has successfully been created.


![bucket created](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0kz0gq8eloq07by3oafb.png)

### Tutorial: Create a StarTrek custom bot with Amazon Lex Automated Chatbot Designer (Preview)

You can access Amazon Lex V2 from the Amazon Lex console and create a bot to analyze thousands of lines of transripts and deep learning will be able to quickly determine the intent.

You may follow the steps in this tutorial to create a custom bot follows the steps outlined in the blog written by Priyanka Tiwari and Harshal Pimpalkhute on 1 [December 2021](https://aws.amazon.com/blogs/machine-learning/expedite-conversation-design-with-the-automated-chatbot-designer-in-amazon-lex/) 'Expedite conversation design with automated chatbot designer in Amazon Lex.

Step 1: Sign in to the AWS Management Console and open the [Amazon Lex V2 console](https://console.aws.amazon.com/lexv2/) change your AWS region to US East (N.Virginia) us-east-1 from the drop-down menu.


![consoleon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/82nd79asq9wofqhw3rt2.png)

![create bot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nlgcxrsl3dmmu2a3lqvg.png)
Click **Create bot**.

Step 2: Select **Start with transcripts** as the bot creation method.


![start with transcripts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grf5u9fc17lgnolu623g.png)


Step 3: Under Bot Configuration, give the bot a name e.g. StarTrekBot

Provide a description of the Bot e.g. Helpdesk to fly to the moon

Step 4: Select **Create a role with basic Amazon Lex Permissions** and a new IAM role will be created for Amazon Lex V2.


![IAM bot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ioml0joyafdk7oh2ti06.png)

Step 5: Under Children's Privacy Protection Act (COPPA) if the bot will not be accessed by minors under age 18 you may select **No**.


![COPPA](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l35nbbr8xk0x0bphb0q2.png)

Click **Next**.

![Next](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hlpn2xwfx4fxgwlc1ov1.png)

Amazon Automated Chatbot Designer (Preview) is only available in US English as at 1 December 2021.

Step 6: Add language to the custom bot.

You may experiment with the different languages or retain the default settings.

![Kimberly](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/stvnfcgs1spmpopgraat.png)

Step 6: Choose the S3 bucket path where the transcript i.e. Star Trek Dialogue was saved


![S3 for V2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfwm7d2kbpolafox40of.png)

Step 7: An optional step is to use AWS Key Management Service (AWS KMS) to encrypt output transcripts.

Step 8: You can specify a date range for the bot to read transcripts.

Step 9: Select **Done**

The bot will take a few hours to analyze the intents and associated phrases of the intent.

Note: Amazon will update your service role with Amazon Lex permissions to access the S3 bucket if you created an Amazon Lex V2 role to read transcripts.

If you created your own Amazon Lex V2 role this will need to be updated and you may read the documentation [here](https://docs.aws.amazon.com/lexv2/latest/dg/using-service-linked-roles.html).


![read transcipts](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8e48tqjjv1v9rj8q4u0a.png)

Step 10: You may review the intents derived from the Automated Chatbot designer.

Happy Learning! 😁

Here is a link to the [slides](https://github.com/wendy-wong/wendywong.github.io/blob/master/AWS%20User%20Group%20MY%20Building%20a%20chatbot%20with%20Amazon%20Lex%20V2%2009032022%5B2305843009239265098%5D.pdf) on Github from the AWS User Group Malaysia Meetup on 9 March 2022.

If you are in the Asia Pacific region and Japan, you may join an AWS User Group such as AWS User Group Malaysia Meetup at this [link](https://www.meetup.com/AWSUGMY/) or join an AWS User Group in your city by accessing this [link](https://aws.amazon.com/developer/community/usergroups/)

### Resources

* [Using your own IAM role for Amazon Lex V2](https://docs.aws.amazon.com/lexv2/latest/dg/using-service-linked-roles.html)

* [Amazon Lex V2 Developer Guide](https://docs.aws.amazon.com/lexv2/latest/dg/what-is.html)

### References

* Star Trek dialogue: https://github.com/BirkoRuzicka/Star-Trek-Transcripts