-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Subscribe for New SMS Messages | ||
|
||
A common use case is to subscribe to all incoming SMS messages. This can be used to either sync messages or to take action in incoming messages. RingCentral has a couple of ways to retrieve incoming messages. This tutorial describes retrieving messages one at a time where there is no replicated dataset. If you wish to replicate to your own datastore, please contact RingCentral devsupport. | ||
|
||
To retrieve incoming SMS messages, there are two steps | ||
|
||
1. Subscribe for events on the message store to receive information on new SMS messages | ||
2. Retrieve the messages from the message store by querying the store for the time range | ||
|
||
### Step 1: Subscription for new SMS events: | ||
|
||
For this step, create a subscription to the `/restapi/v1.0/account/~/extension/~/message-store` event filter with the account id and extension id of interest where `~` represents your currently authorized values. When receiving an event, you will receive an array of `changes` of which, some can have the `type` attribute set to `SMS` along with a `newCount` attribute. When `newCount` is > 0, there is a new SMS. Information on subscription is here: | ||
|
||
* [Dev Guide: Notifications](https://developer.ringcentral.com/api-docs/latest/index.html#!#Notifications.html) | ||
* [API Reference: Notifications](https://developer.ringcentral.com/api-docs/latest/index.html#!#RefNotifications.html) | ||
|
||
### Step 2: SMS Retrieval | ||
|
||
To retrieve the new SMS message given an subscription, use the event's `body.lastUpdated` time property to retrieve inbound SMS messages matching that time. You can do this with the following steps: | ||
|
||
1. Retrieve the event's `body.lastUpdated` property | ||
2. Create a message store API call setting the `dateFrom` and `dateTo` parameters around the event's `body.lastUpdated` property. You can set the range to be 1 second on either side. | ||
3. Upon receiving an array of messages in the response, filter the messages on the message `lastModifiedTime` which will be the same as the event's `body.lastUpdated` time. | ||
|
||
For additional reading, see: | ||
|
||
* [Dev Guide: Messaging](https://developer.ringcentral.com/api-docs/latest/index.html#!#MessagingGuide.html) | ||
* [API Reference: Message List](https://developer.ringcentral.com/api-docs/latest/index.html#!#MessageList.html) | ||
|
||
### Example Implementation | ||
|
||
The above is implemented in an example script using the Ruby SDK. The script retrieves each message and sends it to a Glip chat team using the `Glip::Poster` module. Other chat modules with the same interfae can also be used. | ||
|
||
* Script: [sms_to_chat.rb](https://github.com/grokify/ringcentral-sdk-ruby/blob/master/scripts/sms_to_chat.rb) | ||
* SDK : [messages_retriever.rb](https://github.com/grokify/ringcentral-sdk-ruby/blob/master/lib/ringcentral_sdk/rest/messages_retriever.rb) |
4 changes: 1 addition & 3 deletions
4
...fications/Subscriptions-All-Extensions.md → ...ifications/Subscribe_to_All_Extensions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters