Can you use JavaScript SDK to read incoming SMS messages

  • 4 February 2016
  • 1 reply

  • Anonymous
  • 0 replies

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 reply

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:!#Notifications.html
API Reference:!#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:!#MessagingGuide.html
API Reference:!#MessageList.html

Example Implementation

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


This post is now included with the Ruby SDK here:

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