This blog post is an extension of the Getting Started with Virtual Agents, so if you’d like the background or know how to get started before you read this, check out that post first!

Custom Flows in the Virtual Agent Experience need to meet some specific requirements to display, because VA’s don’t just allow any old Flow to be used. I’ve listed them below.

  • Flows MUST be in a Solution, not lingering around an environment
  • Flows MUST have the Http Request endpoint (When a HTTP request is received) as the starting trigger
  • Flows MUST have the Response as the last action if you wish to return data from the internal workings of the Flow
  • Flows MUST be correctly formatted with JSON at both the request and response to be able to utilise those variables, including the JSON Schema added (Flow will not error if you post an empty schema and your output won’t be obtainable by the VA.)

So, let’s get started creating a brand new custom Flow that your Bot can use.

1. Open Flow and create a new Flow from Blank. Search ‘Request’ and select the HTTP Trigger ‘When a request is received’. This creates an endpoint the Bot will call.

2. Add a JSON schema for the data we expect to be sent. For the example in this post, go ahead and paste in the JSON below. You can always modify this to suit your needs.

{
“type”: “object”,
“properties”: {
“CustomerName”: {
“type”: “string”
},
“CustomerEmail”: {
“type”: “string”
},
“CaseTitle”: {
“type”: “string”
},
“CaseDescription”: {
“type”: “string”
}
}
}
3. Create a new Contact using the ‘Full Name’ information. Given this is a tutorial, this is really a placeholder for much nicer logic you would implement to check if the Contact exists, create if not, use it if it does etc, but for the purpose of creating a placeholder for getting a Contact ID for our Case creation, let’s create a new Contact for now. (You’re not using this in production!)
4. Create a Case record with the Title, Description and Contact object from the previous step in the Flow. It is important you set the ‘Customer Type’ to Contacts here (if you are using Contacts) and use the GUID Contact object from the previous step, or you will get an error back from the Flow not being successful as the Case entity won’t be able to be created. (The Customer one of the mandatory fields)
5. Awesome. Now let’s create a response item by searching for Response in the Actions. Select this and paste the JSON below to pass back the Case Number to the Bot. Use the Dynamic object from the Case you created in the previous step to get the ‘Case Number’ and enter it in the placeholder in the JSON below.

{

“Case Number”: “<Enter Dynamics Case Number Field Here>”

}

If you want/need to return a response object to the bot, you NEED to include a Schema for it. It is not obvious in Flow as it is hidden under ‘Show Advanced Options’ (below), but you need to expand this, and enter the JSON which I’ve included below for you. Again, you can modify this if you want.

Expand the options:

JSON:

{
“type”: “object”,
“properties”: {
“CaseNumber”: {
“type”: “string”
}
}
}
6. Now test your Flow either manually (Microsoft Flow will kick off the request action automatically) or using your Bot. Personally I think it’s better getting your Virtual bot to do it as it’s more realistic and you can check the real-time flow of data.
That’s all there is to it! Now your Flow should appear in the ‘Action’ list when you select it in the Virtual Agent Experience:

I hope that helps in setting up your Custom Flows for Virtual Agents. If you have any questions feel free to add them into the comments below!

Thanks for reading!