question

Shijun Deng avatar image
Shijun Deng asked Shijun Deng commented

Webhook to receive outbound fax events

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: [
        {
          type: "Fax",
          newCount: 0,
          updatedCount: 1,
          newMessageIds: []
        }
      ]
    }
  }

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

faxwebhooks
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 Shijun Deng commented

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.

1 comment
1 |3000

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

Shijun Deng avatar image Shijun Deng commented ·

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?

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