Speech and Text Analytics to API Data Action

I feel so close but yet so far away and just can't figure this out. I've created a data action using the
/api/v2/speechandtextanalytics/conversations/{conversationId} API. It looks like the input and outputs are formed correctly, but keep getting an error. My goal is to return the sentiment of the conversation and route based on if the conversation is a negative score, coming from a digital bot flow. Below is the error and json. What am I missing??

ERROR: Apply output transformation: Transform failed to process result using 'successTemplate' template due to error:'Unexpected character ('S' (code 83)): was expecting comma to separate Object entries at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 107]' Template:'{ "sentimentScore": ${sentimentScore}, "sentimentTrend": ${sentimentTrend}, "sentimentTrendClass": "${sentimentTrendClass}" }'.

{
"name": "Get Conversation Analytics",
"description": "Retrieves analytics data for a given conversation ID",
"secure": false,
"requestType": "HTTP",
"requestTemplate": "https://api.usw2.pure.cloud/api/v2/speechandtextanalytics/conversations/${input.conversationID}",
"requestUrlTemplate": "${requestTemplate}",
"integrationType": "purecloud-data-actions",
"actionType": "REQUEST",
"config": {
"request": {
"template": "https://api.usw2.pure.cloud/api/v2/speechandtextanalytics/conversations/${input.conversationID}",
"method": "GET",
}
},
"response": {
"translationMap": {
"conversationId": "$.conversation.id",
"sentimentScore": "$.sentimentScore",
"sentimentTrend": "$.sentimentTrend",
"sentimentTrendClass": "$.sentimentTrendClass"
},
"successTemplate": "{ "conversationId": "${conversationId}", "sentimentScore": ${sentimentScore}, "sentimentTrend": ${sentimentTrend}, "sentimentTrendClass": "${sentimentTrendClass}" }"
}
},
"contract": {
"input": {
"inputSchema": {
"type": "object",
"properties": {
"conversationID": {
"type": "string",
"description": "The ID of the conversation to retrieve analytics for"
}
},
"required": [
"conversationID"
]
}
},
"output": {
"successSchema": {
"type": "object",
"properties": {
"conversationId": {
"type": "string",
"description": "The ID of the conversation"
},
"sentimentScore": {
"type": "number",
"format": "double",
"description": "The sentiment score of the conversation"
},
"sentimentTrend": {
"type": "number",
"format": "double",
"description": "The sentiment trend of the conversation"
},
"sentimentTrendClass": {
"type": "string",
"description": "The sentiment trend classification"
}
}
}
}
}
}

I've gotten a little further but experiencing another issue now. When I test it, I see that it displays the information from the conversation in the execute portion, but does not in the output:

{
"conversation": {
"id": "69a6b722-3bb5-4f6c-a50e-a6ad6672a856",
"selfUri": "/api/v2/conversations/69a6b722-3bb5-4f6c-a50e-a6ad6672a856"
},
"sentimentScore": -0.9288576214547277,
"sentimentTrend": 0.1558285302294905,
"sentimentTrendClass": "NoChange",
"empathyScores": []
}

But, when I check the translation map, it looks like it automatically defaults to the translationMapDefaults. Here is the full json:

{
"name": "Get Conversation Sentiment",
"integrationType": "purecloud-data-actions",
"actionType": "custom",
"config": {
"request": {
"requestUrlTemplate": "/api/v2/speechandtextanalytics/conversations/${input.conversationId}",
"requestType": "GET",
"headers": {
"Content-Type": "application/json",
"UserAgent": "PureCloudIntegrations/1.0"
},
"requestTemplate": "{}"
},
"response": {
"translationMap": {
"conversationId": "${conversationId}",
"sentimentScore": "${sentimentScore}",
"sentimentTrend": "${sentimentTrend}",
"sentimentTrendClass": "${sentimentTrendClass}"
},
"translationMapDefaults": {
"conversationId": "UNKNOWN",
"sentimentScore": "0",
"sentimentTrend": "0",
"sentimentTrendClass": "UNKNOWN"
},
"successTemplate": "{\n "conversationId": "${conversationId}",\n "sentimentScore": ${sentimentScore},\n "sentimentTrend": ${sentimentTrend},\n "sentimentTrendClass": "${sentimentTrendClass}"\n}"
}
},
"contract": {
"input": {
"inputSchema": {
"title": "",
"type": "object",
"required": [
"conversationId"
],
"properties": {
"conversationId": {
"type": "string",
"description": "The unique ID of the conversation for which speech and text analytics are requested."
}
}
}
},
"output": {
"successSchema": {
"title": "",
"type": "object",
"properties": {
"conversationId": {
"type": "string",
"description": "The unique ID of the conversation."
},
"sentimentScore": {
"type": "number",
"description": "The overall sentiment score of the conversation."
},
"sentimentTrend": {
"type": "number",
"description": "The sentiment trend throughout the conversation."
},
"sentimentTrendClass": {
"type": "string",
"description": "A human-readable classification of the sentiment trend."
}
}
}
}
},
"secure": false
}

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