Creating a Customer Service Bot for Dynamics 365 for Finance and Operations using Power Virtual Agents (Part 1)

Have you ever wondered how you combine the power of a chat bot with data in Dynamics 365 for Finance and Operations (D365F&O)?

Wonder no more because with Power Virtual Agents you can!

In this series of blog posts I will take a look at how it is done and present you with an example. The series will consist of a number of separate posts exploring the following topics:

  1. This post. An introduction to the Contoso Customer Service Bot and the Power Virtual Agent tool set.
  2. How to use Power Automate flows to connect to D365F&O and provide rich contextual conversations.
  3. In the last post we will take a look at how you embed the bot in Microsoft Teams.

What is a Power Virtual Agent Bot?

Basically, a Power Virtual Agent Bot (PVAB) is a chat bot that is trained to respond to predefined topics (phrases) in a pre-configured flow. The PVAB flow consists of a number of components placed in a logical structure that leads the user through a task by asking questions and responding to user input.

Bot 1

In the above example I am using the opening phrase “new order” to start the conversation with the bot. In response, the bot has been configured to ask for my customer number.

Bot 2

In response to the customer order number I entered (“us-017”), the bot uses a Power Automate flow with a D365F&O connector to look up the customer. In this case, the customer account was found and the bot responds with a new question:

“What product would you like to buy?”.

In this example, I have set up a Power Automate flow that allows the user to look up the product using either the product number or the search name.

Bot 3

When I enter the product number “c0007” the bot calls the Power Automate flow that looks up the product and responds with the product name. The user is asked whether they would like to add the product to an order.

If the answer is yes, the bot continues by asking how many pieces the customer wants:

Bot 4

Once the customer enters a quantity, the bot calls a Power Automate flow that creates a new sales order and adds 5 pieces of iPhone 11 to the order in D365F&O. It returns the sales order number so the bot can inform the customer for future reference.

The bot flow has now ended successfully.

Please note: At any stage in the flow, you can pass the user to a chat experience with a customer service agent (person) through Dynamics 365 Customer Service.

Power Virtual Agent Configuration

In the following we will take a quick look at some of the core concepts in creating a PVAB bot.

I will strongly encourage you to follow the tutorial available when you create your first bot. More documentation is available here.

Create a Bot

To create a new bot in the PVAB home, click on the

Bot 7

icon in the ribbon at the top. This brings up the following dialogue where you give the bot a name and select the environment where you would like to place the bot.

Bot 6

Defining Topics

Once you have created your bot, you need to define topics that will start a bot flow. In my bot example, I have two topics:

  1. Ordering.
  2. Address Change.

The topics give the customer the possibility to create an order (see example above) or change address.

Bot 9

In the above example, I have opened the Ordering topic. For this topic, I have defined 11 phrases that will trigger the flow. If the user enters any of these phrases in the chat window, the ordering bot flow will start.

Bot Authoring Canvas

Once you have defined the trigger phrases for a topic, you click on

Bot 10

to start defining the bot flow.

The following screenshot shows the canvas for the first part of the Ordering topic:

Bot 11

The Trigger Phrases component is mandatory and automatically created.

As mentioned, I will encourage you to use the tutorial to familiarize yourself with the various component types in the canvas. However, I would like to show you a few in my example:

Bot 12

The above shows how the bot asks a question to retrieve the customer number. The input is stored in a variable called CustomerNumber. It subsequently uses the customer number variable as input to the Sales Bot Find Customer flow (in Power Automate). The flow looks up the customer in D365F&O and responds with ResponseCode (used to tell the customer if the account was found or not), ResponseName (customer name) and ResponseId (sales order number).

The following screenshots shows the components in the Power Automate flow:

Bot 14


I hope the above has motivated you to go and create your first bot in Power Virtual Agent. In the next blog post, I will take a closer look at the interaction between the bot and D365F&O through Power Automate.

Final Note: Since a PVAB can be embedded using HTML, it can embedded directly in a D365F&O screen through the new iFrame control.




Published by Henrik Marx Larsen

This blog is my personal contribution to the Microsoft Dynamics 365 for Operations and Finance (D365F&O) community debate. Having worked with Axapta / Dynamics AX / D365F&O for 20 years , I think I may have some interesting insights and views to share. However, I tend to always look forward so I will mostly be writing about current subjects. I have a vain hope that my musings may inspire some of you and provoke some new thoughts in the interest of our community. My day job is to work as a Senior Technical Specialist at Microsoft and help take D365F&O capabilities to new and existing customers. Please note, the views expressed in this blog are mine alone and do not necessarily reflect the views of my employer, Microsoft.

2 thoughts on “Creating a Customer Service Bot for Dynamics 365 for Finance and Operations using Power Virtual Agents (Part 1)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: