Creating Simple Bot Leveraging AWS Serverless Services

Sameer Mahajan
3 min readSep 21, 2020

--

Acknowledgement: AWS Fundamentals coursera course of Building Serverless Applications.

We are going to create a bot with which you can interact with voice and find out whether your cat can go out in a specified city. You can try out the bot at: https://domzmdxwh9ho8.cloudfront.net/voice.html from your chrome browser. To interact, click on ‘Push to talk’ button and try saying ‘Can my cat go out in <city of your choice>, say Atlanta?’

Voice Bot Interface

You can find the entire code at: https://github.com/sameermahajan/AWSServerless repo.

We are going to use following AWS Serverless services:

· Lex

· S3

· API Gateway

· CloudFront

· Lambda

· DynamoDB

Create a Simple Bot with Lex

Lex Bot

Creating Serverless Website with S3

1. Create bucket (say 2020–09–18-er-website)

2. Set Static Website Hosting Property

Hosting Static Website using S3 Bucket

3. Allow Access to your bucket using Bucket Policy from Permissions tab

4. Upload website content. While uploading, under Metadata choose header of Cache-Control and set its value to max-age=0

Creating CloudFront Distribution

  1. Create CloudFront Distribution

2. Remove the public access on your s3 bucket since cloudfront would have added Origin Access Identity

Creating a REST endpoint with API Gateway

  1. Create REST endpoint and POST method

2. Enable CORS

3. Wire up API to your website: In scripts/config.js set var API_GATEWAY_URL_STR to be your Invoke URL deployed above.

Create a simple lambda function

  1. Create a simple lambda function

2. Give appropriate permissions to LEX for its execution role

DynamoDB Table

  1. Create a DynamoDB Table

2. Populate DynamoDB table

Making LEX Smarter

  1. Create and Call lambda function from LEX

--

--

Sameer Mahajan
Sameer Mahajan

Written by Sameer Mahajan

Generative AI, Machine Learning, Deep Learning, AI, Traveler

No responses yet