Skip to main content

Notifications

Community site session details

Community site session details

Session Id : zua1xcVRvBu0nGTt5/xrG8
Copilot Studio - General
Answered

Power Virtual Agents - Rendering line breaks on bot messages

Like (0) ShareShare
ReportReport
Posted on 9 Jun 2020 18:29:03 by Microsoft Employee

Hi,

 

I have string values returned from Power Automate that contain line breaks expressed as "\n" within the text. I tried several alternatives to replace those with "<br>", "</br>", etc., but HTML does not seem to work.

 

Which formats are supported for line breaks?

 

Thanks,

 

AgustĂ­n

Categories:
  • DLW-at-H Profile Picture
    on 09 Dec 2023 at 01:54:37
    Re: Power Virtual Agents - Rendering line breaks on bot messages

    For those coming late to the party, you should know that as at end 2023 pva copilot does not seem to support anything like encode/decode. I got this to work by using something like Plaintext("text1<p>text2")

  • adafieno Profile Picture
    Microsoft Employee on 10 Nov 2020 at 15:08:19
    Re: Power Virtual Agents - Rendering line breaks on bot messages

    Sure, @HackManFrank. As suggested by @ChristianAbata, in Power Automate, I used the uriComponentToString function to replace "\n" with the HTML URL encoding for line feed, as follows:

    uriComponentToString(replace(variables('return_sample'),'\n','%0A%0A'))

     

    I hope it helps.

  • HackManFrank Profile Picture
    2 on 10 Nov 2020 at 13:01:58
    Re: Power Virtual Agents - Rendering line breaks on bot messages

    Hey @adafieno.

    Can you tell me, how exactly you got it working? I seem to misunderstand some of the details regarding the function expression used in the solution post.

     

    Thank you

  • adafieno Profile Picture
    Microsoft Employee on 15 Jun 2020 at 22:38:08
    Re: Power Virtual Agents - Rendering line breaks on bot messages

    Thanks, Christian. That did it. Much appreciated.

  • Verified answer
    cabata Profile Picture
    314 Most Valuable Professional on 15 Jun 2020 at 22:23:58
    Re: Power Virtual Agents - Rendering line breaks on bot messages

    @adafieno did you try encoding uri? https://powerusers.microsoft.com/t5/Building-Flows/Replace-Newline-in-Flow-Expression/td-p/57333

     

    In this example the user is deleteing a line break.

     

    see in PA you an encode an decode uri, so you can replace <br> with %0A%0A and in a compose action you can see a line break the you can send your output response to PA again.

  • adafieno Profile Picture
    Microsoft Employee on 15 Jun 2020 at 21:09:47
    Re: Power Virtual Agents - Rendering line breaks on bot messages

    Thanks for your suggestion, Christian. That type of encoding doesn't work either. 

    It seems like the problem lies within the rendering component of Power Virtual Agents. It looks like it's not able to parse and render line breaks.

  • cabata Profile Picture
    314 Most Valuable Professional on 15 Jun 2020 at 19:54:56
    Re: Power Virtual Agents - Rendering line breaks on bot messages

    hi @adafieno did you use encoding html https://www.w3schools.com/tags/ref_urlencode.ASP

     

    %0A

     

    is equals to break

  • adafieno Profile Picture
    Microsoft Employee on 09 Jun 2020 at 19:49:15
    Re: Power Virtual Agents - Rendering line breaks on bot messages

    Thanks. Yes, I did use "/s/s", and also "\s\s" which is what the documentation you sent me says.

     
  • MarKol Profile Picture
    on 09 Jun 2020 at 19:42:07
    Re: Power Virtual Agents - Rendering line breaks on bot messages

    Did you use /s/s markdown tag to indicate a double empty space?

  • adafieno Profile Picture
    Microsoft Employee on 09 Jun 2020 at 19:10:30
    Re: Power Virtual Agents - Rendering line breaks on bot messages

    Thanks. That doesn't work either. It just renders two spaces wherever there's a "\n" string.

     

    I need a way to insert actual line break characters into the string to render correctly in markdown. The double spaces force the new line, but it assumes that the text has a line break in the end.

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Copilot Studio - General

#1
Ekta Gupta Profile Picture

Ekta Gupta 4

#2
ricardodesouza Profile Picture

ricardodesouza 2

#2
L-1234567-0 Profile Picture

L-1234567-0 2

Overall leaderboard
Loading started