Copilot Studio 自适应卡片添加
add-adaptive-card
使用 AdaptiveCardPrompt 生成自适应卡片并插入 Copilot Studio 主题中。当用户要求在主题中添加自适应卡片、富卡片、表单卡片、信息卡片、确认卡片或交互式卡片时使用。
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 493
- Forks
- 103
01 前言 Front Matter
- agent
- copilot-studio-author
- context
- fork
- description
- Generate and insert an Adaptive Card into a Copilot Studio topic using AdaptiveCardPrompt. Use when the user asks to add an adaptive card, rich card, form card, info card, confirmation card, or interactive card to a topic.
- allowed-tools
- Bash(node *schema-lookup.bundle.js *), Read, Write, Edit, Glob
- argument-hint
- <card-type> in <topic-name>
- user-invocable
- false
02 资源文件 1
- 参考文档card-templates.md8.9 KB
03 SKILL.md 正文
Add Adaptive Card
Add an AdaptiveCardPrompt node to an existing Copilot Studio topic. Use this for all Adaptive Card scenarios — display-only cards, input forms, and confirmation flows.
Instructions
-
Auto-discover the agent directory:
Glob: agents/**/agent.mcs.ymlNEVER hardcode an agent name.
-
Clarify requirements from the user if not specified:
- Which topic should the card be added to?
- Which card type (form, info, confirmation)?
- What fields, labels, and placeholders are needed?
- Which topic variables should receive the submitted values?
-
Read the target topic file to understand its structure and find the correct insertion point.
-
Verify the schema if needed:
# Copilot Studio node schema node ${CLAUDE_SKILL_DIR}/../../scripts/schema-lookup.bundle.js summary AdaptiveCardPrompt # Adaptive Cards element schema (v1.6 — the version supported by Copilot Studio) node ${CLAUDE_SKILL_DIR}/../../scripts/schema-lookup.bundle.js ac-summary TextBlock node ${CLAUDE_SKILL_DIR}/../../scripts/schema-lookup.bundle.js ac-summary Input.Text node ${CLAUDE_SKILL_DIR}/../../scripts/schema-lookup.bundle.js ac-search Action -
Select and adapt the template from card-templates.md matching the requested type.
-
Generate unique IDs for all new nodes (format:
<nodeType>_<6-8 random alphanumeric>). -
Insert the node(s) at the correct position in the
actionsarray using Edit. -
Validate the updated topic file:
node ${CLAUDE_SKILL_DIR}/../../scripts/schema-lookup.bundle.js validate <topic-file.yml> -
Inform the user that they must push (VS Code Extension) and publish (Copilot Studio UI) before testing with
/chat-with-agentor/run-tests.
AdaptiveCardPrompt Structure
AdaptiveCardPrompt is the correct node kind for all Adaptive Cards in Copilot Studio. The card JSON is embedded as a multiline YAML literal string under card: |.
- kind: AdaptiveCardPrompt
id: adaptiveCardPrompt_m9Kp2x
card: |
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [...],
"actions": [...]
}
output:
binding:
fieldId: Topic.MyVariable
outputType:
properties:
fieldId:
type: String
Rules:
card: |— the literal block scalar is mandatory. Do not usecard: >or inline the JSON without it.$schemaandversionare required inside the card JSON.- The
output.bindingmaps each card inputidto a topic variable (Topic.VarName, no=prefix). outputType.propertiesmust declare a type for every bound field.- Use plain
binding:— nokind:property inside it. - Every
AdaptiveCardPromptmust haveoutput,outputType, and anAction.Submitbutton — including display-only info cards. Omitting any of these causes VS Code extension errors (MissingRequiredProperty,AdaptiveCardMissingActionSubmit). - For info cards with no meaningful inputs, add an
Action.Submit(e.g. "OK") and bind a dummy acknowledgement variable (Topic.CardAcknowledged, typeString).
Node Comparison
| Node | Use When |
|---|---|
AdaptiveCardPrompt |
Any Adaptive Card — with or without input fields |
SendActivity |
Plain text messages with optional {} variable interpolation |
Do NOT use SendActivity with an attachments array for Adaptive Cards.
Field Validation
Do NOT use style: "Email" or style: "Tel" for validation — these only change the mobile keyboard and do not validate on submit. Always use regex:
{
"type": "Input.Text",
"id": "email",
"label": "Email address",
"placeholder": "Enter your email address",
"isRequired": true,
"regex": "^[a-zA-Z0-9._%+\\-]+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,}$",
"errorMessage": "Enter a valid email address"
}
{
"type": "Input.Text",
"id": "mobile",
"label": "Mobile number",
"placeholder": "Enter your mobile number",
"isRequired": true,
"regex": "^[+]?[0-9][\\s\\-\\(\\)0-9]{6,14}$",
"errorMessage": "Enter a valid mobile number"
}
| Approach | Validates on submit? | Notes |
|---|---|---|
regex |
Yes — blocks submit if pattern fails | Use for email, phone, any format |
isRequired: true |
Yes — blocks submit if empty | Mandatory fields |
style: "Email" |
No | Keyboard hint only — never use for validation |
style: "Tel" |
No | Keyboard hint only — never use for validation |
Rule: Every
Input.ChoiceSet(and any required input) must have alabelproperty, or the VS Code extension raisesAdaptiveCardInputIsRequiredMissingLabel.
Output Binding
- Card input
idvalues must exactly match the keys inoutput.binding. - Topic variable references:
Topic.VariableName(no=prefix). - Declare every bound field in
outputType.propertieswith its type.
output:
binding:
userName: Topic.UserName
userEmail: Topic.UserEmail
category: Topic.Category
outputType:
properties:
userName:
type: String
userEmail:
type: String
category:
type: String
Dynamic Text Around Cards
Card JSON is static — Power Fx expressions and {} interpolation do not work inside the card body. Use SendActivity before or after AdaptiveCardPrompt for dynamic content:
- kind: SendActivity
id: sendMessage_Rz4Wq1
activity: "Hello {Topic.UserName}, please complete the form below."
- kind: AdaptiveCardPrompt
id: adaptiveCardPrompt_m9Kp2x
card: |
{ ... }
Card Types Quick Reference
| Type | Has inputs? | Has output? |
Template |
|---|---|---|---|
form |
Yes | Yes | Form Card |
info |
No (dummy acknowledgement) | Yes (always required) | Info Card |
confirmation |
Yes (ChoiceSet) | Yes | Confirmation Card |
For full YAML examples of each type, see card-templates.md.
04 同仓库更多 Skills
Copilot Studio YAML 校验
validate
使用 LSP 二进制文件的完整诊断能力(YAML 结构、Power Fx、schema、跨文件引用)校验 Copilot Studio 智能体的 YAML 文件。当用户要求检查、验证或核对 YAML 文件时使用。
Copilot Studio 测试身份验证
test-auth
为 Copilot Studio 评估 API 和 SDK 聊天进行身份验证。缓存一个在 run-eval 和 chat-sdk 技能之间共享的令牌。在任何评估或 SDK 聊天工作流之前运行此技能。要求使用具有 MakerOperations 和 Copilots.Invoke 权限的 App Registration。
Copilot Studio Kit 批量测试
run-tests-kit
通过 Copilot Studio Kit (Dataverse API) 运行批量测试套件。使用 Power CAT Copilot Studio Kit 对已发布的智能体执行测试用例,并生成包含延迟的通过/失败结果。要求环境中已安装 Kit、具有 Dataverse 权限的 App Registration,以及已发布的智能体。
Copilot Studio 智能体评估运行
run-eval
通过 Power Platform Evaluation API 对 Copilot Studio 智能体运行评估。适用于草稿(DRAFT)智能体——无需发布步骤。列出测试集、启动运行、轮询直至完成、获取结果,并针对失败提出 YAML 修复建议。当用户希望在不发布的情况下测试智能体更改时使用。
Copilot Studio 主题创建
new-topic
创建一个新的 Copilot Studio 主题(topic)YAML 文件。当用户要求为其智能体创建新主题、对话流程或对话框时使用。
Copilot Studio 智能体管理
manage-agent
通过 VS Code 扩展的 LanguageServerHost LSP 二进制文件推送/拉取 Copilot Studio 智能体内容。处理身份验证(推送/拉取使用交互式浏览器登录,聊天令牌使用设备代码流)、同步推送、同步拉取、克隆和差异比较操作。