agilio | 2020-06-25 13:37:24 UTC | #1
I'm setting participate data via a flow. Depending if the call was inbound or outbound the participant index could change. I'm trying to retrieve that value using a data action in a script. Is there a Velocity method or macro that will allow me to find the first item in an array that has a value. Meaning it's not empty. For Example I would want to return 2 but I have know idea that it's in the second position of the array. ["",2,""]
Jason_Mathison | 2020-06-26 11:39:24 UTC | #2
Hi agilio,
Could provide a (redacted if needed) example of the output you are working with? I am not sure yet whether JSONPath or Velocity can get you what you need, but it is a lot easier to experiment with an example. Architect can go through a list and pull the real value out, but it would be nice to not have to add a bunch of stuff to your flows.
--Jason
agilio | 2020-06-26 13:31:56 UTC | #3
Here is an example from the api/v2/conversations/{conversationId} API
In this example the return_value attribute is on the first participant. This is because it was an inbound call. In other examples it could be on the third participate if it's an outbound call. Nevertheless the Data action needs to return the value as a single item and not as an array. The reason for this is the data action will be called from a script and we don't have the tools we have in architect to find the value in a collection of items.
So the Goal is to call this DataAction Pass in the conversationID and have it return the single value so we can update the script page after the caller returns from the IVR.
{ "id": "ConverstationGUID", "startTime": "2020-06-17T02:03:38.819Z", "endTime": "2020-06-17T02:05:25.558Z", "address": "tel:+1XXXXXXXXXXX", "participants": [ { "id": "020acf2d-62b7-46ed-82d0-40dbf05c42e7", "startTime": "2020-06-17T02:03:38.819Z", "endTime": "2020-06-17T02:05:25.541Z", "connectedTime": "2020-06-17T02:03:38.890Z", "name": "SADTown", "purpose": "external", "participantType": "External", "address": "tel:+1XXXXXXXXXXX", "ani": "tel:+1XXXXXXXXXXX", "aniName": "SADTown", "dnis": "tel:+1XXXXXXXXXXX", "wrapupRequired": false, "attributes": { "return_value": "XX"" }, "calls": [ { "state": "terminated", "id": "361824b6-e81b-48fa-a66e-d45484ca3e1a", "direction": "inbound", "recording": false, "recordingState": "none", "muted": false, "confined": false, "held": false, "segments": [ { "startTime": "2020-06-17T02:03:38.822Z", "endTime": "2020-06-17T02:03:38.890Z", "type": "System", "howEnded": "Interact" }, { "startTime": "2020-06-17T02:03:38.890Z", "endTime": "2020-06-17T02:05:25.541Z", "type": "Interact", "howEnded": "Disconnect", "disconnectType": "endpoint" } ], "disconnectType": "endpoint", "connectedTime": "2020-06-17T02:03:38.890Z", "disconnectedTime": "2020-06-17T02:05:25.541Z", "disconnectReasons": [], "provider": "Edge", "self": { "name": "SADTown", "nameRaw": "", "addressNormalized": "tel:+1XXXXXXXXXXX", "addressRaw": "sip:+1XXXXXXXXXXX@, "addressDisplayable": "unavailable" }, "other": { "name": "xxxxZ", "nameRaw": "", "addressNormalized": "tel:+1XXXXXXXXXXX", "addressRaw": "sip:+1XXXXXXXXXXX@x.xx.xxx.xxx:5060;user=phone;transport=tcp", "addressDisplayable": "unavailable" } } ], "callbacks": [], "chats": [], "cobrowsesessions": [], "emails": [], "messages": [], "screenshares": [], "socialExpressions": [], "videos": [] }, { "id": "2c3e56d9-5d6c-4ff7-834a-665c989e7c46", "startTime": "2020-06-17T02:03:38.838Z", "endTime": "2020-06-17T02:03:39.805Z", "connectedTime": "2020-06-17T02:03:38.846Z", "name": "Happy Town", "purpose": "ivr", "participantType": "IVR", "address": "sip:fc72a806-2a17-4a9b-9554-652fa4c94422@127.0.0.1;language=en-US;user=ivr", "ani": "tel:+1XXXXXXXXXXX", "aniName": "SADTown", "dnis": "sip:fc72a806-2a17-4a9b-9554-652fa4c94422@127.0.0.1;language=en-US;user=ivr", "wrapupRequired": false, "attributes": {}, "calls": [ { "state": "terminated", "id": "1d4df597-cfcd-49ce-a0e0-26fdcdb9875d", "direction": "inbound", "recording": false, "recordingState": "none", "muted": false, "confined": false, "held": false, "segments": [ { "startTime": "2020-06-17T02:03:38.838Z", "endTime": "2020-06-17T02:03:38.846Z", "type": "System" }, { "startTime": "2020-06-17T02:03:38.846Z", "endTime": "2020-06-17T02:03:39.805Z", "type": "IVR", "howEnded": "Disconnect", "disconnectType": "peer" } ], "disconnectType": "peer", "connectedTime": "2020-06-17T02:03:38.846Z", "disconnectedTime": "2020-06-17T02:03:39.805Z", "disconnectReasons": [], "provider": "Edge", "peerId": "361824b6-e81b-48fa-a66e-d45484ca3e1a", "uuiData": "XXXXX-XXXXX|1538.60|20200616|ENG|100135967420200617", "self": { "name": "Happy Town", "nameRaw": "Happy Town", "addressNormalized": "sip:fc72a806-2a17-4a9b-9554-652fa4c94422@127.0.0.1;language=en-US;user=ivr", "addressRaw": "sip:fc72a806-2a17-4a9b-9554-652fa4c94422@127.0.0.1;language=en-US;user=ivr", "addressDisplayable": "unavailable" }, "other": { "name": "SADTown", "nameRaw": "SADTown", "addressNormalized": "tel:+1XXXXXXXXXXX", "addressRaw": "sip:+1XXXXXXXXXXX@10.42.92.238;user=phone", "addressDisplayable": "unavailable" } } ], "callbacks": [], "chats": [], "cobrowsesessions": [], "emails": [], "messages": [], "screenshares": [], "socialExpressions": [], "videos": [] }, { "id": "00214c29-15c2-4473-be98-df1f2cded79e", "startTime": "2020-06-17T02:03:39.782Z", "endTime": "2020-06-17T02:05:25.557Z", "connectedTime": "2020-06-17T02:03:39.799Z", "name": "9a2a2df4-03cc-44b9-8f35-440246753b7d", "purpose": "ivr", "participantType": "IVR", "address": "sip:6a72f779-e294-4c65-9e66-9f2e1bdf1348@127.0.0.1;language=en-US;user=ivr", "ani": "sip:anonymous@anonymous.invalid", "aniName": "anonymous", "dnis": "sip:6a72f779-e294-4c65-9e66-9f2e1bdf1348@127.0.0.1;language=en-US;user=ivr", "wrapupRequired": false, "attributes": {}, "calls": [ { "state": "terminated", "id": "92275610-ae09-4674-a186-332ae5ac65c1", "direction": "inbound", "recording": false, "recordingState": "none", "muted": false, "confined": false, "held": false, "segments": [ { "startTime": "2020-06-17T02:03:39.783Z", "endTime": "2020-06-17T02:03:39.799Z", "type": "System" }, { "startTime": "2020-06-17T02:03:39.799Z", "endTime": "2020-06-17T02:05:25.557Z", "type": "IVR", "howEnded": "Disconnect", "disconnectType": "peer" } ], "disconnectType": "peer", "connectedTime": "2020-06-17T02:03:39.799Z", "disconnectedTime": "2020-06-17T02:05:25.557Z", "disconnectReasons": [], "provider": "Edge", "peerId": "361824b6-e81b-48fa-a66e-d45484ca3e1a", "self": { "name": "9a2a2df4-03cc-44b9-8f35-440246753b7d", "nameRaw": "9a2a2df4-03cc-44b9-8f35-440246753b7d", "addressNormalized": "sip:6a72f779-e294-4c65-9e66-9f2e1bdf1348@127.0.0.1;language=en-US;user=ivr", "addressRaw": "sip:6a72f779-e294-4c65-9e66-9f2e1bdf1348@127.0.0.1;language=en-US;user=ivr", "addressDisplayable": "unavailable" }, "other": { "name": "anonymous", "nameRaw": "anonymous", "addressNormalized": "sip:anonymous@anonymous.invalid", "addressRaw": "sip:anonymous@anonymous.invalid", "addressDisplayable": "unavailable" } } ], "callbacks": [], "chats": [], "cobrowsesessions": [], "emails": [], "messages": [], "screenshares": [], "socialExpressions": [], "videos": [] } ], "recordingState": "NONE", "divisions": [ { "division": { "id": "2bb47912-4ae3-4668-b2f4-bffff349c20b", "selfUri": "/api/v2/authorization/divisions/2bb47912-4ae3-4668-b2f4-bffff349c20b" }, "entities": [ { "id": "2d4e8aff-bfb1-415c-8a7b-80bd8808145e", "selfUri": "/api/v2/flows/2d4e8aff-bfb1-415c-8a7b-80bd8808145e" }, { "id": "9a2a2df4-03cc-44b9-8f35-440246753b7d", "selfUri": "/api/v2/flows/9a2a2df4-03cc-44b9-8f35-440246753b7d" } ] } ], "selfUri": "/api/v2/conversations/ConversationGUID" }
Jason_Mathison | 2020-06-26 13:42:45 UTC | #4
I believe that a JSONPath of $..return_value will get what you are looking for. You might need to use a firstFromArray in the response template to get the result out of an array.
system | 2020-07-27 13:42:48 UTC | #5
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: 8113