Skip to main content
Question

SMS message status | Polling or MessageEvent?

  • November 2, 2022
  • 1 reply
  • 200 views

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.

1 reply

PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • 2320 replies
  • November 4, 2022

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)
  }
}

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings