Skip to content

zxdong262/ringcentral-chatbot-template-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ringcentral-chatbot-template-js

Template to build RingCentral chatbot with ringcentral-chatbot-js.

Table of contents

Prerequisites

  • Nodejs 8.10+/npm, recommend using nvm to install nodejs/npm
  • Yarn (npm i -g yarn)
  • Create the bot App: Login to developer.ringcentral.com and create an public Server/Bot app with permissions: ReadContacts, ReadMessages, ReadPresence, Contacts, ReadAccounts, SMS, InternalMessages, ReadCallLog, ReadCallRecording, WebhookSubscriptions, Glip

Development & Quick start

# install dependencies
yarn

# run ngrok proxy
# since bot need https server,
# so we need a https proxy for ringcentral to visit our local server
yarn proxy
# will show:
# Forwarding https://xxxxx.ngrok.io -> localhost:3000

# create env file
cp .sample.env .env
# then edit .env, set proper setting,
# and goto your ringcentral app setting page, set OAuth Redirect URI to https://https://xxxxx.ngrok.io/bot/oauth

# create bot logic file
# edit src/bot.js to create your own bot logic
cp bot-sample.js src/bot.js

# run local dev server
yarn start

Test bot

Building and Deploying to AWS Lambda

AWS Lambda with API Gateway and RDS would give us a flexible way to deploy the bot.

Get an AWS account, create aws_access_key_id and aws_secret_access_key and place them in ~/.aws/credentials, like this:

[default]
aws_access_key_id = <your aws_access_key_id>
aws_secret_access_key = <your aws_secret_access_key>

For more information, refer to https://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html

cp dist/serverless.sample.yml dist/serverless.yml
cp dist/.env.sample.yml dist/.env.yml

AWS Lambda connects AWS RDS issue

  • If you create an RDS manually and let it create a new security group for you.
  • By default, the security group only allows inbound traffic from your current laptop's public IP address AWS Lambda by default cannot access the newly created AWS RDS
  • We need to update security group to allow inbound traffic from 0.0.0.0/0

Edit dist/serverless.yml and dist/.env.yml, and make sure you set the proper name and required env.

Deploy to AWS Lambda with yarn build && yarn deploy

# build
yarn build

# Run this cmd to deploy to AWS Lambda, full build, may take more time
yarn deploy

## watch Lambda server log
yarn watch

Do not forget to set your RingCentral app's redirect URL to Lambda's API Gateway URL, https://xxxx.execute-api.us-east-1.amazonaws.com/prod/bot/oauth for bot app.

License

MIT

About

Template to build ringcentral chatbot with javascript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published