Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Canned Response in HTML

    Posted 06-05-2025 18:43

    wu_edward | 2021-12-06 23:02:26 UTC | #1

    In a call flow, I have a data action to retrieve a canned response but the response is in html. Is there a way to convert it to plain text?


    Jason_Mathison | 2021-12-07 03:36:39 UTC | #2

    Data Actions require the response from the endpoint to be in JSON. If the endpoint is returning raw HTML then you can't directly use that endpoint from a Data Action, you could work around that by calling a lambda from a data action.

    --Jason


    wu_edward | 2021-12-07 18:16:49 UTC | #3

    Thanks @Jason_Mathison . Sorry I am not familiar with the lambda integration. Does it mean I have to create a lambda function in AWS to call the Genesys API endpoint and somehow create a data action in Genesys that integrates with my lambda function?


    Jason_Mathison | 2021-12-07 20:09:37 UTC | #4

    Which Genesys route are you accessing? Let's see if it returns raw HTML, or if it is returning JSON.

    --Jason


    wu_edward | 2021-12-07 20:18:43 UTC | #5

    /api/v2/responsemanagement/responses/query


    wu_edward | 2021-12-07 20:25:15 UTC | #6


    Jason_Mathison | 2021-12-08 02:50:43 UTC | #7

    Ok, so the endpoint is returning JSON, with one of the values being a string containing HTML. This is something we can work with.

    We don't have any built in functionality to convert HTML to plain text, but you could setup your response template to rip out any HTML tags that you want to get rid of.

    I set my test endpoint to return this: { "test" : "<p>Test some <BR> HTML </p>" }

    This response template will grab that response and remove all of the HTML included in it. You will need to add more HTML inside of the replaceAll to remove other tags.

    { "translationMap": { "html": "test" }, "translationMapDefaults": {}, "successTemplate": "{ \"no-more-html\" : $html.replaceAll(\"<BR>|<p>|</p>\", \"\") }" }

    If removing known chunks of HTML isn't enough, then consider running a lambda data action in order to do smarter cleaning. There is certainly a javascript or python library that can do this for you.

    --Jason


    system | 2022-01-08 02:51:37 UTC | #8

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