question

Thomas Janicik avatar image
Thomas Janicik asked Phong Vu commented

SMS message status | Polling or MessageEvent?

Say the response to creating an sms message has a status of "Queued". Would subscribing to the message store message event fire an event when delivery status is changed and include an entry in the changes array within the body? Or is that solely for read status from a rc user perspective?


I'm trying to figure out if there's any way to avoid polling for status until a final status is achieved or the 3 retries are exhausted.

sms and text messaging
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered Phong Vu commented

You can use the message-store event notification to avoid polling. But to check the message status, you still need to call the Get Message API to detect the status of the message. Here is a simple sample code in Node to check.

// Provided that you subscribe for this event filter
'/restapi/v1.0/account/~/extension/~/message-store?type=SMS&direction=Outbound'

// Then when you receive a new notification. Assumed that the msg is the notification payload

for (var message of msg.body.changes){
  for (var msgId of message.newMessageIds){
    await checkMessageStatus(msgId)
  }
}
async function checkMessageStatus(msgId){
  try{
    var resp = await platform.get(`/restapi/v1.0/account/~/extension/~/message-store/${msgId}`)
    var jsonObj = await resp.json()
    console.log("Message status: " + jsonObj.messageStatus)
  }catch(e){
    console.log(e.message)
  }
}
2 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thomas Janicik avatar image Thomas Janicik commented ·

I haven't been able to trigger a message event in the sandbox that has updated messages rather than new messages, I'm assuming because you already received a successful delivery response from your sms provider before the initial new message event is sent. I did notice that the example for message event in the documentation is missing the newMessageIds array. I also noticed that the message changes class in the .net nuget package is missing this array as well.

Does the changes object include an updatedMessageIds array when there are messages that have been updated?

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Thomas Janicik commented ·

updated event is only for message status changed as Read/Unread or I think also Deleted.

0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys