The simplest example is a question with Yes and No for answer options. Like below:
The options are hardcoded into the action and users will see them as buttons in the chat. You use a Condition action to react according to user's answer to the question.
Sometimes when we are dealing with more complex choices there is a need to make the options dynamic. Fortunately, there is a way for it: you can use a table variable to carry the options, and the Question action can list all of the records in it as options for users to choose.
Let's set up a table variable to implement this scenario:
table1
" and make its value: "[{Name:"Option1"},{Name:"Option2"},{Name:"Option3"}]
"in Formula section.Name
" and a value "Option x
", which x goes from 1 to 3. We are supposed to see a dialog with 3 option to choose from:Now we can bind this table to a Question action:
table1
" (the table variable we just created)What do you see? An error!
Yes, it was an error that took me a couple of hours to figure out. I'll show you how to resolve it: The Question action in Copilot Studio looks for a field named "DisplayName
" in each record and uses it as the options presented to users when using a table variable. Unfortunately, there's no way to tell Copilot Studio to use a different field, regardless of how many fields your records contain. Therefore, you MUST include a field specifically named "DisplayName
" in your table.
To solve this issue, we just need to change our table's value to: "[{DisplayName:"Option1"},{DisplayName:"Option2"},{DisplayName:"Option3"}]
"in the Set Variable action.
After the change and complete the conditions for the options, the Question action should work as expected!
Simple but not what I used to as a pro-code developer.
Here is the full YAML code-behind:
1 - kind: SetVariable
2 id: setVariable_OIj99F
3 variable: Topic.table1
4 value: =[{DisplayName:"Option1"},{DisplayName:"Option2"},{DisplayName:"Option3"}]
5
6 - kind: Question
7 id: question_COuBOV
8 interruptionPolicy:
9 allowInterruption: true
10
11 variable: init:Topic.Var1
12 prompt: Ask a question
13 entity:
14 kind: DynamicClosedListEntity
15 items: =Topic.table1
16
17 - kind: ConditionGroup
18 id: conditionGroup_Qb83vd
19 conditions:
20 - id: conditionItem_IVL8wG
21 condition: =Topic.Var1.DisplayName = "Option1"
22
23 - id: conditionItem_r4WFun
24 condition: =Topic.Var1.DisplayName = "Option2"
25
26 - id: conditionItem_HiDUZx
27 condition: =Topic.Var1.DisplayName = "Option3"
28
The content on Invoke, LLC's blog is provided for general informational purposes only and focuses on IT-related topics, including technology trends, software, AI, cybersecurity, and industry commentary. While we strive to provide accurate, up-to-date, and high-quality information, we make no representations or warranties of any kind, express or implied, about the accuracy, reliability, completeness, or suitability of the information, tools, or resources shared on this blog. Any reliance on such content is at your own risk.
The opinions expressed in our blog posts are those of the authors and do not necessarily reflect the official views of Invoke, LLC. Our blog may include links to third-party websites, software, or services. We do not endorse or assume responsibility for the content, functionality, security, or practices of these third-party resources.
The information on this blog is not intended to replace professional IT, technical, AI, or cybersecurity advice. You should consult a qualified IT professional before implementing any solutions, configurations, or strategies discussed on this blog. Invoke, LLC and its affiliates are not liable for any loss or damage, including but not limited to data loss, system downtime, or security breaches, arising from the use of or reliance on this blog’s content.
We reserve the right to modify, update, or remove content on this blog at any time without prior notice.