$npx -y skills add microsoft/skills-for-copilot-studio --skill add-generative-answersAdd generative answer nodes (SearchAndSummarizeContent or AnswerQuestionWithAI) to a Copilot Studio topic. Use this instead of /add-node when the user asks to add grounded answers, knowledge search, generative answers, or AI-powered responses — these nodes require specific patter
| 1 | # Add Generative Answers |
| 2 | |
| 3 | Add `SearchAndSummarizeContent` nodes to generate responses grounded in the agent's knowledge sources. |
| 4 | |
| 5 | ## Important: Do You Even Need a Topic? |
| 6 | |
| 7 | When knowledge sources are added to the agent (via `/add-knowledge`), the AI can **directly search them without any topic** if it recognizes a QnA-style query. A dedicated topic with `SearchAndSummarizeContent` is useful when: |
| 8 | - You want to **restrict the search to a subset of knowledge sources** (not all of them) |
| 9 | - You want to **control the flow** around the answer (e.g., follow-up questions, formatting, adaptive cards) |
| 10 | - You want to **process the response** before showing it (e.g., extract content, combine with other data) |
| 11 | - You want to **use a specific input** other than the user's last message |
| 12 | |
| 13 | If the user just wants the agent to answer questions from its knowledge, adding the knowledge source may be enough. |
| 14 | |
| 15 | ## Instructions |
| 16 | |
| 17 | 1. **Auto-discover the agent directory**: |
| 18 | ``` |
| 19 | Glob: **/agent.mcs.yml |
| 20 | ``` |
| 21 | NEVER hardcode an agent name. |
| 22 | |
| 23 | 2. **Determine the approach** based on what the user needs: |
| 24 | - **Add to existing topic**: Read the target topic and insert a SearchAndSummarizeContent node |
| 25 | - **Create new search topic**: Generate a complete topic with the search pattern |
| 26 | |
| 27 | 3. **Look up the schema** for both nodes: |
| 28 | ```bash |
| 29 | node ${CLAUDE_SKILL_DIR}/../../scripts/schema-lookup.bundle.js resolve CreateSearchQuery |
| 30 | node ${CLAUDE_SKILL_DIR}/../../scripts/schema-lookup.bundle.js resolve SearchAndSummarizeContent |
| 31 | ``` |
| 32 | |
| 33 | 4. **Read `settings.mcs.yml`** to check if `GenerativeActionsEnabled: true`. This determines the best pattern: |
| 34 | - **`GenerativeActionsEnabled: true`** → prefer **Pattern 2 (Orchestrator)**: use topic inputs/outputs and let the orchestrator handle the response. This is the best approach for generative-orchestrated agents. |
| 35 | - **`GenerativeActionsEnabled: false`** (or not set) → use **Pattern 1 (Direct Response)**: `autoSend: false` + manual SendActivity, or **Pattern 3 (Fallback Search)** for a simple all-knowledge fallback. |
| 36 | - **Verbatim/exact content needed** → use **Pattern 4 (Precision Search)**: `SearchKnowledgeSources` + `CreateSearchQuery` for raw results without AI summarization (insurance policies, HR docs, legal text). |
| 37 | |
| 38 | 5. **Ask the user** to clarify the behavior (if not already clear from their request): |
| 39 | - Should it search **all knowledge sources** or only **specific ones**? |
| 40 | - Should **general model knowledge** also be used, or only the configured knowledge sources? |
| 41 | - Should the response be **sent automatically** to chat, or **processed first** (e.g., custom formatting, adaptive card, combined with other data)? |
| 42 | |
| 43 | 6. **Always precede `SearchAndSummarizeContent` with `CreateSearchQuery`** to preserve conversational context. Never pass `=System.Activity.Text` directly to `SearchAndSummarizeContent` — the raw last message may lack context (e.g., "tell me more about that"). `CreateSearchQuery` rewrites the input into an optimized search query. Access the result via `Topic.<ResultVar>.SearchQuery`. |
| 44 | |
| 45 | 7. **Generate unique IDs** for all nodes (format: `<nodeType>_<6-8 random alphanumeric>`). |
| 46 | |
| 47 | 8. **Build the YAML** using the appropriate pattern. For full YAML examples, see [patterns.md](patterns.md). For the complete property reference table, see [property-reference.md](property-reference.md). |
| 48 | |
| 49 | ## SearchAndSummarizeContent vs AnswerQuestionWithAI |
| 50 | |
| 51 | | Node | Use When | Data Source | Output | |
| 52 | |------|----------|-------------|--------| |
| 53 | | `SearchAndSummarizeContent` | You want answers grounded in the agent's knowledge sources (websites, SharePoint, Dataverse) | Agent's configured knowledge | AI-summarized response | |
| 54 | | `SearchKnowledgeSources` | You need verbatim/exact content — insurance policies, legal text, HR docs — where AI summarization could lose details | Agent's configured knowledge | Raw search results (no AI summary) | |
| 55 | | `AnswerQuestionWithAI` | You want a response based only on conversation history and general model knowledge | No external data | AI-generated response | |
| 56 | |
| 57 | **Use `SearchAndSummarizeContent`** for the vast majority of cases (what people call "generative answers"). Use `SearchKnowledgeSources` when you need raw, unsummarized results for precision scenarios (pair with `CreateSearchQuery` for better search accuracy). Use `AnswerQuestionWithAI` only when you explicitly want the model to respond |