Brian_McGlothlen | 2019-07-02 22:49:09 UTC | #1
I'm using the following query to get all the conversations since the last time we called the API: /api/v2/analytics/conversations/aggregates/query. My plan is to call this every minute or so to get all the new unprocessed conversations. My question is since we're using a watermark timestamp to only get the conversations after the last time we made the call, what happens if there is a very long call?
I believe the interval range is based on the start time of the call (but, not sure). And, it's important to make sure the watermark is not moved past calls that haven't completed, because then we'll miss calls. So, if there's a really long call, then there will be a bunch of short calls that finish quickly while the long call still hasn't finished. Therefore, our system will need to wait until the really long call completes (because it has the earliest start time), before we can process the really short calls.
Am I doing this correctly? Any ideas on how to read many calls concurrently when I want to process them soon after they complete? Also, I was told that I needed to use this API even if I implement a web hook, because the web hooks are not guaranteed to be delivered because there are no retries.
Thanks for your help.
tim.smith | 2019-07-03 20:22:13 UTC | #2
Analytics queries will return conversations that had activity during the interval. You will definitely get repeated results when querying every minute.
Brian_McGlothlen, post:1, topic:5478
Also, I was told that I needed to use this API even if I implement a web hook, because the web hooks are not guaranteed to be delivered because there are no retries.
PureCloud doesn't have any outbound webhooks. Maybe you're referring to Notifications?
What are you trying to accomplish? If you can describe your need, I can try and recommend an approach.
Brian_McGlothlen | 2019-07-03 20:49:44 UTC | #3
Thanks for getting back to me. Yes, I meant Notifications.
What I'm trying to accomplish is reading and processing conversation recordings as soon as they are available. However, I only need to process each recording once. I understand that I can use Notifications, but since they are not guaranteed to be delivered (no retries) I need to query for recordings another way. So, that's why I'm using the analytics API.
What's the best way to accomplish this task?
tim.smith | 2019-07-05 17:55:07 UTC | #4
The most straightforward way to do this is to process conversations in intervals of 5-10 minutes with a delay that will guarantee all conversations have ended. For example, if your call center runs 9 am to 5 pm, you could have a job that runs late that night to make analytics detail queries to get a list of conversations for the day, then retrieve recordings for each. Because there shouldn't be any active calls after hours and all recordings should be ready due to delaying several hours, this process allows conversations to be processed without much additional logic.
If you have a requirement to retrieve the recordings as soon as possible, I would suggest using notifications. While you are correct that notification messages aren't guaranteed, it's very rare for them to be missed as long as your socket connection is maintained. You can mitigate any connection drops and missed messages by reconciling the list of conversations you know about from notifications with the results of an analytics query run every 5-10 minutes or when the app knows it lost connection. This process will be more labor intensive since it has to track the state of conversations to know when they've ended, but is unavoidable if you need this data in near real time.
One thing to note regardless of what option you pursue, you shouldn't page through more than around 10 pages of analytics results if possible. It's better to have a shorter interval with less pages than a big interval with lots of pages. This is a technical side effect of how analytics data is accessed behind the scenes; the deeper you go into paging, the longer queries take to return.
Additionally, you can request new features (e.g. a notification topic for when a recording is ready) and share your use case at https://purecloud.ideas.aha.io/ideas.
Brian_McGlothlen | 2019-07-09 23:00:41 UTC | #5
A couple more questions on this thread then?
- If I need to control the number of pages, how do I know how many pages I'll get back if I query based on a begin to end time range? Also, I wasn't aware of paging, because I seem to get all my results in one go. Is there an actual paging API that I call over and over again like I request the number of rows with an offset?
- When I use the begin and end time range in the aggregates query, is it filtering based on the record's beginning conversation time or the record's end conversation time?
- Does your system create a conversation record after the conversation is started, but before the recording is finished? I know the recordings show up a bit after the conversation is finished, but I haven't checked to see if the conversation record is there while I'm still on the phone.
- I was told watermarks are the way to drive this API. But, after what you've said I'm not sure. I understand that I will need to implement notifications. But, I will still need to call the aggregates query API, and I want to know how would you call this API to make sure I don't read the same conversations over again. I think you mentioned I should set up a cache to store records I've already read, and then use somewhat deeply overlapping times to make sure I don't miss long recordings. To do this, I need to understand the answers to the questions above. I can't assume any particular delay since our customer's recording lengths vary a lot, and many of our customers call centers are open 24 hours a day.
Thanks for your help, Brian
tim.smith | 2019-07-10 15:01:30 UTC | #6
- Paging is part of the query. You don't know how many pages there are until you've retrieved them all. When you retrieve the next page and there are no results, you've reached the end. If you're unsure how to retrieve pages, see the Analytics Query Builder; it supports paging.
- It depends on exactly what dimension and operator you're using.
- When a conversation is created, a conversation ID is allocated immediately. All events and data for that conversation will be accessed either directly or indirectly by that conversation ID. Unless noted otherwise, all conversation data is available in real-time.
system | 2019-08-09 15:01:30 UTC | #7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 5478