Skip to content

edonosotti/serverless-bot-skeleton-with-analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codebeat badge

serverless-bot-skeleton-with-analytics

Description

A multi-platform, serverless chatbot skeleton, with support for Natural Language Processing services, Sentiment Analysis and Analytics.

Available integrations:

  • Chatbase (analytics)
  • Dialogflow (Natural Language Processing)

Upcoming integrations:

  • Amazon Comprehend (analytics) + Amazon Translate (translation)
  • Amazon Lex (Natural Language Processing)

Features

  • Runs on AWS Lambda, based on claudia-bot-builder
  • Supports multiple messaging platforms: Facebook, Skype, Slack, Telegram, Viber
  • Supports Amazon Echo (Alexa)
  • Built-in Chatbase integration for usage analytics
  • Built-in Dialogflow integration for Natural Language Processing

Requirements

  • Node.js 6.10 (depends on available AWS Lambda runtimes)

Deploying

Prerequisites

  • An Amazon Web Services account

Configuring Dialogflow

  1. Create a new agent
  2. Zip the /config/dialogflow directory (zip the whole directory from "outside")
  3. Open the agent settings
  4. Go to Export and Import
  5. Choose Restore from zip
  6. Select the .zip file created at step #2

Deploying the bot to AWS Lambda

Being based on Claudia.JS tools and bot framework, deploying the bot is a simple and straightforward operation. Please refer to the official claudia-bot-builder tutorial, paragraph: Deploying the bot.

It's also worth reading the tutorial on managing multiple environments in Lambda.

Please note that claudia commands MUST be ran from the /src directory. If is not installed "globally", you can use the local copy packaged with the sources: $ ./node_modules/.bin/claudia.

Setting the environment variables

Set the following environment variables in the AWS Lambda function created with claudia:

VARIABLE NAME DESCRIPTION
DIALOGFLOW_CLIENT_ACCESS_KEY Dialogflow Client Access Token
CHATBASE_API_KEY Chatbase API Key

Environment variables can also be set with claudia, using the --set-env and --set-env-from-json option switches.

Run: $ ./node_modules/.bin/claudia create --help from the /src directory for info.

claudia also supports AWS KMS to encrypt environment variables values, see the "help" for the --env-kms-key-arn option switch.

A note on vendorized dependencies

This project includes a local copy of its dependencies, stored in the /src/node_modules directory. This practice is known as "vendoring" and is not generally considered a best practice, but an annoying and dangerous incident happened not even long ago in the Node.JS community made me re-evaluate it. You can find good coverage of the incident searching for: "node.js broke the internet", such as:

To perform a fresh installation of all the dependencies, just remove all files from the /src/node_modules directory and run: $ npm install from the /src directory.