Skip to main content

Simple ringcentral chatbot framework python extension that add `bot info` command support.

Project description

ringcentral-chatbot-python-ext-bot-info

Simple ringcentral chatbot python extension that add bot info command support.

screen

Table of contents

Prerequisites

  • Python3.6+ and Pip3
  • Nodejs 8.10+/npm, recommend using nvm to install nodejs/npm
  • 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

Quick start

# use virtualenv
pip3 install virtualenv # might need sudo

# init virtual env
virtualenv venv --python=python3

# use env
source ./venv/bin/activate

# install deps
pip install -r requirements.txt
npm i

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

# 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
RINGCENTRAL_BOT_SERVER=https://xxxxx.ngrok.io

## for bots auth required, get them from your ringcentral app page
RINGCENTRAL_BOT_CLIENT_ID=
RINGCENTRAL_BOT_CLIENT_SECRET=

# run local dev server
./bin/start

Test bot

Building and Deploying to AWS Lambda

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

*Be aware that AWS Lambda ONLY works in linux on an x64 architecture. For non-linux os, we need docker to build dependencies, should install docker first.

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 dev/lambda/serverless.sample.yml devlambda/serverless.yml

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

# you can define service wide environment variables here
  environment:
    NODE_ENV: production
    # ringcentral apps

    ## bots
    RINGCENTRAL_BOT_CLIENT_ID:
    RINGCENTRAL_BOT_CLIENT_SECRET:

    ## common
    RINGCENTRAL_SERVER: https://platform.devtest.ringcentral.com
    RINGCENTRAL_BOT_SERVER: https://xxxx.execute-api.us-east-1.amazonaws.com/default/poc-your-bot-name-dev-bot

    # db
    DB_TYPE: dynamodb
    DYNAMODB_TABLE_PREFIX: rc_bot2
    DYNAMODB_REGION: us-east-1

Deploy to AWS Lambda with bin/deploy

# install serverless related modules
npm i

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

## watch Lambda server log
bin/watch
  • 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 AmazonDynamoDBFullAccess and AWSLambdaRole policies 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-oauth for bot app.

The bot create process

create

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file ringcentral_bot_framework_extension_botinfo-0.0.1.tar.gz.

File metadata

  • Download URL: ringcentral_bot_framework_extension_botinfo-0.0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for ringcentral_bot_framework_extension_botinfo-0.0.1.tar.gz
Algorithm Hash digest
SHA256 37e20eaa887c9c767986a41fa1399703bef4135180b67106124a606209e80bcc
MD5 bb2c0ab755de823eda8c2b7dbbdf11da
BLAKE2b-256 c2ceb53d85ee290c6842992242b8794bc6b7159f8201b459762edfa3b8d47401

See more details on using hashes here.

File details

Details for the file ringcentral_bot_framework_extension_botinfo-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ringcentral_bot_framework_extension_botinfo-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2fae525eb70186978c6afebd26df73559a08b3c32e2ab6e70d819bc05c2d888e
MD5 666f96eb768b323d5e8ef566c03f8a14
BLAKE2b-256 62aa9ed24093335935a7b7dbb8d6547addd0cfd9375c44944711e95095c9ed91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page