Build a Bot with Virtual Agent, Flow and CDS

This post demonstrates how easy it is to build a Bot using Dynamics 365 Virtual Agent for Customer Service. The Bot will call Flow to return data from CDS and display it to the user. Virtual Agent is part of Microsoft’s push to democratize AI and it allows Bots to be created using a Flow like designer without any code.

Build a Bot with Virtual Agent, Flow and CDS Joe Gill Dynamics 365 Consultant

Virtual Agent is incredibly easy to use and you create Topics for you Bot to interact with users. A Topic is a conversation path that is triggered when the user entering a phrase. In my case I created a Topic called Order that gets triggered when users enter phrases such as “where is my order”. The Topic editor can be used to design the conversation flow and in my conservation I prompt the user to enter their Order No and save it in a variable called OrderNo. I can then pass the OrderNo variable to a Flow to return the order details from CDS and display it to the user.

Build a Bot with Virtual Agent, Flow and CDS Joe Gill Dynamics 365 Consultant

To call a Flow from your Topic you first need to add your Flow to the Common Data Service Default Solution in the CDS environment that Virtual Agent is configured to use. Select + Action option to call a Flow from your Topic.

Build a Bot with Virtual Agent, Flow and CDS Joe Gill Dynamics 365 Consultant

Only Flows that have a response object are displayed can be called from the Topic designer. My GetOrderDetails Flow has a request schema that accepts a single parameter called OrderNo and a response schema that returns a Json object contains the OrderDetails and DeliveryDate. The Flow use the CDS connector to search the orders entity for an order with the orderNo and populates the response object with the retrieved details.

Build a Bot with Virtual Agent, Flow and CDS Joe Gill Dynamics 365 Consultant

Once the flows completes I can take the output from the flow and display it to the user. I did try and use a collection of objects so I could show all orders for a user but I could not get this to work.

Build a Bot with Virtual Agent, Flow and CDS Joe Gill Dynamics 365 Consultant

Once your Topic is complete you can test it directly from the designer window making sure your select the “Start Over with Latest Content” option first. You can also select the Deploy option to generate the HTML code to embed the bot in your own web site. When I trigger my Bot I can now enter a valid Order No returning the order details.

Virtual Agent has simplified the creation of Bots without the need for any technical skills. Using Virtual Agent in combination with Microsoft Flow allows you to build Bots that interact act with back-end platforms without any code. Virtual Agent is currently in preview so there is not pricing information available yet. You can sign up for the preview here.