Outbound SMS subscription event and gathering specifics of the message sent

  • 1
  • Problem
  • Updated 3 weeks ago
  • (Edited)
I'm using the SMS subscription event and attempting to pull the details of outbound messages from the message store. This works fine if it's a single SMS, but if messages are being sent in relatively rapid succession (say three messages over the span of 25 seconds), I'm seeing the event looks like this

lastUpdated: '2019-03-01T16:45:32.899Z',
  changes: [ { type: 'SMS', newCount: 2, updatedCount: 1 } ] }

Trying to filter the message store by either the time stamp or the newCount ends up missing one (or more) of the messages. I could subtract a given value from the timestamp, but that then runs the risk of pulling in duplicated values.

Anyone with some insight into this?
Photo of Brennon Dean

Brennon Dean

  • 92 Points 75 badge 2x thumb

Posted 3 weeks ago

  • 1
Photo of Tyler Long

Tyler Long, Official Rep

  • 9,336 Points 5k badge 2x thumb
You can keep a small cache in your program to remember the message IDs.  Then you can filter out duplicate by message id.

Or you can call sync messages: https://github.com/ringcentral/RingCentral.Net/blob/master/samples.md#sync-messages

Sync token can make sure you can get all and no duplicates: https://github.com/ringcentral/RingCentral.Net/blob/master/RingCentral.Net/Definitions/SyncMessagesP...
Photo of Brennon Dean

Brennon Dean

  • 92 Points 75 badge 2x thumb
Thanks Tyler! Is it intended behavior for messageType and direction parameters to throw invalid parameter errors with message sync when using a syncToken? Not a huge deal because I can just filter it after the API returns values, more curious. I'm able to reproduce this behavior using the tool on the ringcentral site here:

https://developer.ringcentral.com/api-reference#SMS-and-MMS-syncMessages



Edit: Perhaps I'm misunderstanding, but this is the response behavior I'm getting with the following endpoint. The 'test' values are the outgoing message values. I'm updating the syncToken value each time with the last value returned.

/account/~/extension/~/message-sync?syncToken=TOKENVALUE&syncType=ISync

[[12:18:32.280]] [LOG]   syncToken: AQEAAAAAAwAAAWk_pNlQBgAAAPoFAAABaUAN85ATAAgAAAAADtmLVAkBCgEZAAABaUAOUU2HPQIg
[[12:18:32.488]] [LOG]   test 67
[[12:18:32.489]] [LOG]   test 68
[[12:18:52.310]] [LOG]   syncToken: AQEAAAAAAwAAAWk_pNlQBgAAAPoFAAABaUAOq8gTAAgAAAAADtmLVAkBCgEZAAABaUAOwpUSXZIb
[[12:18:52.680]] [LOG]   test 67
[[12:18:52.684]] [LOG]   test 68
[[12:18:52.686]] [LOG]   test 69
[[12:19:12.254]] [LOG]   syncToken: AQEAAAAAAwAAAWk_pNlQBgAAAPoFAAABaUAO_vITAAgAAAAADtmLVAkBCgEZAAABaUAPFJ09c8LN
[[12:19:12.487]] [LOG]   test 69
[[12:19:12.490]] [LOG]   test 70
(Edited)
Photo of Tyler Long

Tyler Long, Official Rep

  • 9,246 Points 5k badge 2x thumb
As my understanding, for the first page you specify all the searching parameters and syncType=FSync.

For the remaining pages you specify syncType=ISync. And you should not change the searching parameters or do not specify them at all.

If it is not as I described, it might be a bug on our side. Please do let me know.

As the doc says, you should be able to use these searching parameters: https://github.com/ringcentral/RingCentral.Net/blob/master/RingCentral.Net/Definitions/SyncMessagesP...  Let me know if it is not the case.
Photo of Brennon Dean

Brennon Dean

  • 92 Points 75 badge 2x thumb
Hey Tyler, appreciate the response. It does look like ISync will still return values that were previously reported from the last time it was performed. (E.g. the same outgoing text message will be returned multiple times). I was trying to avoid tracking by ID, but decided that would probably be easiest in this situation.
Photo of Tyler Long

Tyler Long, Official Rep

  • 9,246 Points 5k badge 2x thumb
You should specify the token from last response for ISync.   If you don't change token, you will get duplicate response.

But if you did as I described and still have the issue. Could you please send me some sample code to show me how you do the pagination? I would like to reproduce the issue myself.