Reputation: 2922
I'm working on an application where I need to get notified when a call is received on the main line or any of the available extensions. Which event should be subscribed to get notification?
Moreover does RingCentral support Webhook notification? At some place I came across something which said RingCentral only supports PubNub but I saw that there is a way to provide TransportType as PubNub or Webhook.
Upvotes: 1
Views: 485
Reputation: 1298
You would want to subscribe to Presence events making sure to set the detailedTelephonyStatus
query parameter to true
.
Here is an example of this from the documentation for creating a subscription to presence events:
POST /restapi/v1.0/subscription HTTP/1.1
Authorization: Bearer U0pDMDFQMDFQQVMwMnxBQUJFU3VOMlp2bjZFR0gxNFhfTUNONhaU1SVHc
Content-Type: application/json
Content-Length: 235
{
"eventFilters": [
"/restapi/v1.0/account/~/extension/~/presence?detailedTelephonyState=true&aggregated=true"
],
"deliveryMode": {
"transportType": "PubNub",
"encryption": "true"
}
}
Within the eventFilters
property, you would want to add an array element for each extension within the account which you wish to monitor.
I have created a sample application built in Node.js for creating a subscription to all of the extensions within a RingCentral sandbox account here: https://github.com/bdeanindy/ringcentral-subscription-basics.
Yes, read the documentation for creating subscriptions https://developers.ringcentral.com/api-docs/latest/index.html#!#RefCreateSubscription and you will see that both PubNub
and Webhook
are supported transportType.
Here is an example of how to create a subscription which uses the Webhook
transportType:
POST /restapi/v1.0/subscription HTTP/1.1
Accept: application/json
Authorization: Bearer U0pDMDFQMDFQQVMwMXxBQURIZjAzWFFySGpMen
Content-Type: application/json
Content-Length: 269
{
"eventFilters": [
"/restapi/v1.0/account/~/extension/~/presence",
"/restapi/v1.0/account/~/extension/~/message-store"
],
"deliveryMode": {
"transportType": "WebHook",
"address": "https://consumer-host.example.com/consumer/path"
}
}
You'll want to make sure to change the deliveryMode.address
value to point to a server you manage to receive the events. This server will need to have a valid certificate chain supporting connections on port 443.
Here is a quick start tutorial on using RingCentral Webhooks.
Upvotes: 2