{
"name": "Surveys - Get RnR MetaData - Exported 2022-11-28 @ 15:12",
"integrationType": "purecloud-data-actions",
"actionType": "custom",
"config": {
"request": {
"requestUrlTemplate": "/api/v2/conversations/[ConversationIDHere]",
"requestType": "GET",
"headers": {},
"requestTemplate": "${input.rawRequest}"
},
"response": {
"translationMap": {
"participantCount": "$.participants[?(@.purpose == 'agent')].purpose.size()"
},
"translationMapDefaults": {},
"successTemplate": "{\n\"participantCount\": ${participantCount}\n}"
}
},
"contract": {
"input": {
"inputSchema": {
"type": "object",
"properties": {},
"additionalProperties": true
}
},
"output": {
"successSchema": {
"type": "object",
"properties": {
"participantCount": {
"type": "integer"
}
},
"additionalProperties": true
}
}
},
"secure": false
}
------------------------------
Philip Penn
------------------------------
Original Message:
Sent: 11-28-2022 10:09
From: Philip Penn
Subject: Data Action - Count Iteam is a Array Filtered from a Json Response
Hi Gerardo.
Thanks for your response.
I have attempted this
Contact Json
Input
{
"type": "object",
"properties": {},
"additionalProperties": true
}
Output
{
"type": "object",
"properties": {
"participantCount": {
"type": "integer"
}
},
"additionalProperties": true
}
TranslationMap
{
"translationMap": {
"participantCount": "$.participants[?(@.purpose == 'agent')].purpose.size()"
},
"translationMapDefaults": {},
"successTemplate": "{\n\"participantCount\": ${participantCount}\n}"
}
But I get this response
{ "message": "JSON failed schema validation for the following reasons: Schema: # @/properties/participantCount. Error location: /participantCount. instance type (array) does not match any allowed primitive type (allowed: [\"integer\"])", "code": "invalid.schema", "status": 400, "messageParams": {}, "contextId": "6854452a-2dcb-48ee-98e1-908330282412", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": []}
Do you know what I am doing wrong?
------------------------------
Philip Penn
Original Message:
Sent: 11-28-2022 03:30
From: Gerardo Rodríguez
Subject: Data Action - Count Iteam is a Array Filtered from a Json Response
Hi Philip,
If you just need number of items, for translation map try to use:
$.participants[?(@.purpose == 'agent')].purpose.size()
Contract value for output must be an integer type.
regards
------------------------------
Gerardo Rodríguez
Evolutio Cloud Enabler, S.A.
Original Message:
Sent: 11-26-2022 07:17
From: Philip Penn
Subject: Data Action - Count Iteam is a Array Filtered from a Json Response
Afternnon All,
I am after some help.
I would like to determine from the following API if a Customer has spoken to more than one advisor:
API: /api/v2/conversations/${input.conversationId}
I would like to filter the results using the following in the translation map
$.participants[?(@.purpose == 'agent')].purpose
And count the items in the array, which would have one or many items.
[
"agent",
"agent"
]
I would like to return an integer on the output contract.
Any advice would be apprecaited.
#Unsure/Other
------------------------------
Philip Penn
------------------------------