tAbandon metric in data action

Hello guys,

I want to obtain the metric tAbandon for a interaction using data action and I am stuck. Can you please enlighten me cause no matter what I use as output contract, I never get it to work.

Input Contracts:

{
"title": "input",
"type": "object",
"properties": {
"ConversationID": {
"type": "string"
}
},
"additionalProperties": true
}

Output contracts:
{
"title": "output",
"type": "object",
"properties": {
"tAbandon": {
"type": "number"
}
},
"additionalProperties": true
}

Request:

{
"requestUrlTemplate": "/api/v2/analytics/conversations/details?${input.ConversationID}",
"requestType": "GET",
"headers": {
"content-type": "application/json"
},
"requestTemplate": "${input.rawRequest}"
}

Response:
{
"translationMap": {
"tAbandon": "$.conversations[0].participants[?(@.purpose == 'acd')].sessions[0].metrics[?(@.name == 'tAbandon')].value"
},
"translationMapDefaults": {
"tAbandon": ""Not Found""
},
"successTemplate": "{"tAbandon": ${tAbandon}}"
}

I get the below error:

{
"message": "JSON failed output schema validation for the following reasons: Schema: # @/properties/tAbandon. Error location: /tAbandon. instance type (array) does not match any allowed primitive type (allowed: ["integer","number"])",
"code": "invalid.schema",
"status": 400,
"messageParams": {},
"contextId": "89cffdd8-a5e8-441d-961e-5f53ac126d91",
"details": [
{
"errorCode": "ACTION.PROCESSING"
}
],
"errors": []
}

Hi Charis,

The action is failing because the schema is expecting tAbandon to be a single number, however it is actually an array of values due to the type of JSONPath you have. If there is only ever one value you can use firstFromArray to pull that value out:

If there could be more than one value then you might want to change your output schema to be an array of numbers.

--Jason

Hi Jason,

Thanks for your reply. Could you please elaborate further? I cannot understand how the output contract structure should be set.

What I am trying to accomplish, is to obtain the waiting time of an interaction until it gets abandoned. Any help would be highly appreciated.

Regards,
Charis

If having multiple values makes sense, then your output contract should have an array with the value inside of the array being of type "number".

If there should really only be one usable number then you can leave your output contract alone and wrap the
${tAbandon}
with the irstFromArray macro that is in the documentation that I linked to.

--Jason

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