Retrieve waiting interactions in a queue

Hello team,
I have a requirement to fetch all the conversations in a queue through API. the queue is a test queue and has not been is use for quite a while. there are 170 interactions waiting which we want to disconnect. However the code is returning all interactions. Could anyone please shed some light on the filtering or any metric that will return only the waiting conversation Id list.
-----------------------------------------Code Used------------------------
const platformClient = require('purecloud-platform-client-v2');
const client = platformClient.ApiClient.instance;

// Set environment
client.setEnvironment();

// Login using Client Credentials Grant
client.loginClientCredentialsGrant(Client ID, Client secret)
.then(() => {
// Initialize Analytics API
let apiInstance = new platformClient.AnalyticsApi();

let body = {
  interval: "2024-06-01T00:00:00.000Z/2024-06-23T23:59:59.999Z", // Interval for which data is requested
  order: "asc", 
  orderBy: "conversationStart", 
  paging: { 
    pageSize: 100, 
    pageNumber: 1
  },
  segmentFilters: [
    {
      type: "and",
      predicates: [
        {
          type: "dimension",
          dimension: "queueId",
          operator: "matches",
          value: "0313b38f-58f5-4fcb-b324-4a66837a9a86"
        },
        {
          type: "dimension",
          dimension: "segmentType",
          operator: "matches",
          value: "interact"
        },
        {
          type: "dimension",
          dimension: "purpose",
          operator: "matches" ,
          value: "acd"
        }
      ]
    }
  ]
};
return apiInstance.postAnalyticsConversationsDetailsQuery(body);

})
.then((data) => {
console.log(get conversations data success! Data: ${JSON.stringify(data, null, 2)});
})
.catch((err) => {
console.log('There was a failure calling postAnalyticsConversationsDetailsQuery');
console.error('Error details:', JSON.stringify(err, null, 2));
});

#Reporting/Analytics


Swarup Das
Accenture Solutions Private Limited

Do you mean it is also fetching conversations that have been handled by an agent/tester?

If so could you look at one of the dimensions that only a completed call would have and look for the absence of data - for example SelectedAgentID?

Hi @Swarup_Das ,

If you want to get only waiting interactions, you can use the following:

{
  "segmentFilters": [
    {
      "type": "and",
      "predicates": [
        {
          "type": "dimension",
          "dimension": "queueId",
          "operator": "matches",
          "value": "your-queue-id-here"
        }
      ]
    }
  ],
  "interval": "your-interval-here",
  "conversationFilters": [
    {
      "type": "and",
      "predicates": [
        {
          "type": "dimension",
          "dimension": "conversationEnd",
          "operator": "notExists"
        }
      ]
    }
  ]
}

You should add conversationFilters array with the conversationEnd dimension set to notExists.
This will keep only the waiting interactions, as there is no conversationEnd set while they are waiting.

Hope that helps :slight_smile:

Kind regards,

Charaf

I want to fetch the conversation list waiting in the queue right now. but the code is not working properly. (code below). It is producing 0 hits. If I change the interval, lets say to january it produces result but lot more than what we have in waiting. Hence i believe that is not what we are actually looking for.

interval: "2024-06-29T00:00:00.000Z/2024-06-30T23:59:59.999Z",
segmentFilters: [
{
type: "and",
predicates: [
{
type: "dimension",
dimension: "queueId",
operator: "matches",
value: "0313b38f-58f5-4fcb-b324-4a66837a9a86"
}
]
}
],
conversationFilters: [
{
type: "and",
predicates: [
{
type: "dimension",
dimension: "conversationEnd",
operator: "notExists"
}
]
}
]

Hello Charaf,

Thanks for the suggesntion. But it produced 0 hits. Please see the updated code below.. :roll_eyes:

interval: "2024-06-29T00:00:00.000Z/2024-06-30T23:59:59.999Z",
segmentFilters: [
{
type: "and",
predicates: [
{
type: "dimension",
dimension: "queueId",
operator: "matches",
value: "0313b38f-58f5-4fcb-b324-4a66837a9a86"
}
]
}
],
conversationFilters: [
{
type: "and",
predicates: [
{
type: "dimension",
dimension: "conversationEnd",
operator: "notExists"
}
]
}
]

Hi @Swarup_Das,

It seems the interval specified in your code is incorrect. The correct interval format should be from the start date to today’s date and must not exceed 31 days.

Since today is June 30, 2024, the correct interval should be :

2024-05-31T21:59:59.999Z/2024-06-30T21:59:59.999Z 

This interval spans from May 31, 2024, to June 30, 2024, inclusive of today's date, and does not exceed the 31-day limit.

This should resolve the issue. Let me know if that works :slight_smile:

Kind regards,

Charaf

Surely it worked.. thank you a ton..

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.