Hello. I configure the email routing rules for our contact center. We are trying to use a Genesys Cloud Data Action to automatically create an incident ticket in our external ServiceNow system when a specific VIP customer emails us. I created the Data Action to push the email body into the ServiceNow ‘description’ field. However, because the inbound email contains complex HTML tags and quotation marks, the Data Action fails with a 400 Bad Request error. The JSON payload becomes malformed due to the unescaped HTML characters. How do I safely send raw HTML email bodies through a Data Action?
Greetings. When extracting qualitative data such as email transcripts for external reporting or ticketing systems, strict JSON schema validation is enforced by the Genesys Cloud integration gateway. You cannot pass raw HTML directly into a JSON string value without escaping the quotation marks and control characters.
Within your Data Action’s Request Configuration template, you must wrap the input variable with the esc.jsonString() Velocity macro. For example, your payload should be formatted as "description": ${esc.jsonString($input.emailBody)}.
This macro automatically escapes the disruptive HTML characters, ensuring the JSON remains valid.
Oh, this is such a classic ServiceNow integration issue! The esc.jsonString() macro is absolutely the correct fix for the Data Action crash! However, I want to give you a huge warning from the ServiceNow side! Even after you successfully pass the HTML into the ticket, ServiceNow’s default incident description field is plain text! It will literally display all the raw HTML tags (<div>, <br>) to your IT agents, making it completely unreadable! You must modify your ServiceNow REST API endpoint to map that specific payload variable to an HTML-enabled ‘Work Notes’ or ‘Rich Text’ field instead of the basic description!