Skip to main content

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.

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