rocco52 | 2019-06-06 03:45:39 UTC | #1
Hello, I have created a PureCloud Data Action to request an external contact to PureCloud API.
This is the output contact:
And the result when I test the data action is OK
When I set the data action in the IVR, the values of the entities.id and entities.tittle variables arrive empty. But the total variable arrives with value.
I have done several tests and the variables that have the dot like entities.id, don't load, in fact, in the IVR changes the point by a __:
I'm consuming GET /api/v2/externalcontacts/contacts, its output is:
And I need to obtain the values id and title from objetc entities, how I can do it whitout errors in IVR?
Jason_Mathison | 2019-06-06 12:41:51 UTC | #2
Hi rocco52,
The issue appears to be that you are attempting to do the flattening of the output contract yourself. The output contract should have an entities object with title and id properties inside of it. The Data Action service takes care of flattening the input and output contracts as well as output from your action.
If you continue to have difficulties with getting this to work please include an export of your action along with a cut & paste of the response from the contacts api (not an image).
--Jason
rocco52 | 2019-06-06 14:14:53 UTC | #3
Hello Jason_Mathison, I created the entities object in another attempt, but it didn't work. The variables do not appear in the tests.
This is the data action: <a class="attachment" href="/forum/uploads/db6296/original/2X/a/a9f92e47511ad90717508cc0f8f7519a45341e05.json">PRUEBA-EU-BUSCAR-CONTACTO-EXTERNO-2019060691431.custom.json</a> (2.2 KB)
That's the service I am using: https://developer.mypurecloud.com/developer-tools/#/api-explorer?share=N4IgDghgLgFiBcIDmBTKBRAHlFAnAdhADYDGA9vlBCVAM4DCFVNtIANCALZoxkAmCZGnYgArrgCWggPQQwE6QDcATNJTY8hUk2p1p5SrtYdIuCJwBqxUSlbxQkVAGUJALxSCAjCMcoAcqKcAEZ4CJ4cAI6CABwADADsAJye0QAs0SAAvplAA
This is the full output of the service:
{ "entities": [ { "id": "f0102367-a4ed-42c5-b650-da5074e6b55b", "firstName": "Ricardo", "middleName": "", "lastName": "Delgado", "title": "80791848", "workPhone": { "display": "+57 311 3212200", "acceptsSMS": false, "userInput": "+573113212200", "e164": "+57311321220", "countryCode": "CO" }, "modifyDate": "2019-06-06T00:58:37Z", "createDate": "2019-05-30T01:34:25Z", "surveyOptOut": false, "selfUri": "/api/v2/externalcontacts/contacts/f0102367-a4ed-42c5-b650-da5074e6b55b" } ], "pageSize": 1, "pageNumber": 1, "total": 1, "firstUri": "/api/v2/externalcontacts/contacts?pageSize=1&pageNumber=1", "selfUri": "/api/v2/externalcontacts/contacts?pageSize=1&pageNumber=1", "lastUri": "/api/v2/externalcontacts/contacts?pageSize=1&pageNumber=1", "pageCount": 1 }
Thank you for your help
Jason_Mathison | 2019-06-06 15:23:13 UTC | #4
Please try the entities object again, testing it in architect. We have an open ticket for issues with the test mode UI when flattening is enabled for objects with subobjects.
rocco52 | 2019-06-06 16:27:48 UTC | #5
Hello Jason_Mathison
I'm trying with this new version of output contract:
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "entities": { "properties": { "id": { "type": "string" } } } } }
But, doing the test, it doesn't show the variable id.
Is this contract correct?
I have published this dataaction to test in IVR. I see that in the IVR shows the ID output, however, doing a test call, it enters directly by the path fail.
Thank you
Jason_Mathison | 2019-06-06 17:46:06 UTC | #6
The reason that nothing showed up in the Test UI output is that the schema didn't include "type" : "object" for "entities"
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "entities": { "type": "object", "properties": { "id": { "type": "string" } } } } }
Jason_Mathison | 2019-06-06 17:56:22 UTC | #7
Since it appears that you are trying to grab a few specific pieces of data about the contact, you would probably be better off using a translation map to grab the data that you want. For example, to grab the id of the first contact that you get back and return it you would have an output contract like this:
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "id": { "type": "string" } } }
and a response configuration like this:
{ "translationMap": { "id" : "$.entities[0].id" }, "translationMapDefaults": {}, "successTemplate": "{ \"id\" : ${id}}" }
rocco52 | 2019-06-06 18:37:32 UTC | #8
Thank you Jason_Mathison
I tested the second option with the traslation map and it works perfectly .
Thank you very much!
system | 2019-07-07 18:37:33 UTC | #9
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: 5298