cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cbernier12
Resolver II
Resolver II

Formatting response from Power Automate in virtual agent

Hi does anyone know how to format a response returned to the virtual agent?

 

In Flow I have JSON output that is parsed and I use the "value" from the parse JSON action in the virtual agent response action, however the format is one long JSON string.

[{“id”:“234sodoz-48ff-4ee9-werwe-1edwerewb8dd”,“Name”:“TestName”,“DateTime”:“2018-11-29T23:34:24Z”,“manufacturer”:“Microsoft Corporation”,“model”:“Virtual Machine”,“serialNumber”:“90294”,“operatingSystem”:“Windows”}]

 

I'd like the output for the response to be in a readable format and accommodate for multiple records.  Anyone have ideas?  Ideally I'd like a table, however create CSV and HTML actions in Power Automate don't show correctly in the response either.

 

1 ACCEPTED SOLUTION

Accepted Solutions
cbernier12
Resolver II
Resolver II

Ok, after some testing I figured out how to make a table format.  In the append to string variable stack the values on top of one another, then add a space on top and bottom between each value.  At the very top add some dashes and do the same for the very bottom underneath the last value.  Works really well.

 

So it will look like this:

 

----------------------------------------------

name

 

id

 

model

 

etc...

----------------------------------------------------

 

If you want you can add the title for each row next to the value if needed.

 

So Name: namevalue and so on.

 

@renatoromao @Pstork1 

 

View solution in original post

10 REPLIES 10
renatoromao
Super User
Super User

Hi @cbernier12 ,

 

You can use Markdown to format results inside the Power Virtual Aggents.

 

Basically, you need to create a parse JSON action inside the Power Automate, read all properties and format the results inside your workflow.

After that, you need to create a response to your chatbot using a string property.

 

I will create a sample, wait some minutes, please.

But you can read this documentation: Use markdown to format Power Automate approvals - Power Automate | Microsoft Docs


Did I answer your question? Mark my post as a solution!
Thanks!

Renato Romão,

Connect with me here 😉

Power Virtual Agents course (+2.760 students) : English | Português
renatoromao
Super User
Super User

1.png

 

2.png

 

3-.png


Did I answer your question? Mark my post as a solution!
Thanks!

Renato Romão,

Connect with me here 😉

Power Virtual Agents course (+2.760 students) : English | Português
renatoromao
Super User
Super User

Hi @cbernier12 ,

 

I posted all steps above.

You can follow it and if you need to use the PArse Json Schema, you can see my code below:

 

{
    "type""array",
    "items": {
        "type""object",
        "properties": {
            "id": {
                "type""string"
            },
            "Name": {
                "type""string"
            },
            "DateTime": {
                "type""string"
            },
            "manufacturer": {
                "type""string"
            },
            "model": {
                "type""string"
            },
            "serialNumber": {
                "type""string"
            },
            "operatingSystem": {
                "type""string"
            }
        },
        "required": [
            "id",
            "Name",
            "DateTime",
            "manufacturer",
            "model",
            "serialNumber",
            "operatingSystem"
        ]
    }
}

Did I answer your question? Mark my post as a solution!
Thanks!

Renato Romão,

Connect with me here 😉

Power Virtual Agents course (+2.760 students) : English | Português
Pstork1
Dual Super User
Dual Super User

I suspect you are looking for the ability to return an array to PVA the way you can with Power Apps.  That functionality isn't currently available.  As @renatoromao said you need to format your response as text in the Flow and then return it to PVA for display.  You can't return a raw array the way you can when using an HTTP Response to return JSON to Power Apps.  It may be possible in the future, but isn't at this point.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@renatoromao I tried your example exactly and I receive the following at the parse JSON action:

 

The 'content' property of actions of type 'ParseJson' must be valid JSON. The provided value cannot be parsed: 'Invalid property identifier character: “. Path '[0]', line 1, position 2.'.

cbernier12
Resolver II
Resolver II

Actually I'm using a HTTP call that pulls data back and then I parse it with a parse JSON action, in the apply to each action I need to somehow convert the object to an array I guess.  Or will that not work either?

 

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')' is of type 'Object'. The result must be a valid array.

renatoromao
Super User
Super User

HI @cbernier12 ,

 

If you are using Http request to get data from other API or something like that, you need to confirm which is the return that you are receiving because I used your sample to build this template.

 

Basically you will use the HTTP body inside the Content field on the Parse JSON action and maintain the same parse that I used. (Maybe you can remove the required property, but it’s not necessary yet before work the read content values).

 

Can you send a screenshot about your http result?

And also send the result here (you can remove sensitivity information)


Did I answer your question? Mark my post as a solution!
Thanks!

Renato Romão,

Connect with me here 😉

Power Virtual Agents course (+2.760 students) : English | Português

Hi @renatoromao, yes very familiar with parsing HTTP calls with the parse JSON action, however it needs to be converted to an array not an object which is the default.  I can use select action, however it won't break out the individual values parse JSON does.

cbernier12
Resolver II
Resolver II

@renatoromao I got it to work, so the output is still one big string only now the headers start and every entry has a | between it.  Pretty much back to where I started.  Is there no way to modify so it shows up in a table like format in the virtual agent?  Returning one record isn't an issue, however when there are multiple records, the response is a mess to read as it's just one long string of data in the UI.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

Canadian Cloud 2022 768x460.png

Register for a free PVA chatbot creation workshop.

Learn how to respond rapidly to your customers and employees at scale, using intelligent conversational chatbots.

Top Solution Authors
Users online (1,354)