You should be able to achieve this using an Analytics Query for Conversation Details (POST /api/v2/analytics/conversations/details/query).
You will have to parse the result to extract your WrapUp code and notes.
Under the agent participant structure - "wrapUpCode" (for the id of the selected WrapUp Code) and "wrapUpNote"
The request could use the following body.
{
"interval": "$$Your_Query_Interval$$",
"order": "desc",
"orderBy": "conversationStart",
"paging": {
"pageSize": 3,
"pageNumber": 1
},
"segmentFilters": [
{
"type": "and",
"predicates": [
{
"type": "dimension",
"dimension": "mediaType",
"operator": "matches",
"value": "voice"
},
{
"type": "dimension",
"dimension": "purpose",
"operator": "matches",
"value": "agent"
},
{
"type": "dimension",
"dimension": "ani",
"operator": "matches",
"value": "tel:$$Your_Customer_Phone_number$$"
}
]
}
],
"conversationFilters": [
{
"type": "and",
"predicates": [
{
"type": "dimension",
"dimension": "conversationEnd",
"operator": "exists"
}
]
}
]
}
Few comments on this one:
Replace $$Your_Query_Interval$$ with the interval you want to query. Note that the maximum duration of the Interval is one month.
I have set the "order" attribute to "desc" so that most recent conversations are at the beginning of the conversations array (most recent to oldest conversations)
I have set "pageSize" to 3 to retrieve the last 3 voice calls (note that there may be 0, 1, 2 or 3 calls - depending on customer previous calls in the requested time interval).
In my predicates (using "and" condition), I have checked:
-- mediaType=voice (to avoid getting a web callback conversation)
-- purpose=agent (to make sure this was a call which was connected to an agent - and not a call in self-service IVR/Bot or a call abandoned in a Queue before reaching an agent)
-- ani=tel:$$Your_Customer_Phone_number$$ (you may adapt this to your environment - in mine, the ANI will appear as "tel:+33123456789" in the conversation details)
-- conversationEnd exists (to only retrieve previous ended/terminated calls and not the current one).
Regards,