This is a sample chatbot application using Amazon Lex
and Amazon Translate
to automatically translate
incoming requests, process them and translate the responses back to their original language.
It is based on claudia-bot-builder
and it is compatible with many
messaging platforms,
such as Facebook Messenger
, Telegram
, Skype
, Slack
and also Amazon Echo (Alexa)
.
claudia-bot-builder
runs on Amazon Lambda
and
Amazon API Gateway
.
Read this article to find out more.
-
This chatbot is meant to prototype a new service or product and run the first iterations over it. Although it can scale virtually infinitely using the Amazon platform, for the long run it is most probably better to switch to human-curated translations and save on the requests issued to Lex and Translate, that are billed per-use.
-
The AWS free tier SHOULD allow you to test this bot for free, but please read its terms and conditions carefully. You may be charged for AWS services usage. In particular, Lex and Translate free tiers only last for 12 months after the first request (at the time of writing). So if your account is older than that you may have already used up your free tier. Also, all services subject to the free tier do enforce usage limits for it. Make sure that your usage is within those limits. Be safe and set an AWS Budget to detect unwanted or excessive charges early on. You are responsible for that.
-
The training data (city names) provided to the chatbot for the
Location
slot is very minimal and not enough for the machine learning to properly determine its nature, so stick to the provided list of cities when testing the bot. Other cities might not work.
Node.JS v10.x.x
This bot is built on claudia-bot-builder
and uses Claudia.JS
for deployments on AWS
. Since version 2 of the bot framework
was released, Claudia.JS
was decoupled from the framework
and MUST be installed separately. Claudia.JS
can be either
installed as a global package or a local dependency.
In order to make the distribution of this package easier for
users and for it to coexist with other versions of Claudia.JS
,
it has been included as a local dependency.
Zip the aws/lex/WeatherBot_Export.json
file and import it using the Lex
console:
- Sign in to the AWS Management Console and open the Amazon Lex console, Bots page.
- From
Actions
, chooseImport
. - From
Import Bot
, choose the.zip
archive that contains theJSON
file that contains the bot to import. - Press
Import
. - Press
Build
to build the bot. - Press
Publish
and name the deployment:Development
.
Install the required dependencies first:
$ npm install
Run the following command, replacing {AWS_REGION}
with your
AWS region of choice:
$ ./node_modules/.bin/claudia create \
--region {AWS_REGION} \
--api-module bot \
--version development \
--policies aws/iam/policies.json \
--set-env-from-json aws/lambda/env.json
If you have multiple AWS profiles configured on your machine, specify the profile
$ AWS_PROFILE={PROFILE_NAME} \
./node_modules/.bin/claudia create \
--region {AWS_REGION} \
--api-module bot \
--version development \
--policies aws/iam/policies.json \
--set-env-from-json aws/lambda/env.json
For detailed information on connecting a bot to a messaing
platform, please see the
claudia-bot-builder
Hello World Chat Bot doc.
To get started quickly and test a bot, Telegram
is a very good place to start from. Creating and configuring a bot takes
only a few steps.
- Create a bot on Telegram
- Deploy the chatbot as described in First deployment above
- Run
and follow the instructions shown on the screen.
$ ./node_modules/.bin/claudia --configure-telegram-bot
This bot uses the MetaWeather API
to deliver the
weather forecast. You can ask it:
How is the weather in Milan?
How will the weather be like in Boston on monday?
in any language supported by Amazon Translate
that can be translated to English.
Please read the Caveats paragraph above and see the
aws/lex/WeatherBot_Export.json
file for the list
of cities that are safe to use in this demo.
Run:
$ npm install
$ npm test
This code is released under the MIT license
.
Please read it carefully before using it.