Skip to main content

Notifications

How to use mark down to format a table for the bot response

Example scenario

In this article we are using a Power Virtual Agent to collect FAQ articles for a relevant product for the user. As you can see in the screenshot below this setup works fine, however the results are still in JSON format. The aim of this article is to show you how you can format these results into a table.

 

createtableforarrayresponse_pva.png

Prerequisites for this example

Before you start it is good to know that these bits were created for this example.

1. Create Power Virtual Agents bot

2. Create a custom topic in your Power Virtual Agents bot

3. Create a new flow from the Power Virtual Agents authoring canvas 

4. A SharePoint list with FAQ items like below

 

faqs_sharepointlist.png

 

Table Markdown in Power Automate Flow 

Below are the steps how you can create the table with mark down. In this example we are presenting a table with two columns and we are using three fields from the SharePoint list in the rows of that table.

 

1. Modify the Power Virtual Agents trigger action. Add a Text Input variable. In this example this is ProductChoiceInput.

 

productchoiceinput.png

 

2. Add a Initialize variable action, call this variable MarkDownTable. In this action we are going to create a table with Markdown. Paste the code snippet from below in the value field. Make sure you also add a CR at the end.

 

 

| Title | FAQ |

 

 

initializevariable_markdowntable.png

 

3. Add a Append to string variable action, select the MarkDownTable variable. Paste the code snippet from below in the value field. Make sure you also add a CR at the end.

 

 

|-----------|:-----------:|

 

 

appendtomarkdown_separate.png

 

4. Add a Get Items action. Make sure you use a OData filter to retrieve only the FAQs from the relevant category. This filter will use the ProductChoiceInput from the trigger action.

 

 

Category eq '@{triggerBody()['text']}'

 

 

getitems_odatafilter.png

 

5. Add an Apply to each action. Use the value field of the Get Items action in the output field. Add another Append to string variable action in the loop, select the MarkDownTable variable. Paste the code snippet from below in the value field. Make sure you also add a CR at the end. 

 

 

| @{items('Apply_to_each')['title']} | [@{items('Apply_to_each')?['FAQID']}](@{items('Apply_to_each')?['FAQLink']}) |

 

 

appendtostring_rowtable.png

 

6. Modify the Return value(s) to Power Virtual Agents action. Add a Text output variable. Use the MarkdownTable variable for the content of that text output.

 

returnvaluetopva.png

 

7. Save the flow and return to the authoring canvas of your custom topic.

 

Testing the end result

After you finished the configuration you can start testing your bot. Below is how the new mark down table should look like after it has been formatted. Happy testing!

 

testing_endresult_pva.png

 

Comments

*This post is locked for comments