$npx -y skills add microsoft/skills-for-copilot-studio --skill add-nodeAdd or modify a node in an existing Copilot Studio topic. Use when the user asks to add a question, message, condition, variable, or other node to a topic. Do NOT use this for generative answers or knowledge search — use /add-generative-answers instead.
| 1 | # Add Node to Topic |
| 2 | |
| 3 | Add a new node to an existing Copilot Studio topic, or modify an existing one. |
| 4 | |
| 5 | In Copilot Studio, the elements inside a topic's `actions` array are **nodes** (SendActivity, Question, ConditionGroup, etc.). These are different from **actions** (`actions/*.mcs.yml`), which are connector-based TaskDialogs. This skill handles nodes within topics. |
| 6 | |
| 7 | **For generative answers (SearchAndSummarizeContent, AnswerQuestionWithAI)**, use the `/add-generative-answers` skill instead — it has the specific patterns, follow-up ConditionGroup logic, and disambiguation guidance needed to set them up correctly. |
| 8 | |
| 9 | ## Instructions |
| 10 | |
| 11 | 1. **Auto-discover the agent directory**: |
| 12 | ``` |
| 13 | Glob: **/agent.mcs.yml |
| 14 | ``` |
| 15 | NEVER hardcode an agent name. |
| 16 | |
| 17 | 2. **Parse the arguments** to identify: |
| 18 | - The node type (SendActivity, Question, SetVariable, ConditionGroup, etc.) |
| 19 | - The target topic file |
| 20 | - If modifying an existing node, which node to modify |
| 21 | |
| 22 | 3. **Look up the node schema**: |
| 23 | ```bash |
| 24 | node ${CLAUDE_SKILL_DIR}/../../scripts/schema-lookup.bundle.js resolve <NodeType> |
| 25 | ``` |
| 26 | |
| 27 | 4. **Read the existing topic file** to understand its current structure. |
| 28 | |
| 29 | 5. **Generate or modify the node** with: |
| 30 | - A unique ID (format: `<nodeType>_<6-8 random alphanumeric>`) |
| 31 | - All required properties from the schema |
| 32 | - Appropriate default values |
| 33 | |
| 34 | 6. **Determine the correct insertion point** in the actions array and present the plan to the user before writing. |
| 35 | |
| 36 | ## Common Node Types |
| 37 | |
| 38 | | Node | Purpose | Key Properties | |
| 39 | |------|---------|----------------| |
| 40 | | `SendActivity` | Send message | `kind`, `id`, `activity` | |
| 41 | | `Question` | Ask user input | `kind`, `id`, `variable`, `prompt`, `entity` | |
| 42 | | `SetVariable` | Set/compute value | `kind`, `id`, `variable`, `value` | |
| 43 | | `SetTextVariable` | Set text with interpolation (YAML-only, no canvas) | `kind`, `id`, `variable`, `value` | |
| 44 | | `ConditionGroup` | Branching logic | `kind`, `id`, `conditions` | |
| 45 | | `BeginDialog` | Call another topic | `kind`, `id`, `dialog` | |
| 46 | | `EndDialog` | End topic | `kind`, `id` | |
| 47 | | `CancelAllDialogs` | Cancel all topics | `kind`, `id` | |
| 48 | |
| 49 | ## Generative Orchestration Guidelines |
| 50 | |
| 51 | When the agent has `GenerativeActionsEnabled: true`: |
| 52 | |
| 53 | - Prefer **AutomaticTaskInput** over Question nodes for collecting user info (the orchestrator handles prompting automatically). |
| 54 | - Still use Question nodes when: conditional asks (ask X only if Y), or end-of-flow confirmations. |
| 55 | - Prefer **topic outputs** over SendActivity for returning results. |
| 56 | - Do NOT use SendActivity to show final outputs unless it's a precise mid-flow message. |
| 57 | |
| 58 | ## Power Fx Quick Reference |
| 59 | |
| 60 | - Expressions start with `=`: `condition: =System.FallbackCount < 3` |
| 61 | - String interpolation uses `{}`: `activity: "Error: {System.Error.Message}"` |
| 62 | - Variable init on first assignment: `variable: init:Topic.MyVar` |
| 63 | - Common: `Text()`, `Now()`, `IsBlank()`, `!IsBlank()` |
| 64 | |
| 65 | ## Example: Adding a Question Node |
| 66 | |
| 67 | ```yaml |
| 68 | - kind: Question |
| 69 | id: question_k7xPm2 |
| 70 | variable: init:Topic.UserName |
| 71 | prompt: What is your name? |
| 72 | entity: StringPrebuiltEntity |
| 73 | alwaysPrompt: true |
| 74 | interruptionPolicy: |
| 75 | allowInterruption: false |
| 76 | ``` |
| 77 | |
| 78 | ## Important Notes |
| 79 | |
| 80 | - **Unique IDs**: Use random 6-8 alphanumeric characters. Duplicate IDs cause Copilot Studio errors. |
| 81 | - Verify the node type exists in the schema before generating. |
| 82 | - For ConditionGroup, include at least one condition item with its own unique ID. |