aditi.o.agarwal | 2022-09-20 10:18:20 UTC | #1
Hi,
I have hit a blocker and need some break through please. I am trying to create a PureCloud Data action to query out Email conversationIds, Email Subject for current day from a specific FromAddress.
Request URL Template: /api/v2/analytics/conversations/details/query Request Body Template: { "interval": "${input.iCurrentDate}", "order": "asc", "orderBy": "conversationStart", "paging": { "pageSize": 100, "pageNumber": 1 }, "segmentFilters": [ { "type": "or", "predicates": [ { "type": "dimension", "dimension": "mediaType", "operator": "matches", "value": "email" }, { "type": "dimension", "dimension": "addressFrom", "operator": "matches", "value": "${input.iFromAddress}" } ] } ] }
Response: { "translationMap": { "conversationIDValue":"$.conversations[].conversationId", "subjectValue":"$.participants[].subject" }, "translationMapDefaults": {}, "successTemplate": "#set($default = \"No-Data\") {\r\n \"oEmailSubject\": ${successTemplateUtils.firstFromArray(\"${subjectValue}\", \"$esc.quote$default$esc.quote\")}, \"oConversationId\": ${successTemplateUtils.firstFromArray(\"${conversationIDValue}\", \"$esc.quote$default$esc.quote\")} \r\n}" }
Output Error:
{ "message": "Failed while processing the translation map. Could not resolve value for the key: 'subjectValue' and no default value was configured. Additional details: Missing property in path $['participants']", "code": "bad.request", "status": 400, "messageParams": {}, "contextId": "1b80ca1a-ac7b-4f0e-ba86-643d213f555f", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }
Thanks.
aditi.o.agarwal | 2022-09-20 10:59:25 UTC | #2
Hi,
Just an update: I have i think made a progress and wanted to keep this thread up-to-date. Can anyone verify and confirm if it is the right way? And how do i then pull all the records instead of just pulling the 'firstfromarray'.
Response: { "translationMap": { "conversationValue":"$.conversations[].conversationId", "subjectValue":"$.conversations[].participants[].sessions[].segments[*].subject" }, "translationMapDefaults": {}, "successTemplate": "{\r\n \"oEmailSubject\": ${successTemplateUtils.firstFromArray(\"${subjectValue}\", \"$esc.quote$default$esc.quote\")}, \"oConversationID\": ${successTemplateUtils.firstFromArray(\"${conversationValue}\", \"$esc.quote$default$esc.quote\")} \r\n}" }
this executed for couple of times successfully, but without any changes it has started to throw the below error - { "message": "Failed while processing the translation map. Could not resolve value for the key: 'conversationValue' and no default value was configured. Additional details: Missing property in path $['conversations']", "code": "bad.request", "status": 400, "messageParams": {}, "contextId": "5bec17c9-eacc-4d05-9515-8f5c1e5192b2", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }
Jason_Mathison | 2022-09-20 12:57:18 UTC | #3
Hi Aditi,
For the issue of now getting errors, is it possible that there are no active conversations, so there is no conversations section in the response?
As to your overall question, could you provide an example of the analytics response you are getting (with anything sensitive replaced with a non-sensitive replacement), and an example of what you want the final output to look like?
--Jason
aditi.o.agarwal | 2022-09-20 17:03:35 UTC | #4
Many thanks for your response Jason! :slight_smile:
Request URL Template: /api/v2/analytics/conversations/details/query Request Body Template:
{ "interval": "${input.iCurrentDate}", "order": "asc", "orderBy": "conversationStart", "segmentFilters": [{ "type": "and", "predicates": [{ "type": "dimension", "dimension": "mediaType", "operator": "matches", "value": "email" }, { "type": "dimension", "dimension": "addressFrom", "operator": "matches", "value": "${input.iFromAddress}" } ] }] }
Response:
{ "translationMap": { "conversationIDValue": "$.conversations[].conversationId", "subjectValue": "$.conversations[].participants[].sessions[].segments[*].subject" }, "translationMapDefaults": {}, "successTemplate": "#set($default = \"No-Data\") {\r\n \"oEmailSubject\": ${successTemplateUtils.firstFromArray(\"${subjectValue}\", \"$esc.quote$default$esc.quote\")}, \"oConversationID\": ${successTemplateUtils.firstFromArray(\"${conversationIDValue}\", \"$esc.quote$default$esc.quote\")} \r\n}" }
Error Code:
{ "message": "Failed while processing the translation map. Could not resolve value for the key: 'conversationIDValue' and no default value was configured. Additional details: Missing property in path $['conversations']", "code": "bad.request", "status": 400, "messageParams": {}, "contextId": "12f7779b-c4d5-4680-9581-9e62c80bb71c", "details": [{ "errorCode": "ACTION.PROCESSING" }], "errors": [] }
End Goal: to fetch all the email conversations with their respective email subjects for a given FromAddress for current day. This data will then be used to scan the new incoming interactions to check whether its a duplicate email or not. And if the new conversationID has a similar email sent by same customer (FromAddress) then I plan to terminate the new interaction. This will avoid to be routed to agent and will avoid duplications.
The API Response looks like this from API
{ "conversations": [{ "conversationEnd": "2022-09-20T11:29:52.255Z", "conversationId": "07d43eca-c428-4587-b928-c6d233c06a19", "conversationStart": "2022-09-20T11:29:51.100Z", "divisionIds": [ "3c67bf69-7deb-413a-aabd-cc01257a5bb5" ], "originatingDirection": "inbound", "participants": [{ "participantId": "d6103067-d530-49f5-968c-aea3912ce6fd", "participantName": "Thadukamadla, Vani", "purpose": "external", "sessions": [{ "addressFrom": "vani.thadukamadla@x.com", "addressOther": "Test@xxx", "addressSelf": "vani.thadukamadla@x.com", "addressTo": "Test@xxx", "direction": "inbound", "mediaType": "email", "peerId": "98b49f1c-4c43-46c1-8362-036a9fc4ba67", "provider": "PureCloud Email", "sessionId": "b0afb87f-19f5-4f73-aa65-dbff655f037b", "metrics": [{ "emitDate": "2022-09-20T11:29:51.100Z", "name": "nConnected", "value": 1 }, { "emitDate": "2022-09-20T11:29:52.255Z", "name": "tConnected", "value": 1155 } ], "segments": [{ "conference": false, "disconnectType": "peer", "segmentEnd": "2022-09-20T11:29:52.255Z", "segmentStart": "2022-09-20T11:29:51.100Z", "segmentType": "interact", "subject": "Upgrade" }] }] }, { "participantId": "c500331e-04f7-4472-833e-d25e124b9fc0", "purpose": "workflow", "sessions": [{ "addressFrom": "vani.thadukamadla@x.com", "addressOther": "vani.thadukamadla@x.com", "addressSelf": "Test@xxx", "addressTo": "Test@xxx", "direction": "inbound", "mediaType": "email", "peerId": "b0afb87f-19f5-4f73-aa65-dbff655f037b", "provider": "PureCloud Email", "remote": "Thadukamadla, Vani", "sessionId": "98b49f1c-4c43-46c1-8362-036a9fc4ba67", "flow": { "endingLanguage": "en-us", "entryReason": "Test@xxx", "entryType": "direct", "exitReason": "FLOWDISCONNECT", "flowId": "c2aa7200-4a7f-4c25-8272-bba383da442d", "flowName": "DuplicateEmailHandling", "flowType": "INBOUNDEMAIL", "flowVersion": "2.0", "startingLanguage": "en-us" }, "metrics": [{ "emitDate": "2022-09-20T11:29:51.107Z", "name": "nFlow", "value": 1 }, { "emitDate": "2022-09-20T11:29:52.241Z", "name": "tFlow", "value": 1134 }, { "emitDate": "2022-09-20T11:29:52.241Z", "name": "tFlowDisconnect", "value": 1134 } ], "segments": [{ "conference": false, "disconnectType": "client", "segmentEnd": "2022-09-20T11:29:52.241Z", "segmentStart": "2022-09-20T11:29:51.107Z", "segmentType": "interact", "subject": "Upgrade" }] }] } ] }, { "conversationEnd": "2022-09-20T11:42:10.464Z", "conversationId": "a84e26fe-4c03-4c2b-a495-5bd1651cfdd8", "conversationStart": "2022-09-20T11:42:09.186Z", "divisionIds": [ "3c67bf69-7deb-413a-aabd-cc01257a5bb5" ], "originatingDirection": "inbound", "participants": [{ "participantId": "8cac38a6-c757-4aa4-946b-149b72df4a64", "participantName": "Thadukamadla, Vani", "purpose": "external", "sessions": [{ "addressFrom": "vani.thadukamadla@x.com", "addressOther": "Test@xxxx", "addressSelf": "vani.thadukamadla@x.com", "addressTo": "Test@xxx", "direction": "inbound", "mediaType": "email", "peerId": "a3dffa6b-2fe6-4e30-ac0e-0aa07651836a", "provider": "PureCloud Email", "sessionId": "30f95818-614a-443c-8591-c8de6347f4fe", "metrics": [{ "emitDate": "2022-09-20T11:42:09.186Z", "name": "nConnected", "value": 1 }, { "emitDate": "2022-09-20T11:42:10.464Z", "name": "tConnected", "value": 1278 } ], "segments": [{ "conference": false, "disconnectType": "peer", "segmentEnd": "2022-09-20T11:42:10.464Z", "segmentStart": "2022-09-20T11:42:09.186Z", "segmentType": "interact", "subject": "TEST email" }] }] }, { "participantId": "a8a3093d-b0d9-41bd-aa6f-b61d7167c4f8", "purpose": "workflow", "sessions": [{ "addressFrom": "vani.thadukamadla@x.com", "addressOther": "vani.thadukamadla@x.com", "addressSelf": "Test@xxx", "addressTo": "Test@xxx", "direction": "inbound", "mediaType": "email", "peerId": "30f95818-614a-443c-8591-c8de6347f4fe", "provider": "PureCloud Email", "remote": "Thadukamadla, Vani", "sessionId": "a3dffa6b-2fe6-4e30-ac0e-0aa07651836a", "flow": { "endingLanguage": "en-us", "entryReason": "Test@xxx", "entryType": "direct", "exitReason": "FLOWDISCONNECT", "flowId": "c2aa7200-4a7f-4c25-8272-bba383da442d", "flowName": "DuplicateEmailHandling", "flowType": "INBOUNDEMAIL", "flowVersion": "3.0", "startingLanguage": "en-us" }, "metrics": [{ "emitDate": "2022-09-20T11:42:09.193Z", "name": "nFlow", "value": 1 }, { "emitDate": "2022-09-20T11:42:10.447Z", "name": "tFlow", "value": 1254 }, { "emitDate": "2022-09-20T11:42:10.447Z", "name": "tFlowDisconnect", "value": 1254 } ], "segments": [{ "conference": false, "disconnectType": "client", "segmentEnd": "2022-09-20T11:42:10.447Z", "segmentStart": "2022-09-20T11:42:09.193Z", "segmentType": "interact", "subject": "TEST email" }] }] } ] } ], "totalHits": 2 }
Jason_Mathison | 2022-09-20 18:11:55 UTC | #5
Thank you for the additional information.
I setup an endpoint to return your example response from analytics, copied your response configuration and got a reasonable looking response. Is it possible that when you are getting errors that the analytics endpoint doesn't have any conversations to return?
In terms of returning multiple results, you can setup your output contract to have an array of strings, and then have your response template return a list. For example I updated the oEmailSubject to return the list of results:
"successTemplate": "#set($default = \"No-Data\") {\r\n \"oEmailSubject\": ${subjectValue}, \"oConversationID\": ${successTemplateUtils.firstFromArray(\"${conversationIDValue}\", \"$esc.quote$default$esc.quote\")} \r\n}"
Architect (for example) could then go through the list of email subjects.
--Jason
aditi.o.agarwal | 2022-09-21 08:58:48 UTC | #6
Thanks for your quick response and validation Jason! :) much appreciated. Could you share on how you set it up please? maybe few screenshots?
I dont understand what is going wrong with the way i am running the data action test. I have 2 email conversations that needs to be fetched via Data Actions. (This is valid as the output is returned through the API request-reponse via API Developer. Also, had shared earlier)
Further to drill down -
If i use OR operator under - "type": "or" - i am getting an output but not the desired one. But, if i use "type": "and" - I get the below error. Not able to progress unfortunately.
{ "message": "Failed while processing the translation map. Could not resolve value for the key: 'conversationIDValue' and no default value was configured. Additional details: Missing property in path $['conversations']", "code": "bad.request", "status": 400, "messageParams": {}, "contextId": "f7626e0e-1cef-4f1b-bb64-2904283bebc5", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }
Jason_Mathison | 2022-09-21 12:52:46 UTC | #7
I personally use https://mockable.io to mock up responses. I would guess that there are many similar sites. It takes me less than a minute to setup an endpoint to return whatever response that I want. In this case I copied and pasted the analytics output that you provided, and then used the mockable.io address as a custom data action URL template.
When you are having the 400 response that you reported in your most recent post, what is the "execution" step showing as the output?
--Jason
aditi.o.agarwal | 2022-09-21 14:30:31 UTC | #8
Any idea why this is happening please? and what is the error message please?
If i use OR operator under - "type": "or" - i am getting an output but not the desired one. But, if i use "type": "and" - I get the below error. Not able to progress unfortunately.
{ "message": "Failed while processing the translation map. Could not resolve value for the key: 'conversationIDValue' and no default value was configured. Additional details: Missing property in path $['conversations']", "code": "bad.request", "status": 400, "messageParams": {}, "contextId": "f7626e0e-1cef-4f1b-bb64-2904283bebc5", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }
ChrisDibble | 2022-09-21 15:44:46 UTC | #9
Aditi,
Based on your query and error code, it looks like there are no emails in the interval specified that match the email address supplied. The data action is returning an error because it's unable to find any data in the response from the analytics endpoint at the path you defined in your success template.
If you expect that there should be data being returned from the analytics endpoint, verify in the test step output that the Resolve request body template step resolved to the payload that you expect and verify that you get results using postman to hit the same endpoint and using that resolved payload.
When the translation map doesn't find any data you can either let the action succeed using default values, or you can let it fail if there is no suitable fallback value. If you want to use fallback values, you can define entries in the translationMapDefaults config that should be used as a fallback when the normal translationMap fails. Try configuring something like this
aditi.o.agarwal, post:4, topic:16359
"translationMap": {
"conversationIDValue": "$.conversations[*].conversationId",
"subjectValue": "$.conversations[*].participants[*].sessions[*].segments[*].subject"
},
"translationMapDefaults": {
"conversationIDValue":"none",
"subjectValue":"none"
}
With that configuration, the two translationMap variables will both be set to none when there is no data present.
Let us know if these ideas resolve the blocker.
-Chris
aditi.o.agarwal | 2022-10-14 11:31:11 UTC | #10
thanks ChrisDibble. Your response is appreciated.
I have been trying to get this sorted all through the time with various combinations. But, it just doesnt seem to work.
I am getting the output when executing the same on postman or Developer tools using the same request and API. :unamused:
Jason_Mathison | 2022-10-14 14:14:22 UTC | #11
A couple of troubleshooting steps that I have taken are:
- Play the input to the data action as audio in the IVR. That way I can hear if I have an unexpected input value.
- Copy your action into a web service data action, and configure it to hit a site like the postman echo route or mockable.io so that you can see the exact request that you are making to the endpoint.
It is pretty common for some of the input in the IVR to not match what you expected, and cause you trouble.
--Jason
aditi.o.agarwal | 2022-10-17 06:03:56 UTC | #12
Hi Jason,
Thanks for your tips/tricks.
I found the issue. It was the issue with OAuth client as it did not have permissions to all the divisions which has the result. That was real trick!
However, i am able to get the relevant hits but, the translation map fails. Can you please confirm if the translation map is well constructed?
Translation Map: { "translationMap": { "conversationIDValue": "$.conversations[].conversationId", "subjectValue": "$.conversations[].participants[].sessions[].segments[*].subject" }, "translationMapDefaults": { "conversationIDValue": "none", "subjectValue": "none" }, "successTemplate": "#set($default = \"NoData\") {\r\n \"oEmailSubject\": ${successTemplateUtils.firstFromArray(\"${subjectValue}\", \"$esc.quote$default$esc.quote\")}, \"oConversationID\": ${successTemplateUtils.firstFromArray(\"${conversationIDValue}\", \"$esc.quote$default$esc.quote\")} \r\n}" }
Output:
{ "message": "JSON failed schema validation for the following reasons: Schema: # @/properties/oConversationID. Error location: /oConversationID. instance type (string) does not match any allowed primitive type (allowed: [\"array\"]),\nSchema: # @/properties/oEmailSubject. Error location: /oEmailSubject. instance type (string) does not match any allowed primitive type (allowed: [\"array\"])", "code": "invalid.schema", "status": 400, "messageParams": {}, "contextId": "90769fb9-b500-4a8e-83b7-2a98cad024a9", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }
Many thanks again for your valuable inputs, everyone!
Jason_Mathison | 2022-11-02 14:32:25 UTC | #13
Sorry for the slow response, I lost track of this thread. Were you able to resolve the error that you were getting?
system | 2022-12-03 14:32:45 UTC | #14
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 16359