Skip to main content

Hi,

I am implementing a feature which tracks all sent faxes on a NodeJS backend. I don't want to request the API regularly, but subscribe a notification to received events and take actions based on the events.

I checked the documents, the fax sending event tracks inbound faxes, from my understanding, this is for tracking all received faxes, and my final finding is to subscribe Message Events with the following eventFilter

/restapi/v1.0/account/{accountId}/extension/{extensionId}/message-store?type=Fax&direction=Outbound

I added a subscription with this eventFilter, sent several faxes to test this webhook, and found the following two types of events

  1. events with newCount > 0 which means new faxes have been created. in this case, a field called newMessageIds will be attached and I can easily find out the newly created fax with messageStatus and readStatus
  2. events with updatedCount > 0, which means, usually, the status of some faxes have been updated, i.e. a fax has been sent successsfully. But in this case, there is no information indicated which faxes have been updated, here is a sample req.body I received for this type of events:
{
   uuid: "********************",
   event: "/restapi/v1.0/account/**********/extension/*******/message-store",
   timestamp: "2023-07-19T15:40:12.734Z",
   subscriptionId: "********-****-****-****-************",
   ownerId: "********",
   body: {
     accountId: ********,
     extensionId: ********,
     lastUpdated: "2023-07-19T15:40:00.232Z",
     changes: b
       {
         type: "Fax",
         newCount: 0,
         updatedCount: 1,
         newMessageIds: e]
       }
     ]
   }
 }

My question is: is there a way to figure out precisely which faxes have been updated in this case? or the eventFilter is wrong to do such a job? if yes, which one to use? Thanks

You did a good job in learning, trying and explaining how the notification works so far.

Unfortunately, what you are facing is the limitation of the message store event notification for changed events, which do not include the message id of a message that got updated. This limitation has been discussed internally several times and we still don't have a solution for it.

The only option as a workaround solution is to first catch the event with newCount, call the message store with the message id to detect the Fax message status, if it is not Delivered or Failed, then keep the message id in an array and poll again when you get the updated events.


Thank you for your reply.

After comparing the information of several faxes, I found that the values of lastUpdated in the message event and lastModifiedTime in the record are very close. In the few faxes I tested, the two are basically the same, or the difference is only a few milliseconds. Can we reliably use this situation to make decisions?


Reply