Creating Simple Bot Leveraging AWS Serverless Services
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?’
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
Creating Serverless Website with S3
1. Create bucket (say 2020–09–18-er-website)
2. Set Static Website Hosting Property
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
- 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
- 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
- Create a simple lambda function
2. Give appropriate permissions to LEX for its execution role
DynamoDB Table
- Create a DynamoDB Table
2. Populate DynamoDB table
Making LEX Smarter
- Create and Call lambda function from LEX