serverless, AWS-service-driven Chatbot web application
I will be building an AWS Chatbot using S3, API Gateway, Lambda, Lex, DynamoDB, Elastic Search, and some open source API.
Building chatbot frontend and host it in an AWS S3 bucket. Then set up chat API using AWS API Gateway and connect it with a Lambda function ('chat') to receive and response to chat messages from the user.
- enable CORS on all API methods including the preflight OPTIONS methods.
- import the Javascript SDK to the frontend directory to invoke AWS APIs.
Building chatbot using AWS Lex.
Amazon Lex is an AWS service for building conversational interfaces for applications using voice and text. With Amazon Lex, the same conversational engine that powers Amazon Alexa is now available to any developer, enabling you to build sophisticated, natural language chatbots into your new and existing applications.
- Created the following three intents:
- GreetingIntent
- ThankYouIntent
- HotelSuggestionsIntent Then, set up a lambda function to pass user message to Lex and to receive the processed response from Lex.
- Through conversation, collect the following pieces of information from the user:
- Location
- Checkin date
- pet-friendly
- number of nights to stay
- number of beds
- phone number
-
fulfillment confirmation: Confirm to the user that you received their request and that you will notify them over SMS once you have the list of hotel suggestions.
-
create another lambda function ('chatbot-backend'). in the fullfillmentCodeHook section, push the information collected from the user to an SQS queue ('myQ').
-
Website integration: integrate Lex chatbot into Lambda function 'chat'. Instantiate a 'lex-runtime' client with node.js SDK to establish connection with the bot we just created. Note: need to fix problem importing node modules in Lambda....
Use the API to collect 3,000+ hotels in Manhattan and New Jersey. Create a table in DynamoDB to store the collected data.
Elastic Search
set up a queue-worker Lambda function to pull messages from the SQS queue. Generate recommendation of hotel bookings using ElasticSearch and DynamoDB. Send the recommendation through text message using SNS.
- Lambda queue worker skeleton added
- Set up a scheduler on AWS EventBridge(CloudWatch). Lambda queue worker function will be invoked every one minute. Visibility is tentatively set to 0 for testing purposes.
- Set up AWS SNS
- Build API logic