Legacy Dev Forum Posts

 View Only

Sign Up

getConversationsEmailMessage returning different data types

  • 1.  getConversationsEmailMessage returning different data types

    Posted 06-05-2025 19:01

    Garymannion5 | 2022-09-06 09:53:42 UTC | #1

    Hi All,

    When using getConversationsEmailMessage, I am getting different out put data types for the body of the message. Sometimes it is just the body with no formatting and other times it is the body along with all the html formatting from the message.

    When it's just the text body that returns as expected the column returns 'textbody' and when it brings back the formatting with the text the column reads 'htmlbody'

    (e.g >\r\nHi Amanda,</p>\r\n<p style=\"margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;text-align:left\">\r\nOriginal Query:</p>\r\n<p style=\"margin-bottom:0px;margin-left:0px;margin)

    Is there a way to just bring back the text and not the formatting?

    Kind Regards, Gary


    tim.smith | 2022-09-06 19:07:18 UTC | #2

    The contents of the email is determined by the sender, not Genesys Cloud. Some email clients send plain text only, some html only, and some send both. You can see which bodies are present on the email via the textBody and htmlBody properties in the response for GET /api/v2/conversations/emails/{conversationId}/messages/{messageId}.

    If you want to normalize this, you would need to work with your mail server's administrator to see if that's something that can be done prior to the email reaching Genesys Cloud. You could also normalize this to plain text after fetching it from the API by parsing the htmlBody as HTML and extracting only the displayable text (there are 3rd party libraries that do such things).


    Garymannion5 | 2022-09-07 09:47:26 UTC | #3

    Hi Tim,

    Many thanks for the clear explanation on this. May I ask what 3rd party libraries are you referring to here?

    Kind Regards, Gary


    tim.smith | 2022-09-07 13:19:33 UTC | #4

    I'm not referring to any libraries in particular. You could google for something like "get text from html" plus the language you're using to see what's out there for your environment.


    system | 2022-10-08 13:19:43 UTC | #5

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