Office 365 Email & ChatGPT

Hi all!

I have a basic flow set up; Microsoft 365 Email set to look for unread emails in ‘Inbox’ > OpenAI to look at the ‘Body: Content’ and send to an assistant to write a response and send back to Microsoft 365 email which will save the response as a draft.

However, I am getting an error :“[400] Invalid ‘messages[0].content’: string too long. Expected a string with maximum length 32768, but got a string with length 46892 instead.”

Which seems to be because the body is comprised of a lot of HTML styling, so it is exceeding the character limit for OpenAI.

What I am wondering is if anyone else has come across this problem and how they overcame it. Is there a way of stripping out the HTML and just having the text from the Microsoft 365 email read?

Hey Matt,

There are a few options. You could do this ‘inline’ with the stripHTML() function. So you wrap your text from M365 in the OpenAI module with the stripHTML() function. This will strip away all the HTML tags:


Results in:
image

Another option is using the HTML to text module from the text parser tool as an in-between:

And you can then map the output of that HTML to text module to OpenAI.

Hope that helps!

2 Likes

Amazing @NolaDigital I opted for the Text Parser which has worked perfectly. Thank you. :star_struck:

2 Likes

Hey there @Matt7 :wave:

Happy to hear that @NolaDigital’s solution erased your trouble and fixed the problem.

Could you please mark his comment as a solution? This way we keep our community healthy and neat for everybody.

Thanks! :sunflower:

1 Like

Consider it done, @vendy :smiley:

2 Likes