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.
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 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.
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.
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)
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 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.'.
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.
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:
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
Romain The Low-Code...
76
Pablo Roldan
61
stampcoin
10