Zack_Pemberton | 2021-03-03 23:08:27 UTC | #1
I am building a data action using /api/v2/conversations/chats/${input.conversationID} and I'm attempting to pull out some attributes passed through when a user chats.
Example output:
{ "id": "d1a3c22d-0c1d-4dc8-a03c-xxxxxx", "participants": [ { "id": "53ea7a34-2f46-46d0-aa6e-eaxxxxxx", "name": "xxxx", "startTime": "2021-03-03T20:42:08.906Z", "connectedTime": "2021-03-03T20:42:08.922Z", "endTime": "2021-03-03T20:51:53.565Z", "purpose": "customer", "state": "disconnected", "disconnectType": "client", "held": false, "wrapupRequired": false, "queue": { "id": "74f56edb-aa6a-4335-ad35xxxxxx", "selfUri": "/api/v2/routing/queues/74f56edb-aa6a-4335-ad35-17xxxxx" }, "attributes": { "context.firstName": "Sxxxx", "context.genesysOS": "ChromeOS", "context.lastName": "", "context.genesysbrowser": "Chrome",
I can pull things from the main participant list with no issues, such as endTime, startTime, etc. The issue I have is once I get into the attributes portion, I'm getting bad request errors.
My Response:
{ "translationMap": { "filter1": "$.participants[0].endTime", "filter2": "$.participants[0].attributes[0].context.firstName" }, "translationMapDefaults": {}, "successTemplate": "{\r\n\"Time Ended\": ${filter1}\r\n,\r\n\"First Name\": ${filter2}\r\n" }
Output Contract:
{ "type": "object", "properties": { "Time Ended": { "type": "string" }, "First Name": { "type": "string" } }, "additionalProperties": true }
Error Response:
{ "message": "Failed while processing the translation map. Could not resolve value for the key: 'filter2' and no default value was configured. Additional details: Filter: [0]['context']['firstName'] can only be applied to arrays. Current context is: {context.firstName=Sxxxx, context.genesysOS=ChromeOS, context.lastName=, context.genesysbrowser=Chrome, context.genesysreferrer=https://www.url.com, context.genesysurl=url.com, context.genesyssource=web, context.genesyspageTitle=urlpage, context.genesys.legacyRoutingTargetQueueAddress=our Chat}", "code": "bad.request", "status": 400, "messageParams": {}, "contextId": "28b595d9-b4b9-4xxxxxxx", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }
Jerome.Saint-Marc | 2021-03-04 12:48:09 UTC | #2
Hello,
Here is a Response configuration which will work (to access the context.firstName attribute). I also added a missing } in the successTemplate. And added a default value (empty string) for filter2, in case the context.firstName attribute is not present.
{ "translationMap": { "filter1": "$.participants[0].endTime", "filter2": "$.participants[0].attributes['context.firstName']" }, "translationMapDefaults": { "filter2": "\"\"" }, "successTemplate": "{\n \"Time Ended\": ${filter1},\n \"First Name\": ${filter2} \n}" }
This would work as well (using \\" instead of '):
{ "translationMap": { "filter1": "$.participants[0].endTime", "filter2": "$.participants[0].attributes[\"context.firstName\"]" }, "translationMapDefaults": { "filter2": "\"\"" }, "successTemplate": "{\n \"Time Ended\": ${filter1},\n \"First Name\": ${filter2} \n}" }
It is not mandatory - but I would recommend to use output contract parameters without spaces. I mean TimeEnded and FirstName.
Regards,
Edit: As an additional comment If you are trying to retrieve participant attributes on the active chat conversation (I mean the one from which you make this Data Action request)
- In an Architect flow, you can retrieve participant attributes with Get Participant Data block and using context.firstName
- In a Script, you can define a variable with name: "firstName" and with the Input toggle enabled. Script will read from the participant attributes (and will automatically add "context." internally as it is a chat)
Zack_Pemberton | 2021-03-04 12:48:46 UTC | #3
Works perfectly! Thanks Jerome! My biggest issue was figuring out the .attributes['context.firstName']" portion of the call. Thanks again for all of your help!
system | 2021-04-04 12:48:50 UTC | #4
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: 10164