项目作者: grokify

项目描述 :
Tools to manage RingCentral webhooks including CLI app Keepalive Lambda function
高级语言: Go
项目地址: git://github.com/grokify/rchooks.git
创建时间: 2018-05-19T04:04:58Z
项目社区:https://github.com/grokify/rchooks

开源协议:MIT License

下载


RCHooks - RingCentral Webhook Tools

Build Status
Lint Status
Go Report Card
Docs
License
Video

rchooks is a toolset for creating, listing, recreating, and deleting RingCentral webhooks. It is especially useful in development when working with ngrok and when webhooks are blocked when test servers are taken down and non-responsive. It includes the following:

  • rchooks CLI app
  • keepalive_lambda AWS Lambda function to check and rebuild webhook when blacklisted
  • rchooks SDK package for utilities to build your own apps

YouTube Tutorial Video: https://youtu.be/DYrzzJe8OyI

Apps

CLI App

CLI Installation

  1. $ go install github.com/grokify/rchooks/cmd/rchooks
  2. $ rchooks --env=/path/to/.env --list

Prior to Go 1.18, use go get:

  1. $ go get github.com/grokify/rchooks/cmd/rchooks
  2. $ rchooks --env=/path/to/.env --list

CLI Usage

By default, rchooks looks for an environment file path specified by the ENV_PATH environment variable or a .env file in the current working directory. You can also explicitly specify a .env file with the --env path parameter.

  1. $ rchooks --list
  2. $ rchooks --create=https://example.com/webhook
  3. $ rchooks --recreate=https://example.com/webhook
  4. $ rchooks --recreate=11112222-3333-4444-5555-66667777888
  5. $ rchooks --delete=https://example.com/webhook
  6. $ rchooks --delete=11112222-3333-4444-5555-66667777888

Configure OAuth by setting the oauth2more/credentials file via --creds and the account via --account.

Set the following enviroment variables:

  • RINGCENTRAL_WEBHOOK_DEFINITION_JSON - Create subscription JSON body
Example Webhook Definition

An example value for RINGCENTRAL_WEBHOOK_DEFINITION_JSON can be the following. For a long lived webhook, use a value like 500000000 seconds which is equivalent to 15.85 years.

  1. {
  2. "eventFilters":[
  3. "/restapi/v1.0/glip/posts",
  4. "/restapi/v1.0/glip/groups",
  5. "/restapi/v1.0/account/~/extension/~/message-store/instant?type=SMS"
  6. ],
  7. "deliveryMode":{
  8. "transportType":"WebHook",
  9. "address":"https://12345678.execute-api.us-east-1.amazonaws.com/prod/webhook"
  10. },
  11. "expiresIn":500000000
  12. }

Compact example:

{"eventFilters":["/restapi/v1.0/glip/posts","/restapi/v1.0/glip/groups","/restapi/v1.0/account/~/extension/~/message-store/instant?type=SMS"],"deliveryMode":{"transportType":"WebHook","address":"https://12345678.execute-api.us-east-1.amazonaws.com/prod/webhook"},"expiresIn":500000000}

Keepalive Lambda Function

Installation

Build the lambda function and then upload to AWS:

  1. $ go get github.com/grokify/rchooks
  2. $ cd $GOPATH/src/github.com/grokify/rchooks/apps/keepalive_lambda
  3. $ sh build_lambda.sh

Set the following enviroment variables:

  • RINGCENTRAL_TOKEN - JSON string or simple access token string
  • RINGCENTRAL_SERVER_URL
  • RINGCENTRAL_WEBHOOK_DEFINITION_JSON - Create subscription JSON body

Notes

Blacklist Reasons

  • I/O operation is failed. Details: [Read timed out]
  • Webhook response exceeds max size. Read bytes count: [1024]
  • Webhook responses with code: [404], reason: [Not Found]