I'm working on a workflow where I need to retrieve agent details, wrap-up code, and call duration using a Data Action. The goal is to update a Salesforce case when the agent disconnects the interaction.
Currently, I'm using the following API endpoint:
/api/v2/conversations/${input.conversationId}
to collect the conversation details.
Initially, I tried handling this in the workflow using a loop with the following condition:
ToString(GetJsonObjectProperty(Flow.participants[State.participantLoopCount], "purpose")) == "agent"
However, we're encountering errors when parsing the full JSON response. later, we filtered the output using JSONPath expressions like:
"wrapupNotes": "$.participants[?(@.purpose == 'agent')].wrapup.notes",
"UserId": "$.participants[?(@.purpose == 'agent')].userId",
"wrapupCode": "$.participants[?(@.purpose == 'agent')].wrapup.code",
"agentName": "$.participants[?(@.purpose == 'agent')].name",
"startTime": "$.startTime",
"attributes": "$.participants[0].attributes",
"endTime": "$.endTime",
"customerName": "$.participants[0].name",
"queue": "$.participants[?(@.purpose == 'agent')].queueName",
"direction": "$.participants[0].calls[0].direction",
"wrapupName": "$.participants[?(@.purpose == 'agent')].wrapup.name"
The challenge arises when multiple agents are involved in the same conversation. The API response returns multiple agent participants, so these fields come back as arrays. This makes it difficult to reliably extract the specific agent's wrap-up details and duration that we need for the Salesforce update.
Is there a more specific API endpoint or recommended approach to retrieve agent-level details (including wrap-up code and duration) more efficiently in scenarios where multiple agents are part of the same conversation?
Appreciate any guidance or best practices you can share. Thanks!
#API/Integrations#ArchitectandDesign#Implementation------------------------------
Mohamed Shibil
Contact Center Engineer
------------------------------