Template to build RingCentral chatbot with ringcentral-chatbot-js.
- 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
# 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
- Goto your ringcentral app's bot section, click 'Add to glip'
- Login to https://glip-app.devtest.ringcentral.com, find the bot by searching its name. Talk to the bot.
- Edit config.py to change bot bahavior and test in https://glip-app.devtest.ringcentral.com
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
- 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.
MIT