News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Can you use JavaScript SDK to read incoming SMS messages
Tags: sdk
Feb 4, 2016 at 11:05am   •   1 replies  •  0 likes
jscgroup

Is there any way to read incoming SMS using JavaScript SDK/API. If so can you please provide more details including where to download the SDK/APIs.

1 Answer
answered on Feb 5, 2016 at 6:55pm  
You can do this using the API and JavaScript SDK. There's more than one day to do this so it would help to know how you intend to use the messages that are retrieved Do you intend to sync a datastore of SMS messages or to use them in another downstream action?

One way to do this requires two steps as shown below. There are other ways to do this so please let us know your use case.

1. Subscribing for events on the message store to receive information on new SMS messages
2. Retrieving the messages from the message store by querying the store for the time range

Step 1: Subscription for new SMS events:

For step one, you can subscribe to the ''/restapi/v1.0/account/~/extension/~/message-store'' event filter where ~ indicates your currently authorized account_id and extension_id. 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: https://developer.ringcentral.com/api-docs/latest/index.html#!#Notifications.html
API Reference: https://developer.ringcentral.com/api-docs/latest/index.html#!#RefNotifications.html

Step 2: SMS Retrieval

To retrieve the new SMS message, call the message-store endpoint. Use the event's "body.lastUpdated" time attribute to query the message-store. You can limit the message-store query by setting the "dateFrom" and "dateTo" to around the "body.lastUpdated" time, e.g. set "dateFrom" and "dateTo" to 1 second less and greater than the "body.lastUpdated" time respectively. Upon receiving an array of messages, filter on the message's "lastModifiedTime" which will match the event's "body.lastUpdated" time.

Dev Guide: https://developer.ringcentral.com/api-docs/latest/index.html#!#MessagingGuide.html
API Reference: https://developer.ringcentral.com/api-docs/latest/index.html#!#MessageList.html

Example Implementation

This is implemented in the community Ruby SDK which posts each incoming message to the Glip chat service.

Script: https://github.com/grokify/ringcentral-sdk-ruby/blob/master/scripts/sms_to_chat.rb

This post is now included with the Ruby SDK here:

http://ringcentral-sdk-ruby.readthedocs.org/en/latest/usage/notifications/Subscribe_for_New_SMS/

You can take the same concepts and implement this in JavaScript.

 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us