Enhance your Copilot Studio’s topic with Dynamic Options

Shows the Ask Question Node and highlights that you can change it to a Options from a list variable

Continuing on with my series about Copilot Studio I want to show you something cool. In questions the Copilot asks the user we can presents a option set for the user to choose from. However this list is usually static, such as in my request a day off example. What if we HR adds a leave type option in our HR system? They will probably forget that they have to update the Copilot as well! Let me show you how we can add Dynamic Options to our Copilot.

This post is part of a series of blogpost about Copilot Studio in which I create a HR Copilot and show various options available within Copilot Studio. Here are my other posts about this topic:

Time off types from our HR system

The first thing we want to do is create a Cloud Flow from within Copilot Studio. This ensures that we use the correct Trigger and Return type.

Shows the Create a flow option within topic management of Copilot Studio
Create the Flow

I am not going through building the Cloud Flow to get the meta data from your HR system about leave types. Basically because there are quite a number of HR systems available and it is not the focus of blogpost. Instead I will return a Json structured list as a string to our Copilot topic. We will use this Json string within Copilot later. So look to build the list similar to this formatting when you are building your Cloud Flow that does connect to your HR system.

Shows a Power Automate Cloud Flow to show how to return the leave types as a json array
Cloud Flow Get Leave Types

Don’t be alarmed by the Trigger and Return Action in Power Automate flow. Not every system within Microsoft has gotten the message that Power Virtual Agents has evolved into Copilot Studio. For good measure the json string is as follows:

  "Holiday Leave",
  "Sick Leave",
  "Maternity Leave"

When we are done creating the flow we go back to Copilot Studio. You will need to refresh the studio to load the latest Power Automate Cloud. Select it and it will automatically put the LeaveTypes return variable into a string.

Shows the Node in Copilot Studio calling the Cloud Flow and retrieving the return value in the string variable LeaveTypes
Cloud Flow Node

Grab the string and parse it to a table

Now that we have the string of leave type options from our HR system, we want to utilize them in the Ask a question node. It is not possible to add them to the answers manually. We can however use a table as the options to choose from. The first step is to convert the LeaveTypes string to a table. As this is a json string we can utilize the Parse Value option.

Shows how to add a Parse Value node. You can choose it in Variable Management.
Parse Value in Variable Management

After selecting Parse value you have to choose the variable you want to parse. In our case it’s the LeaveTypes variable the Cloud Flow returned to us.

Shows the Parse Value Node highlighting the From Sample Data option for Data Type
From Sample Data

After which we need to define the Data type we want to parse into. A great feature is that we can provide sample data so the json schema is automatically defined just as in Power Automate!

Shows the Sample Data to enter. It's the same as we return from the Cloud Flow
Sample json

And afterwards you can see that we now have a table. Which I have called ParsedLeaveTypes

Shows the finished Parse Value node. With the variable ParsedLeaveTypes as a table
Parse Value now results in a table

Finishing touches

To finish it off and make our choices dynamic we change the existing question from a “Multiple choice options” to a “Options from a list variable”.

Shows the Ask Question Node and highlights that you can change it to a Options from a list variable
Options From a List Variable

In here we select our ParsedLeaveTypes table variable and we are good to go!

Shows the changed question node with a List Variable to choose from.
Changed Question to Options from a list variable

There you have it! Now our Leave Types our employees can choose from are dynamic. One thing to keep in mind though, is making a call each time to your HR system can be costly. For performance it might be a good idea to keep option sets hardcoded. Or grab the data from Dataverse where you can push the changes from the HR system towards. This post is primarily to inspire what is possible.

Leave a Reply

Your email address will not be published. Required fields are marked *