OpenAi Chat Completion output not formatted correctly when used as body for the "Reply To Outlook Mail Message" Activity

Hi, All,

Need some help getting the email reply (from OpenAi Chat Completion) on the right format. It doesn’t have any line spacing; everything in one paragraph. Can’t find answers from the web and both solutions from Chatgpt and Bard doesn’t work.

“Response” is my Output - Top Generated Text variable from the OpenAi Generate Chat Competion activity.

Give try at YourTextVar.Replace(Environment.NewLine,"<br>")

I appreciate the reply! Not sure if I did it right using the “Assign” but it’s the same email output, no line spacing.


Please do one thing

use the immediate panel, type in the variable name and share the output with us
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Also try:

Please see snips below. The other 3 functions are giving me an error.

I tried the “Modify Text” approach to no avail:

please run also

And share the screenshot with us . thanks

All 3 are giving me the same error. I’m fairly new to this. Let me know if I’m doing it wrong… I appreciate the help!

Hi, @ppr ,

I made some corrections in the Assign activity and the issue seem to have been resolved although not consistent. It works on the first test email but not on the second… Do I need to do something in the “Reply To Outlook Mail Message” activity?

I think we’re getting close. Thanks a lot for the help!

This is by the way working: YourTextVar.Replace(Environment.NewLine,“

we do see in second mail text screenshot no <br>. So you will not get linebreaks (br - break - html - short newline)

It worked twice on one email but issue reoccurred. Must have been a fluke. GPT3.5 turbo’s output is with \n for line breaks and is always the case. Not sure why it’s not getting converted to html


thats why we asked moretimes for

Yey! Finally figured out! The below approached worked! Thanks for sharing very helpful bits of info @ppr

Value to save = Response.replace(vbLf, “< br >”)

Value to save = Response.Replace(“\n”, environment.NewLine)


Also have a look at this defensive replacement
[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.