Hi,
We use a Data Action to retrieve the amount of transfers that a conversation had. This value we show in the agent script so that the agent can see that the call has been transferred.
Input Contract
{
"title": "input",
"type": "object",
"properties": {
"conversationId": {
"type": "string"
}
},
"additionalProperties": true
}
Output Contract
{
"title": "output",
"type": "object",
"properties": {
"nTransferred": {
"type": [
"integer",
"null"
]
}
},
"additionalProperties": true
}
Request
{
"requestUrlTemplate": "/api/v2/analytics/conversations/${input.conversationId}/details",
"requestType": "GET",
"headers": {},
"requestTemplate": "${input.rawRequest}"
}
Response
{
"translationMap": {
"nTransferredArrayAsStr": "$.participants[*].sessions[*].metrics[?(@.name=='nTransferred')].value"
},
"translationMapDefaults": {
"nTransferredArrayAsStr": "[]"
},
"successTemplate": "#set ($nTransferredArray = $nTransferredArrayAsStr.replace(\"[\", \"\").replace(\"]\", \"\").replace(\" \", \"\").split(\",\")) {\"nTransferred\":$math.getTotal(${nTransferredArray})}"
}
Now if there have been some transfers it works like a charm:
But on the first transfer the value is not there so I receive an error, I have been searching and trying but cannot seem to find the solution.
Error message: 10. Apply output transformation: Transform failed to process result using 'successTemplate' template due to error:'Reference $math.getTotal(${nTransferredArray}) evaluated to null when attempting to render at successTemplate[line 1, column 131]' Template:'#set ($nTransferredArray = $nTransferredArrayAsStr.replace("[", "").replace("]", "").replace(" ", "").split(",")) {"nTransferred":$math.getTotal(${nTransferredArray})}'.
Is there anyone that has a suggestion?
Thanks in advance!
BR,
Rob