- Notifications
You must be signed in to change notification settings - Fork3
This repository contains the guide to walk developers through the process of creating a Glip bot using the ringcentral-ai-bot framework.
License
ringcentral-tutorials/ringcentral-ai-bot
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This project contains the code and resources needed for developers to build and deploy a voicemailassistant bot on top of the RingCentral Glip messaging platform. The bot contained within thisframework can, with a user's permission, monitor a user's voicemail for incoming messages, andthen alert the user via a Glip message of a new voicemail. In addition, it can interface withGoogle's speech-to-text APIs to transcribe the incoming message, analysis with Google's cloud AI(Cloud Natural Language API) and post the text and result to user as well.
The bot contained within is meant to be used in conjunction with adetailed tutorial on building botson Glip. As a result, the bot intentionally lacks some functionality that ideally developerswould implement by completing the corresponding tutorial.
The bot provided by this project is capable of responding to the following command:
monitor- enable monitoring of the current user's voicemail messages.
When a voicemail is received, the bot will post a transcript of the voicemail to the user, along with some high-level analysis of the contents of the voicemail.
This bot is includes core bot features that are intended to be extracted to a Glip bot framework that seeks to eliminate the need to develop a lot of the mundane functions necessary to support a bot that is easily deployed, and authorized to access a user's account. Here are some of the functions this framework will provide to developers:
- Implements an OAuth flow for adding bots to a Glip organization.
- Implements an OAuth flow for prompting users to grant the bot permission to access their RingCentral account data.
- Automatically refreshes event subscriptions before they expire.
- Provides a simple framework for developers to implement new commands and functionality.
- Persists and manages authentication tokens for users of the bot.
A detailed guide for getting the bot up and running is provided in thebot's tutorial. For those developers more familiar with RingCentral wishing to dive right in, the following instructions will help:
Prerequisites
- Node.js >= 8.10
- Yarn
- a Google API account with asaved Google credentials file, note that you can still run local demo to see how it works without Google account/credential, but with fake demo data.
git clone git@github.com:ringcentral-tutorials/ringcentral-ai-bot.gitcd ringcentral-ai-botyarn installIf you are developing on your local machine, you may need to create a proxy/tunnel to the outside world so that your bot can receive webhooks properly. You can do this easily by executing the following command in a separate terminal:
cd ringcentral-ai-botyarn proxyMake note of the ngrok HTTPS URL for use later.
Login todeveloper.ringcentral.com and create two different apps using the parameters below.
- General Settings
- Choose a name and description you prefer.
- App Type and Platform
- Application Type: Public
- Platform Type:
Server/Bot - Carrier:accept the default values
- OAuth Settings
- Permissions Needed: All of them (ReadContacts, ReadMessages, ReadPresence, Contacts, ReadAccounts, SMS, InternalMessages, ReadCallLog, ReadCallRecording, WebhookSubscrip
tions, Glip) - OAuth Redirect URI: Using your ngrok HTTPS URL from above, enter in the following value:
https://1234abcd.ngrok.io/oauth-bot
- Permissions Needed: All of them (ReadContacts, ReadMessages, ReadPresence, Contacts, ReadAccounts, SMS, InternalMessages, ReadCallLog, ReadCallRecording, WebhookSubscrip
- General Settings
- Choose a name and description you prefer.
- App Type and Platform
- Application Type: Public
- Platform Type:
Browser-based - Carrier:accept the default values
- OAuth Settings
- Permissions Needed: All of them (ReadContacts, ReadMessages, ReadPresence, Contacts, ReadAccounts, SMS, InternalMessages, ReadCallLog, ReadCallRecording, WebhookSubscriptions, Glip)
- OAuth Redirect URI: Using your ngrok HTTPS URL from above, enter in the following value:
https://1234abcd.ngrok.io/oauth-user
Make a copy of the sample.env file.
cp .sample.env .envThen edit the.env file and populate it with the parameters unique to your install.
Finally, start the server:
yarn devLogin tohttps://app.devtest.ringcentral.com, find the bot by searching its name. Talk to the bot, and follow the its instructions.
# install pm2 first if you wanna use pm2yarn global add pm2# or `npm i -g pm2`# buildyarn build# run production serveryarn prod-server# use pm2pm2 start bin/pm2.yml
AWS Lambda with API Gateway and DynamoDB would give us a flexible way to deploy the bot.
Be aware that AWS LambdaONLY works in linux on an x64 architecture. Therefore, some dependencies will need to be prebuilt and uploaded to Lambda on a linux x64 instance. You could do this in ci or any linux server/destop env.
Get an AWS account, createaws_access_key_id andaws_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 tohttps://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html
cp lambda/serverless.sample.yml lambda/serverless.yml
Editlambda/serverless.yml, and make sure you set the proper name and required env.
# you can define service wide environment variables hereenvironment:NODE_ENV:production# ringcentral apps## botsRINGCENTRAL_BOT_CLIENT_ID:RINGCENTRAL_BOT_CLIENT_SECRET:## userRINGCENTRAL_USER_CLIENT_ID:RINGCENTRAL_USER_CLIENT_SECRET:## commonRINGCENTRAL_SERVER:https://platform.devtest.ringcentral.comRINGCENTRAL_BOT_SERVER:https://xxxx.execute-api.us-east-1.amazonaws.com/default/poc-your-bot-name-dev-bot## for google cloud api crendential pathGOOGLE_APPLICATION_CREDENTIALS:path/to/google-credential.json# dbDB_TYPE:dynamodbDYNAMODB_TABLE_PREFIX:rc_ai_bot1DYNAMODB_REGION:us-east-1
Deploy to AWS Lambda withyarn deploy
# Run this cmd to deploy to AWS Lambda, full build, may take more timeyarn deploy## watch Lambda server logyarn watch## update functionyarn update## update without build, fast update, no rebuildyarn u
- Create API Gateway for your Lambda function, shape as
https://xxxx.execute-api.us-east-1.amazonaws.com/default/poc-your-bot-name-dev-bot/{action+} - Make sure your Lambda function role has permission to read/write dynamodb(Set this from AWS IAM roles, could simply attach
AmazonDynamoDBFullAccessandAWSLambdaRolepolicies to Lambda function's role) - Make sure your Lambda function's timeout more than 5 minutes
- 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/default/poc-your-bot-name-dev-bot/bot-oauthfor bot app,https://xxxx.execute-api.us-east-1.amazonaws.com/default/poc-your-bot-name-dev-bot/user-oauthfor user app.
This repo also serves as a tutorial that can be viewed online athttps://ringcentral-tutorials.github.io/ringcentral-ai-bot. If you would like to contribute to the documentation effort, clone this repository and run the documentation server locally via the following commands:
# install depsyarn# start local docs serveryarn docsThen visithttp://localhost:8888 to check the tutorial
You can editdocs/tutorial/index.jade, docs will auto updatedocs/index.html, refreshhttp://localhost:8888 to see the change.
- The concept of this bot is designed by@grokify
- @tylerlong wrote the token management logic
- @zxdong262 implemented everything else
- @byrnereese contributed to the documentation effort
- https://developer.ringcentral.com/legacy-api-reference/index.html#!#Overview.html
- https://ringcentral-api-docs.readthedocs.io/en/latest/glip_bots/
- https://github.com/grokify/ringcentral-polling-and-syncing
- https://github.com/ringcentral/ringcentral-js
- https://github.com/tylerlong/ringcentral-js-concise
- https://github.com/grokify/groupbot
- https://github.com/tylerlong/subx
- https://github.com/zxdong262/audio-analysis-service (Voice transcript/analysis related external service)
MIT
© 2018 RingCentral, Inc.
About
This repository contains the guide to walk developers through the process of creating a Glip bot using the ringcentral-ai-bot framework.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.