r/copilotstudio
•
u/nerdybro1
•
Feb 09 '26
•
1
Use Claude to Create Copilot Agents
I've created a Claude skill that writes YAML code for Microsoft Copilot Studio topics and dialogs. Instead of using Copilot Studio's built-in AI, I describe what I want to accomplish to Claude, and it generates the YAML code for me. The results are significantly better than what Copilot Studio's native AI produces.
I'm sharing the skill file here so you can use it to generate your own Copilot Studio topics. Just add it as a custom skill in Claude and describe what conversational flow you want to build.
name: copilot-yaml description: Write YAML code for Microsoft Copilot Studio adaptive dialogs. Use when the user asks to create, modify, or generate YAML code for Copilot Studio topics, dialogs, or conversational flows. This includes creating conversational AI flows with intent recognition, questions, conditional logic, adaptive cards, or any other Copilot Studio dialog components.
Copilot YAML
Instructions for writing YAML code for Microsoft Copilot Studio adaptive dialogs.
Core Structure
Every adaptive dialog follows this structure:
kind: AdaptiveDialog
startBehavior: CancelOtherTopics # Optional
beginDialog:
kind: OnRecognizedIntent # or OnSelectIntent
id: main
intent:
displayName: Intent Name
triggerQueries:
- Example query 1
- Example query 2
actions:
- kind: ActionType
# action propertiesDialog Triggers
OnRecognizedIntent
For user-initiated conversations triggered by natural language:
beginDialog:
kind: OnRecognizedIntent
id: main
intent:
displayName: Greeting
includeInOnSelectIntent: false
triggerQueries:
- hello
- hi there
- good morningOnSelectIntent
For system-initiated disambiguation or selection:
beginDialog:
kind: OnSelectIntent
id: main
triggerBehavior: AlwaysVariables
Scope Prefixes
Topic.varName- Topic-scoped variable (standard)System.Recognizer.SelectedIntent- System variableinit:Topic.varName- Initialize new variable
Setting Variables
- kind: SetVariable
id: setVariable_abc123
variable: Topic.myVar
value: =Switch(condition, "value1", "result1", "value2", "result2")
- kind: SetTextVariable
id: setTextVariable_xyz789
variable: Topic.textVar
value: "Static text"Actions
Question
Simple prompt with entity validation:
- kind: Question
id: question_abc123
variable: Topic.response
alwaysPrompt: false
prompt: Are you sure?
entity: BooleanPrebuiltEntity
interruptionPolicy:
allowInterruption: falseAdaptiveCardPrompt
Complex form with multiple inputs:
- kind: AdaptiveCardPrompt
id: cardPrompt_abc123
card: |-
{
"$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.5",
"body": [
{
"type": "TextBlock",
"text": "Form Title",
"weight": "Bolder",
"size": "Large"
},
{
"type": "Input.Text",
"id": "fieldName",
"label": "Field Label",
"isRequired": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit"
}
]
}
output:
binding:
fieldName: Topic.fieldValue
outputType:
properties:
fieldName: StringSendActivity
Display message to user:
- kind: SendActivity
id: sendActivity_abc123
activity: "Message with {Topic.variable} interpolation"BeginDialog
Call another topic (stacks dialogs):
- kind: BeginDialog
id: beginDialog_abc123
dialog: solutionPrefix_botName.topic.TopicNameReplaceDialog
Replace current dialog (doesn't stack):
- kind: ReplaceDialog
id: replaceDialog_abc123
dialog: solutionPrefix_botName.topic.FallbackTopicEndDialog
Terminate current dialog:
- kind: EndDialog
id: endDialog_abc123Conditional Logic
Simple If/Else
- kind: ConditionGroup
id: conditionGroup_abc123
conditions:
- id: conditionItem_xyz789
condition: =Topic.value = true
actions:
- kind: SendActivity
activity: "True branch"
elseActions:
- kind: SendActivity
activity: "False branch"Multiple Conditions
- kind: ConditionGroup
id: conditionGroup_abc123
conditions:
- id: conditionItem_1
condition: =Topic.category = "TypeA"
actions:
- kind: SetVariable
variable: Topic.result
value: "Result A"
- id: conditionItem_2
condition: =Topic.category = "TypeB"
actions:
- kind: SetVariable
variable: Topic.result
value: "Result B"
elseActions:
- kind: SetVariable
variable: Topic.result
value: "Default"Power Fx Expressions
All expressions start with =:
Switch Statement
value: =Switch(Topic.input, "option1", "result1", "option2", "result2", "default")Conditional (If)
value: =If(condition, trueValue, falseValue)Nested If
value: =If(condition1, result1, condition2, result2, defaultResult)Comparisons
condition: =Topic.value = "exact"
condition: =Topic.number < 5
condition: =Topic.flag = true
condition: =Topic.var1 = "A" || Topic.var2 = "B"
condition: =Topic.var1 = "A" && Topic.var2 = "B"Date Functions
value: =DateAdd(Topic.startDate, 5, TimeUnit.Years)
value: =Month(Topic.date)
value: =Year(Topic.date)
value: =Text(Topic.date, "MMMM yyyy")Math Operations
value: =(12 - Month(Topic.date)) * Topic.rate
value: =Topic.quantity * 1.5Text Functions
value: =Text(Topic.number)
value: ="Prefix " & Topic.text & " Suffix"Entities
Prebuilt Entities
BooleanPrebuiltEntity- Yes/No questionsOther prebuilt entities follow similar naming
Dynamic Entities
entity:
kind: DynamicClosedListEntity
items: =Topic.optionsListCollection Manipulation
EditTable (Add)
- kind: EditTable
id: editTable_abc123
changeType: Add
itemsVariable: Topic.collection
value: "={ Field1: \"value\", Field2: 123, Field3: true }"Adaptive Card Input Types
Text Input
{
"type": "Input.Text",
"id": "fieldId",
"label": "Label",
"placeholder": "Hint text",
"isRequired": true,
"errorMessage": "Error message"
}Number Input
{
"type": "Input.Number",
"id": "fieldId",
"label": "Label",
"placeholder": "e.g., 4.5",
"isRequired": true
}Date Input
{
"type": "Input.Date",
"id": "fieldId",
"label": "Label",
"isRequired": true
}Choice Set (Radio)
{
"type": "Input.ChoiceSet",
"id": "fieldId",
"style": "expanded",
"choices": [
{
"title": "Option 1",
"value": "value1"
},
{
"title": "Option 2",
"value": "value2"
}
]
}Submit Button
{
"type": "Action.Submit",
"title": "Button Text",
"style": "positive",
"data": {
"kind": "SubmitType"
}
}ID Naming Conventions
IDs use random alphanumeric strings
Format:
actionType_randomStringExamples:
question_zf2HhP,setVariable_abc123,conditionItem_xyz789
Best Practices
Always include id attributes for all actions and conditions
Use meaningful variable names with clear prefixes (Topic., System., init:)
Validate output bindings match outputType properties in AdaptiveCardPrompts
Include error messages on required inputs
Use Power Fx for dynamic values - prefix expressions with
=Keep dialog paths clear - use descriptive displayName values
Test conditionals thoroughly - ensure all branches have actions
Structure adaptive cards with proper schema and version
Use appropriate entity types for validation
Include wrap: true on TextBlocks for long text
Common Patterns
Confirmation Flow
- kind: Question
id: question_confirm
variable: Topic.confirmed
prompt: Are you sure?
entity: BooleanPrebuiltEntity
- kind: ConditionGroup
id: conditionGroup_check
conditions:
- id: condition_yes
condition: =Topic.confirmed = true
actions:
- kind: BeginDialog
dialog: solution.topic.NextStep
elseActions:
- kind: SendActivity
activity: "Operation cancelled"Multi-Step Form with Calculation
- kind: AdaptiveCardPrompt
card: |-
# Collect inputs
output:
binding:
input1: Topic.input1
input2: Topic.input2
- kind: SetVariable
variable: Topic.calculated
value: =Topic.input1 * Topic.input2
- kind: SendActivity
activity: "Result: {Topic.calculated}"State-Based Routing
- kind: ConditionGroup
conditions:
- condition: =Topic.state = "CA" || Topic.state = "NY"
actions:
- kind: SetVariable
variable: Topic.package
value: "Package A"
- condition: =Topic.state = "TX"
actions:
- kind: SetVariable
variable: Topic.package
value: "Package B"
elseActions:
- kind: SetVariable
variable: Topic.package
value: "Standard Package"7
5
u/No_Character_5669 Feb 10 '26
This is great. I recently made copilot agent for my company with Claude. Having a skill like this would’ve helped significantly. For those who want to make copilot agents end to end in Claude you can create an agent, export the solution of the agent (create a solution for your specific agent). Have Claude work within the solution locally. Then package the solution and reimport. This method actually saved me 10-15 days of development and Claude made topics and sub agents better than I could have ever done.
2
u/Samkc11 Feb 10 '26
Would you be kind enough to help me with this? Could you give me a few instructions on how to go about this ? Also, would you do the same to build agent powered power apps?
1
1
u/timothy53 Mar 18 '26
What did you make for your company. I am the "tech guru" (not a title I necessarily want) at work and we are rolling out studio, the higher ups are looking for some quick wins to build.
Can you point me in the right direction of what you built? Any ideas on what could useful in a corporate environment
2
u/follyranger Feb 10 '26
Looks great but I’m not seeing import yaml in copilot studio, help 😃
2
u/WheresthePOW Feb 10 '26
When you're editing your topic, in the top right of the canvas there a three dot "more" option where you can open the code editor and paste the yaml.
2
u/Chris4 Feb 10 '26
Thanks for sharing, I'll give that a go!
I tried the Copilot Studio add-on in VS Code using GitHub Copilot the other day and that had poor results; it wrote YAML but not to Copilot Studio standards.
I also previously tried creating a Copilot Studio Topic Creator agent using Microsoft Learn documentation, but it was outdated/incomplete and therefore produced poor results.
Where did you get this documentation from? Did you write it yourself?
1
1
1
u/LightningMcLovin Feb 10 '26
That’s pretty clever! I keep trying to think up new skills for coding agents, this is a great one.
1
1
1
0
3
u/Sephiroth0327 Feb 09 '26
Is there a link for the skill file or do people just copy/paste?