Check order status with Power Virtual Agent and Power Automate

By - July 27, 2021

I get a lot of requests where my prospects want Power Virtual Agent to be able to answer questions about order statuses. The scenario here is that someone ordered something from your website, or maybe even in person and now they are looking to see what the status of the order is, how the order was shipped and maybe they even want to get a tracking number. I am not going into that much detail in this article, but I am going to discuss how we can use Power Virtual Agent and Power Automate to solve this business problem.

The first thing I want to do is put a topic together where a customer can ask for order related data. This is where Power Virtual Agent asks for an order number and then initiates a Power Automate action to query the database and get the information it needs to feed back to the user who initiated the chat. The first thing I need to do is log into my bot environment by navigating to When the Power Virtual Agent page loads, you need to click on ‘Topics’ on the left side of the screen. From here you can add a new topic by clicking the ‘+New topic’ button on the top of the screen. This will take you to a page where you have to enter a name for your topic (I called it Order Information) and you need to add some trigger phrases as well. In my case I added the following trigger phrases that will get the job done:

  • Where is my order
  • Can you tell me where my order is
  • My order hasn’t arrived
  • Details on my order

After you have entered the trigger phrases you’ll need to save the topic first. Once the save is completed, you can move on to the authoring canvas. Click the ‘Go to authoring canvas’ button on the right side of the screen. You’ll notice the system automatically created a message to start with. I could delete the message and start with a question instead, but I’m good with the message, so I enter ‘Hello, I will be happy to assist with your order tracking‘ in the message box. Click the + button below the message and select ‘Ask a question‘. This is where we allow for the user who is interacting with the Power Virtual Agent to enter the order number. Enter in the question field: ‘Please enter your order number‘. We want to make sure we capture the user’s entire response. To make it easier for us to identify the response to this question, I want to rename the variable for this question. Click on ‘Var‘ below ‘Save response as‘ and change Var to OrderNumber as shown in the screenshot below.

In the next step we’re going to use a Power Automate flow to query Dynamics 365 (Dataverse) and feed some of that data back into Power Virtual Agent. This means the person who is asking the question about their order will be getting information about their order through Power Virtual Agent in the chat session. Click on the ‘+’ button and select ‘Call an action‘, then click on ‘Create a flow’. A Power Automate flow will open with the Power Virtual Agent step already populated. Click on ‘+Add an input’ and select the ‘Text’ option. Type in the first field ‘OrderNumber’ as shown in the screenshot below.

Below the PVA step, click on ‘+ Add Step’ and search for the ‘List Rows’ action. I am actually using the Microsoft Dataverse legacy connector, because my Power Virtual Agent environment is not in the same environment as my Dynamics 365 environment. Select the correct environment you’re going to query for data. In the ‘Filter query’ field enter ordernumber eq and add 2 apostrophes. Place your mouse in the middle of the 2 apostrophes and click on the ‘OrderNumber’ in the Dynamic Content window on the right side of the screen. What this actually does is only find orders with the number the customer typed into Power Virtual Agent. Of course if they enter an order number that doesn’t exist there will be an error, so you might want to enter a condition for when that happens. To keep this article simple, I am not going to cover that condition here.


Below the ‘List Rows’ step, click on ‘Add Step’ and add a compose step. This is where we will get the status reason related to the order the customer was inquiring about, so I renamed this step to ‘Compose – Status’. Since I don’t want an ‘Apply to All’ action to occur, I will use an expression here: Place the mouse in the ‘Inputs’ field of the compose action and enter the following in the expression area: body(‘List_rows’)[‘value’][0][‘_statuscode_label’]
then click ‘OK’.

The next step is another compose step and this is where we want to get the actual name of the order to return to the customer who is engaging with the Power Virtual Agent. Below the Compose – Status step, click on ‘Add Step’ and add a another compose step. Rename the step to ‘Compose – Order Name’. Click your mouse inside the Inputs field again and click on ‘Expression’ again. Enter the following in the expression area: body(‘List_rows’)[‘value’][0][‘name’] then click OK again.

The last item that we want to return to the customer is the shipping method of the order, so again we’re going to add a final compose step. Below the Compose – Order Name step, click on ‘Add Step’ and add a another compose step. Rename the step to ‘Compose – Shipping Method’. Click your mouse inside the Inputs field again and click on ‘Expression’ again. Enter the following in the expression area: body(‘List_rows’)[‘value’][0][‘_shippingmethodcode_label’] and click OK. The shippingmethode field in Dynamics 365 is an option set and if you’re familiar with option sets then you know that there are two parts to the values in option sets. There is a label, which is what end users will actually see when they expand the field to see which choices they can choose from, and there is also a value. This is a numerical value tied to each choice in the option set. Since we want to return the labels of the option set’s choices and not the numerical values this expression is looking for the shippingmethodcode_label.

The last step in the Power Automate flow is the ‘Return value(s) to Power Virtual Agents’ step. This is where we will be feeding the information from Power Automate to the Power Virtual Agent. Click ‘+Add Output’ and select text. Do this for a total of three times. Enter ‘Status Reason’ in the first text field, then ‘Order Name’ and then enter ‘Shipping Method’.

number is coming from, which is from the question we asked the customer in Power Virtual Agent. You probably remember that we saved the entire response to that question as a variable called ‘OrderNumber’, so make sure to pick this value. You’ll also notice on the bottom the values that we are getting back from flow, which we will use in the next step.

Click ‘+Add Node’ and select the ‘Ask a question’ option. In the question window you can start to type your message to the customer. I started to type my message ‘Your Order <OrderName> has a status of <StatusReason>. The shipping method is <ShippingMethod>. Do you want to check any other orders? ”
Keep in mind that the bolded text in the message above represent the variable values passed back from Power Automate. You can add those variables into the message by positioning your cursor in the message window and clicking the ‘Insert variable’ command in the message.

I also added the two options ‘Yes’ and ‘No’ to the question as you can see in the screenshot above. If the answer to the question is ‘Yes’ I am starting the topic from the first question ‘Please enter your order number’. You can do this by clicking ‘+Add Node’ and dragging the little ‘ball’/’circle’ that appears and attaching it to the ‘ball’ above the first question. This will create sort of a loop if the answer to the question is indeed ‘Yes’. If the answer is ‘No’ I am ending the conversation with a survey, and viola, we’re done!

This article was originally published on

Dian Taylor is a Microsoft Business Applications MVP and a LinkedIn Learning Author. She works at RSM as a Dynamics 365 (CRM) Presales Director. Dian is a seasoned pre-sales consultant specializing in Microsoft Dynamics 365 Customer Engagement since 2011. In the past Dian has been involved in solution designing, implementing, configuring and customizing several complex scenarios in various industry sectors. D365-CE modules: Sales, Sales Insights, Custer Service, Omnichannel for Customer Service, Field Service, Project Service Automation, Project Operations. Power Platform: Power Automate, Power Virtual Agents Website: YouTube: Twitter: @D365Goddess

Receive Posts by Email

Subscribe and receive notifications of new posts by email.