Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Agentless Email Data action failing with HTML BODY from Email flow

    Posted 05-12-2025 01:52
    Edited by Simon Mckenzie 05-12-2025 17:19

    Is this the correct forum for my enquiry???
     

    I am trying to forward emails arriving into an architect email flow automatically based on key word found in the subject or body of email. These are auto forwarded outside of Genesys to the correct teams shared MS mailbox address using an Agentless data action without an agent being involved. 

    2 snags:-

    [A] - the call data action "agentless email" fails in the flow on the html body of email

    [B] I am unable to FWD attachments (apparently this is a limitation of the system at present)

     

    The Agentless email data action variable "Email.Message.htmlBody" is where it falls down. The email sends ok if I do not include the body of the email.
    Obviously there is a formatting issue with the way the htmlbody is interpreted by the data action.

     

    Does anyone know how to get more than 1 filter in the data action email body as i believe my issue is syntax???

     

    e.g Any one of these 3 work individually. How does one combine them all into 1 piece of code???? or provide a better piece of code for me to try :) 

     

    Replace(Email.Message.htmlbody,  ",", "<br>")

    Replace(Email.Message.htmlbody,  "\R", "<br>")

    Replace(Email.Message.htmlbody,  "\N", "<br>")

     

    Some suggest having the Data action requestTemplate remove any newlines (\n or \r) from the string AND escape the newlines so they don't cause an issue. How does one do all of this in the one request template??

    I have tried this but it doesn't work 

    {

        "senderType": "Outbound",

        "fromAddress": {

            "email": "${input.fromAddressEmail}",

            "name": "${input.fromAddressName}"

        },

        "toAddresses": [

            {

                "email": "${input.toAddressEmail}",

                "name": "${input.toAddressName}"

            }

        ],

        "replyToAddress": {

            "email": "${input.replyToAddressEmail}",

            "name": "${input.replyToAddressName}"

        },

        "subject": "${input.subject}",

        "htmlbody": "{\"input.htmlBody\" : #if( ${input.htmlBody} && ${input.htmlBody} != \"\")\"$esc.html(${input.htmlBody.replace("\n", "\\\n").replace("\r", "\\\r")})\"#{else}null#end}"

    }

     

     

     

    ERRORS

     

    {

      "message": "The request could not be understood by the server due to malformed syntax.",

      "code": "bad.request",

      "status": 400,

      "messageParams": {},

      "contextId": "56cd6c0d-2a42-453b-a0c0-92754638e5cd",

      "details": [

        {

          "errorCode": "ACTION.PROCESSING"

        }

      ],

      "errors": [

        {

          "message": "Action failed validation. Errors: [Template validation failed for 'config.request.requestTemplate'.  Details: Lexical error,   Encountered: \"\\\"\" (34), after : \"\\\\\" at *unset*[line 18, column 88]]",

          "code": "BAD_REQUEST",

          "status": 400,

          "messageParams": {},

          "details": [],

          "errors": []

        }

      ]

    }

     


    #ArchitectureandDesign
    #DataActions
    #Agentless
    #EmailFlow

    ------------------------------
    Simon Mckenzie
    Genesys Cloud Technical Consultant
    ------------------------------



  • 2.  RE: Agentless Email Data action failing with HTML BODY from Email flow

    Posted 05-12-2025 12:04

    Hi Simon,

    I am going to move this to the Developer Community as I believe they will be better placed to answer the API response



    ------------------------------
    Sam Jillard
    Online Community Manager/Moderator
    Genesys - Employees
    ------------------------------



  • 3.  RE: Agentless Email Data action failing with HTML BODY from Email flow

    Posted 05-12-2025 17:16

    Thanks Sam. :)



    ------------------------------
    Simon Mckenzie
    Genesys Cloud Technical Consultant
    ------------------------------



  • 4.  RE: Agentless Email Data action failing with HTML BODY from Email flow

    Posted 05-13-2025 08:13

    Can you provide an example of the htmlBody body input to the data action that doesn't work?  Please either use test data, or redact any personal information.



    ------------------------------
    --Jason
    ------------------------------



  • 5.  RE: Agentless Email Data action failing with HTML BODY from Email flow

    Posted 05-15-2025 01:59

    I created a TASK.HTML and applied the following and it is now forwarding emails out ok via the agentless email data action.
    URL links are retained in the body of the forwarded email. Pictures gets replaced by [image: DSC06579.JPG] which is better than nothing.
    PDFs and other attachments get stripped off by design leaving no trace on the forwarded email which a pain. Hopefully this is fixed in the future. It appears our only option for forwarding attachments is when an agent is doing it. 

    Has anyone managed to find a work around for this? eg, email flow stores the email attachment, then agentless data action retrieves it / re-attaches it to the forwarded email? 

    Replace(Replace(Trim(Email.Message.body), "\r", "<br>"), "\n", "")



    ------------------------------
    Simon Mckenzie
    Genesys Cloud Technical Consultant
    ------------------------------