- Node.js
v4.3.0
or later. Download - Serverless CLI
v1.9.0
or later. You can runnpm install -g serverless
to install it once node is installed - An AWS account. If you don't already have one, you can sign up for a free trial that includes 1 million free Lambda requests per month.
- Set-up your CredentialsAWS Docs. Watch the video on setting up credentials Serverless
- Go to Lex console and select OrderFlowers as bot
- Create a Lambda function by going to Lambda Console and using filter Lex and selecting OrderFlowerLex nodejs blueprint
- Specify respective roles etc and test Lambda function using Lex Flower bot test event
- Go to LEX console select OrderFlower bot and attach the Lambda Function to Initialization and validation code hook and confirmation
- Build the bot and publish it by providing an alias name
- There is a folder node_http
- Got to folder make sure you have node installed
- Open app.js in your machine set your AWS access key, password and specify Bot Parameters like botName, alias etc in script.
- Type node server when you are in the folder and it will have a web server running at http://localhost:3000
- Make sure you never checkin changes with your AWS access key and ID
- Try your utterances from the UI screen
In case you want to deploy lambda function from your desktop instead of using AWS templates (use below instructions)
Create a new service using the Node.js template, specifying a unique name and an optional path for your service.
# Create a new Serverless Service/Project
$ serverless create --template aws-nodejs --path nodejsbot
# Change into the newly created directory
$ cd nodejsbot
# Replace handler.js and serverless.yml by the files provided in repo
File replaced by repo version
- Deploy the Service
serverless deploy -v
-
Go to AWS console create a LEX Bot using Lex FlowerBot template
-
Attach the Lambda function created with the Bot
-
Test the chatbot and refer Cloudwatch logs
If at any point, you no longer need your service, you can run the following command to remove the Functions, Events and Resources that were created, and ensure that you don't incur any unexpected charges.
serverless remove