Adam | 2020-05-11 20:29:06 UTC | #1
Hello --
I'm trying to programmatically determine when a new VM has entered a queue, and is ready for an agent to listen to it. I'd like to use this "event" to trigger some additional code (which will notify our CRM that we received a new VM).
I'm using the Notifications API and subscribing to v2.routing.queues.xyz.conversations.
From the notification message's EventBody.Id, I can get the Conversation details. From there I can get the Conversation's Participants. From a Participant I can get Callbacks. From a Callback I can get a Voicemail.
Currently, I'm looking to see if the Participant.Purpose == 'customer' (I need participant data attributes), and then if the Callback.State == Connected, and then if the Voicemail.UploadStatus == Complete. This is a total shot in the dark, as I'm really not sure what I should be keying off of to determine "this is a new VM sitting in the queue."
First question: in terms of what I'm currently keying off of, am I remotely on the right path? Should I even be using the Notifications API for this?
Second question: Even with checking that the Callback is connected and Voicemail.UploadStatus is complete, there are still multiple notifications. I can't seem to figure out the logic to narrow it down to a single notification that I can then use to trigger the rest of my code; and I'm worried about duplicates.
Any assistance would be greatly appreciated.
Best, Adam
tim.smith | 2020-05-13 15:56:11 UTC | #2
Adam, post:1, topic:7758
First question: in terms of what I'm currently keying off of, am I remotely on the right path? Should I even be using the Notifications API for this?
The logic you described sounds right. Using notifications is the correct approach to receiving real-time data.
Adam, post:1, topic:7758
Second question: Even with checking that the Callback is connected and Voicemail.UploadStatus is complete, there are still multiple notifications. I can't seem to figure out the logic to narrow it down to a single notification that I can then use to trigger the rest of my code; and I'm worried about duplicates.
You will receive notifications any time anything about the conversation changes. Your app needs to cache conversation state and diff the incoming notification with the last known state to determine what is different and if the app should take action on those differences. Taking action on every notification will almost certainly yield undesirable results.
system | 2020-06-13 15:56:15 UTC | #3
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 7758