Legacy Dev Forum Posts

 View Only

Sign Up

Help in translation map for collection of objects

  • 1.  Help in translation map for collection of objects

    Posted 06-05-2025 18:43

    Mansi_Dhawas | 2022-03-31 18:45:57 UTC | #1

    Hi team, I am using data action which returns collection of objects, and i have to display it on the agents screen using script. Following are the details: Output contract:

    { "title": "object", "type": "object", "properties": { "CUSTOMER": { "type": "array", "items": { "title": "item1", "type": "string" } }, "AGENT": { "type": "array", "items": { "title": "item2", "type": "string" } }, "SENTIMENT": { "type": "array", "items": { "title": "item3", "type": "string" } } }, "additionalProperties": true }

    Response:

    { "translationMap": { "CUSTOMER": "$.[].item1", "AGENT": "$.[].item2", "SENTIMENT": "$.[*].item3" }, "translationMapDefaults": { "CUSTOMER":"[]", "AGENT":"[]", "SENTIMENT":"[]" }, "successTemplate": "{\n \"CUSTOMER\" : ${CUSTOMER}\n, \"AGENT\" : ${AGENT}\n, \"SENTIMENT\" : ${SENTIMENT}\n }" }

    Expected output:

    [ { "CUSTOMER": "Hi!", "SENTIMENT": "positive", "AGENT": "Greetings, I am Eva from ABC airlines. I can help you book a flight or cancel your ticket. How may I help you today?" }, { "CUSTOMER": "Book a flight", "SENTIMENT": "neutral", "AGENT": "Which airport are you flying to?" } ]

    The json output I am getting is null:

    { "CUSTOMER": [ null ], "AGENT": [ null ], "SENTIMENT": [ null ] }

    Referred the https://mypurecloud.discoursehosting.net/forum/t/using-collections-from-data-action-outputs-in-architect/7676 post and accordingly added the translation map, but the output shows null values. Please help me with this.

    Thank you


    Jason_Mathison | 2022-03-31 18:47:42 UTC | #2

    Can you provide an example response from your endpoint that is giving you the unexpected final result? Feel free to cover over anything sensitive, we just need the shape of the response to be right.

    --Jason


    Mansi_Dhawas | 2022-04-01 07:31:44 UTC | #3

    Hi Jason,

    I am trying to fetch the transcript from google to genesys which can be displayed on the screen of the agent. So, 3 objects are created, customer ,agent , and the sentiment of that particular conversation.

    Response used:

    { "translationMap": { "CUSTOMER": "$.[].item1", "AGENT": "$.[].item2", "SENTIMENT": "$.[*].item3" }, "translationMapDefaults": { "CUSTOMER": "[]", "AGENT": "[]", "SENTIMENT": "[]" }, "successTemplate": "{\n \"CUSTOMER\" : ${CUSTOMER}\n, \"AGENT\" : ${AGENT}\n, \"SENTIMENT\" : ${SENTIMENT}\n }" }

    Example expected Output(API output): [ { "CUSTOMER": "Hi!", "SENTIMENT": "positive", "AGENT": "Greetings, I am Eva from ABC airlines. I can help you book a flight or cancel your ticket. How may I help you today?" }, { "CUSTOMER": "Book a flight", "SENTIMENT": "neutral", "AGENT": "Which airport are you flying to?" }, { "CUSTOMER": "Bangalore", "SENTIMENT": "positive", "AGENT": "Which airport are you flying from?" }....... ]

    Till execute it works fine. After applying the translation map, it gives null output.

    Resolve translation map: { "AGENT": "[ ]", "rawResult": "[ {\n \"CUSTOMER\" : \"Hi!\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"Greetings, I am Eva from ABC airlines. I can help you book a flight or cancel your ticket. How may I help you today?\"\n}, {\n \"CUSTOMER\" : \"Book a flight\",\n \"SENTIMENT\" : \"neutral\",\n \"AGENT\" : \"Which airport are you flying to?\"\n}, {\n \"CUSTOMER\" : \"Bangalore\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"Which airport are you flying from?\"\n}, {\n \"CUSTOMER\" : \"Coimbatore\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"When would you like to fly?Please give date in a format of September 15, 2021\"\n}, {\n \"CUSTOMER\" : \"April 1, 2022\",\n \"SENTIMENT\" : \"neutral\",\n \"AGENT\" : \"Please provide me with your first name?\"\n}, {\n \"CUSTOMER\" : \"Debasish\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"Please provide me with your last name?\"\n}, {\n \"CUSTOMER\" : \"Mishra\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"Can you provide me with your phone number with country code like +18723637398?\"\n}, {\n \"CUSTOMER\" : \"+12029992172\",\n \"SENTIMENT\" : \"neutral\",\n \"AGENT\" : \"What is your email ID?\"\n}, {\n \"CUSTOMER\" : \"D'Mishra@gmail.com\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"Following are the available flight options. Please choose one of them.Option A:-From: CoimbatoreTo: BengaluruDate: April 1, 2022Time: 06:00Option B:-From: CoimbatoreTo: BengaluruDate: April 1, 2022Time: 13:00Option C:-From: CoimbatoreTo: BengaluruDate: April 1, 2022Time: 18:00Please choose either Option A, B or C.\"\n}, {\n \"CUSTOMER\" : \"A\",\n \"SENTIMENT\" : \"neutral\",\n \"AGENT\" : \"Okay. That's good.Do you need a window seat or aisle seat?\"\n}, {\n \"CUSTOMER\" : \"Window seat\",\n \"SENTIMENT\" : \"neutral\",\n \"AGENT\" : \"Okay, Window seat it is. Nice choice.What is your food preference? – Veg or Non-Veg\"\n}, {\n \"CUSTOMER\" : \"Veg\",\n \"SENTIMENT\" : \"neutral\",\n \"AGENT\" : \"I have got everything I need to book your flight. Do you need a return ticket?\"\n}, {\n \"CUSTOMER\" : \"No\",\n \"SENTIMENT\" : \"negative\",\n \"AGENT\" : \"For the payment can you confirm the last 4 digits of your credit card?\"\n}, {\n \"CUSTOMER\" : \"7264\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"I have sent a 6 digit One-Time Password to your phone number.Please state the OTP to complete the transaction.\"\n}, {\n \"CUSTOMER\" : \"910238\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"The payment has been completed.I have sent the itinerary to your email ID.\"\n}, {\n \"CUSTOMER\" : \"Thanks!\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"Do you need any additional assistance?\"\n}, {\n \"CUSTOMER\" : \"No\",\n \"SENTIMENT\" : \"negative\",\n \"AGENT\" : \"Thank you for using our service. You have been a wonderful customer.Would you like to rate our services?\"\n}, {\n \"CUSTOMER\" : \"Sure!\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"Please rate us between 1 and 5, 1 being lowest and 5 being highest\"\n}, {\n \"CUSTOMER\" : \"5\",\n \"SENTIMENT\" : \"positive\",\n \"AGENT\" : \"Thank you for rating our service. Have a nice day.\"\n}, {\n \"CUSTOMER\" : \"Oops I entered the wrong date!\",\n \"SENTIMENT\" : \"negative\",\n \"AGENT\" : \"What was that?\"\n}, {\n \"CUSTOMER\" : \"I want to update my flight booking.\",\n \"SENTIMENT\" : \"neutral\",\n \"AGENT\" : \"Which airport are you flying to?\"\n}, {\n \"CUSTOMER\" : \"Not this, want to update date.\",\n \"SENTIMENT\" : \"negative\",\n \"AGENT\" : \"Thank you for using our service. You have been a wonderful customer.Would you like to rate our services?\"\n} ]", "CUSTOMER": "[ ]", "SENTIMENT": "[ ]" }

    Apply output transformation:

    { "CUSTOMER": [], "AGENT": [], "SENTIMENT": [] }

    Thank you


    Jerome.Saint-Marc | 2022-04-04 13:29:23 UTC | #4

    Hello,

    If the HTTP Response (from API) that your translationMap/successTemplate need to process is the one you have described above:

    [ { "CUSTOMER": "Hi!", "SENTIMENT": "positive", "AGENT": "Greetings, I am Eva from ABC airlines. I can help you book a flight or cancel your ticket. How may I help you today?" }, ... ]

    Then you need to modify your translationMap to:

    "translationMap": { "CUSTOMER": "$[].CUSTOMER", "AGENT": "$[].AGENT", "SENTIMENT": "$[*].SENTIMENT" },

    Regards,


    Mansi_Dhawas | 2022-04-07 06:44:55 UTC | #5

    Hello,

    I made the mentioned changes in translation map, but it is clubing all the agent dialogues, sentiments, and customer's dialogues.

    { "AGENT": [ "Greetings, I am Eva from ABC airlines. I can help you book a flight or cancel your ticket. How may I help you today?", "Which airport are you flying to?", "Which airport are you flying from?", "When would you like to fly? Please give date in a format of September 15, 2021" ],

    "CUSTOMER": [ "Hi!", "Book a flight", "Bangalore", "Coimbatore", "April 1, 2022" ],

    "SENTIMENT": [ "positive", "neutral", "positive", "positive" ] }

    Thanks


    Jerome.Saint-Marc | 2022-04-07 15:34:30 UTC | #6

    Hello,

    Yes, this corresponds to what you defined in your Output contract and Response Configuration. AGENT attribute which extracts all AGENT from the API Response (as array), ....

    I just noticed something in your original post. "display it on the agents screen using script."

    Unfortunately, scripts cannot read data from a JSON array. See the note on this page: https://help.mypurecloud.com/articles/look-data-external-source/ "Data returned to a script from a data action must be in a compatible format. Currently, scripts cannot read data from a JSON array. Some fields returned from Data Dip connectors may currently be inaccessible."

    So you will either have to use a different approach - like implement a custom webapp, displayed in Genesys Desktop, that leverages Platform API. About Custom Client Applications integrations About Client Apps

    Or you can request new features and share your use case at https://genesyscloud.ideas.aha.io/idea

    Regards,


    system | 2022-05-08 15:35:03 UTC | #7

    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: 14121