Skip to main content

Notifications

Copilot Studio - General
Answered

Show JSON data as response from Agent

Posted on by 23

 Hi, 

 

I am new to Power Agent and I am having a difficult time trying to wrap my head around JSON response. I have a desktop flow which generates a custom JSON object and returns it to the Power Agent Flow. I want to display that JSON data as a response from the bot. I have created the Schema as well but I get the message saying

 

"The output you selected is inside a collection and needs to be looped over to be accessed. This action cannot be inside a foreach."

 

{
    "type""object",
    "properties": {
        "Table": {
            "type""array",
            "items": {
                "type""object",
                "properties": {
                    "Customer": {
                        "type""string"
                    },
                    "Name 1": {
                        "type""string"
                    },
                    "Document Type": {
                        "type""string"
                    },
                    "Billing Document": {
                        "type""string"
                    },
                    "Arrears after net due date": {
                        "type""string"
                    },
                    "Document Number": {
                        "type""string"
                    },
                    "Posting Date": {
                        "type""string"
                    },
                    "Amount in local currency": {
                        "type""string"
                    },
                    "Description": {
                        "type""string"
                    },
                    "Text": {
                        "type""string"
                    },
                    "Net due date symbol": {
                        "type""string"
                    },
                    "Payment date": {
                        "type""string"
                    },
                    "Document Date": {
                        "type""string"
                    }
                },
                "required": [
                    "Customer",
                    "Name 1",
                    "Document Type",
                    "Billing Document",
                    "Arrears after net due date",
                    "Document Number",
                    "Posting Date",
                    "Amount in local currency",
                    "Description",
                    "Text",
                    "Net due date symbol",
                    "Payment date",
                    "Document Date"
                ]
            }
        }
    }
}
 
 
This is my JSON format. I am unable to figure this out even after reading other people's queries. Your help would be really appreciated.
 
 
 
zaidalvi_0-1698323619386.pngzaidalvi_1-1698323756971.png

 

Categories:
  • zaidalvi Profile Picture
    zaidalvi 23 on at
    Re: Show JSON data as response from Agent

    @Expiscornovus I thought by sending messages through to the teams chat was pro active messaging?

    Do you possibly have an example of how I should structure the flow in way that enables this work around. 

     

    Also thank you for your initial response that did clear out the table formatting so I have accepted that as a solution. 

  • Expiscornovus Profile Picture
    Expiscornovus 29,370 on at
    Re: Show JSON data as response from Agent

    Hi @zaidalvi,

     

    As far as I am aware the default time-out is 90 seconds. So, if your desktop flow takes three minutes, that is a bit longer than the default time-out setting.

     

    So, that might be a challenging one, since the time-out setting cannot be changed/updated.

     

    There is an idea to be able to update this time-out value:

    https://ideas.powervirtualagents.com/d365community/idea/6fcc9c42-7a4a-4e10-a9f3-f1b233d7955d

     

    Which channel is used to publish the bot? If it is on Teams you might be able to use pro-active messages as a workaround? You could potentially trigger a 'child' flow (with a HTTP action and an when a HTTP request is received trigger action) which has the desktop flow action in it and return the result as a pro-active message.

     

    This way you can let the parent flow complete within the time-out setting limits and the child flow take whatever time it needs 😁

  • zaidalvi Profile Picture
    zaidalvi 23 on at
    Re: Show JSON data as response from Agent

    @Expiscornovus 

    So my Power Virtual Agent flow looks likes this:

    zaidalvi_0-1698746460982.png


    The Run a flow built with Power Automate for desktop properties have been set to: 

    zaidalvi_1-1698746532303.png

     

    In the parallel branch I have set Post Message in a chat to stop PVA agent from timing out but it isnt working properly. 

     

    Where as my bot shows this: 

    zaidalvi_2-1698746618872.png

    My Desktop flow only has steps to access SAP and extract a file as excel. The entire PVA flow takes around 3 minutes to execute. 
    None of my work arounds have worked so far. What would you suggest?

  • Expiscornovus Profile Picture
    Expiscornovus 29,370 on at
    Re: Show JSON data as response from Agent

    Hi @zaidalvi

     

    Can you share a screenshot of your failed flow instance, which timed out? Can you also share the unattended desktop flow configuration as well. Might be useful to see that for troubleshooting purposes. 

     

    @HenryJammes, we probably need to focus on the time-out issue first before helping out with the formatting.

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Show JSON data as response from Agent

    Hi @zaidalvi, the JSON you shared appears to be the schema.

    Do you have a sample of the JSON data you want to display in PVA?

    How would you like it be formatted in a message?

  • zaidalvi Profile Picture
    zaidalvi 23 on at
    Re: Show JSON data as response from Agent

    @Expiscornovus 

    I have been trying to implement this but I run into the issue of the bot session expiring. (Timeout)

    It takes over two minutes for the PVA to process the desktop and parse the JSON response. Your thoughts?

    Also thank you for taking out the time to respond. 

  • Verified answer
    Expiscornovus Profile Picture
    Expiscornovus 29,370 on at
    Re: Show JSON data as response from Agent

    Hi @zaidalvi,

     

    You can use that returned Table property and format it as a Markdown table. In that format you should be able to return it as response in the Complete output variable.

     

    Below is a blog on how you could apply that markdown formatting:

    https://powerusers.microsoft.com/t5/Power-Virtual-Agents-Community/How-to-use-mark-down-to-format-a-table-for-the-bot-response/ba-p/1190942

     

    Let us know if you need more help with configuring this or if something is unclear.

Helpful resources

Quick Links

Welcome to the Power Platform…

We are thrilled to unveil the newly-launched Power Platform Communities!…

Getting Started…

Welcome to the Power Platform Community! We appreciate your visit…

Welcome to the new Power Platform Community!…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 138,287

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,172

Leaderboard