Deploy to AWS
## Deploy to AWS (Lambda + Postgres)We use serverless framework as the main deployment tool, which utilizes YAML config files to define deployment parameters so to simply the process.
- Rename
sample.serverless.yml
toserverless.yml
, andsample.env.yml
toenv.yml
- In
serverless.yml
, fill inservice: {service-name}
at the top, andtags
(optional, deletetags
if not needed). - In
env.yml
, fill in all empty fields, most of them are the same as in your local.env
file. Make sure 2{DBUSERNAME}
and{DBPASSWORD}
are replaced with the actual values. - In console, run
npm run serverless-build
. - Make sure you have your aws user credentials configured in your local environment. Do
npm run serverless-deploy
. (Note: it does install packages -> zip the project -> create AWS services and upload zip) - Go to here to create your bot instance.
There has always been a problem to make serverless services work with RDS (the fact that serverless applications usually generate too many instances with database connections while RDS has been designed to handle low amount of connections at the same time.). AWS recently provide its RDS Proxy service as a solution to it.
We strongly suggest that you should add a RDS proxy in-between your lambda and RDS. Don't worry, it's pretty simple.
- Refer to this doc's Step 3 to create an IAM role for your proxy accessing database secret
- Go to AWS console -> Secret Manager ->
Store a new secret
-> Credentials for Amazon RDS database -> fill inusername
andpassword
(same as in yourenv.yml
) -> select your db -> input a name andNext
->Next
->Store
- Go to AWS console -> RDS -> Proxies ->
Create Proxy
.Identifier
: you could use the same name as your service's nameEngine
: PostgreSQLDatabase
: choose the database you just createdSecrets Manager secret(s)
: choose the secret you just createdIAM Role
: choose the role you just createdAdditional connectivity configuration
->Existing VPC security groups
: choose both db and lambda groupsCreate Proxy
- To validate connectivity, in command line, do
aws rds describe-db-proxy-targets --db-proxy-name $DB_PROXY_NAME
(replace$DB_PROXY_NAME
with your proxy name). A successful connection will return state asAVAILABLE
. - Now go to here to create your bot instance.
Deploy to Heroku
## Deploy to HerokuFork this repo and click below button for your first time deployment. (Note: Heroku Button is to be used for the first time setup. Further changes are to be made on Heroku app web page)
Right after the deployment, make sure taking following steps to configure it:
- Go to your app settings page on Heroku
- Go to
Domains
section and copy your server url (do not include the last '/'). Let's call itBotServerUrl
- Reveal Config Vars
- Find
RINGCENTRAL_CHATBOT_SERVER
and edit it to beBotServerUrl
- Find
DATABASE_URL
and copy its value. Put it ontoRINGCENTRAL_CHATBOT_DATABASE_CONNECTION_URI
- Go to app's
Deploy
tab - In
Deployment method
section, connect it with your Github repo. - Enable
Automatic deploys
. It will then deploy upon every git push to your git remote repo.
- Create a
Bot Add-In
app - Go to your app's
Settings
tab on RingCentral Developer Portal - Find
OAuth Redirect URI
and fill it with{BotSererUrl}/bot/oauth
- Go to
Bot
tab and clickAdd to RingCentral
(Note: bot server url might not be updated right away. Please wait for a few minutes if it fails.)
Note: Aha server seems like using an internal polling mechanism which doesn't send the activity message right after the change. It feels like there's a 5min interval.
Note: if bot's status is In Sandbox
, then go to https://app.devtest.ringcentral.com/
. Please also update RINGCENTRAL_SERVER
in Heroku app env var config if switching between Sandbox and Production
Add the bot to a group chat and type @{botName} help
or direct message the bot help
.
Have a look at src/handlers/botHandler.js
, it's pretty straightforward.
Adaptive card can be designed with Adaptive Cards Designer where the json data in CARD PAYLOAD EDITOR
can be save as xxx.json
and stored under src/adaptive-cards
folder. Please refer to existing use of ahaCard.json
as example.