mcpField
I
int-reference

int-reference

github.com/microsoftAgent 工作流483109 次安装1 天前更新
代码仓库

关于 int-reference

面向 Copilot Studio YAML 项目的参考技能,整理文件结构、触发器、动作、变量和 Power Fx 等定义。适用于构建或检查 Copilot Studio Agent 的开发者,也涵盖连接器动作的配置注意事项。

主要功能

  1. 01说明核心 YAML 文件类型
  2. 02区分生成式与经典编排触发机制
  3. 03列出动作类型与连接器配置
  4. 04汇总系统变量和变量作用域
  5. 05提供受支持的 Power Fx 函数

适用场景

  1. 01查找 Copilot Studio YAML 结构定义
  2. 02配置主题触发器与对话动作
  3. 03检查连接器输入和属性格式

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/microsoft/skills-for-copilot-studio --skill int-reference

安装后在 Claude Code 中输入/int-reference确认已加载。

详细介绍

Copilot Studio YAML 参考

核心文件类型

文件用途
agent.mcs.ymlAgent 主元数据(kind: GptComponentMetadata)
settings.mcs.ymlAgent 设置和配置
connectionreferences.mcs.yml连接器引用
topics/*.mcs.yml对话主题(kind: AdaptiveDialog)
actions/*.mcs.yml基于连接器的操作(kind: TaskDialog)
knowledge/*.mcs.yml知识源(kind: KnowledgeSourceConfiguration)
variables/*.mcs.yml全局变量(kind: GlobalVariableComponent)
agents/*.mcs.yml子 Agent(kind: AgentDialog)

触发器类型

带有 OnRecognizedIntent 的主题有两种路由机制,具体取决于编排模式:

  • modelDescription — 用于生成式编排(GenerativeActionsEnabled: true)。AI 编排器会读取此内容来决定路由。这是生成式 Agent 的主要机制。
  • 触发短语(triggerQueries)— 用于经典编排。通过模式匹配用户的话语。启用生成式编排时,它们是次要提示。

系统触发器(OnConversationStart、OnUnknownIntent、OnError 等)会自动触发,不使用上述任一机制。

Kind用途
OnRecognizedIntent匹配触发短语
OnConversationStart对话开始
OnUnknownIntent未匹配到主题(回退)
OnEscalate用户请求人工 Agent
OnError错误处理
OnSystemRedirect仅由重定向触发
OnSelectIntent匹配到多个主题(消歧)
OnSignIn需要身份验证
OnToolSelected调用子 Agent
OnKnowledgeRequested触发自定义知识源搜索(仅 YAML,不在 UI 中显示)
OnGeneratedResponse发送前拦截 AI 生成的回复
OnOutgoingMessage不生效(2026-03-15) — 存在于架构中,但运行时不会触发。请勿使用。
仅限 YAML 的功能

这些功能在运行时有效,但不会显示在 Copilot Studio UI 中。请提醒用户,UI 编辑可能会悄无声息地移除这些功能。

功能说明
知识源上的 triggerConditionUI 仅将其显示为开关(=false 可将其从 UniversalSearchTool 中排除)。任意 Power Fx 表达式(例如 =Global.UserDepartment = "HR")在运行时有效,但只能通过 YAML 设置。请谨慎使用。(2026-03-16)

操作类型

Kind用途
SendActivity发送消息
Question向用户提问并获取输入
SetVariable设置/计算变量(Power Fx 表达式,前缀为 =)
SetTextVariable使用模板插值({})设置文本变量。可用于将非文本类型(例如 Number)转换为文本:"You have {Topic.Count} items"
ConditionGroup分支逻辑
BeginDialog调用另一个主题
ReplaceDialog替换当前主题
EndDialog结束当前主题
CancelAllDialogs取消所有主题
ClearAllVariables清除变量
SearchAndSummarizeContent生成式回答(基于知识)
AnswerQuestionWithAIAI 回答(仅使用对话历史和常识)
EditTable修改集合
CSATQuestion客户满意度
LogCustomTelemetryEvent日志记录
OAuthInput登录提示
SearchKnowledgeSources搜索知识源(返回原始结果,不提供 AI 摘要)
CreateSearchQuery根据用户输入生成 AI 搜索查询

Connector 操作(TaskDialog)

Connector 操作(kind: TaskDialog)会调用外部 Connector 操作。它们存储在 actions/ 中,并且需要在 connectionreferences.mcs.yml 中引用连接。

使用 /add-action 根据可用的 Connector 创建新操作。 架构描述了 TaskDialog 和 InvokeConnectorTaskAction 的结构属性,但每个 Connector 操作的具体输入和输出因 Connector 而异 — 使用 Connector 查找脚本(connector-lookup.bundle.js)获取完整的操作详情。

操作结构
字段用途
kind: TaskDialog标识这是一个 Connector 操作
inputs输入:AutomaticTaskInput(由 AI 提供)或 ManualTaskInput(固定值)
modelDisplayName用于 AI 编排器路由的显示名称
modelDescription用于 AI 编排器路由的描述
outputsConnector 返回的输出属性名称
action.kindConnector 操作始终为 InvokeConnectorTaskAction
action.connectionReference连接的逻辑名称(在 connectionreferences.mcs.yml 中注册)
action.connectionProperties.modeMaker(创建者的凭据)或 Invoker(最终用户的凭据)
action.operationIdConnector 的特定操作标识符
outputMode通常为 All — 导出所有操作输出
输入类型
输入类型使用场景说明
AutomaticTaskInputAI 编排器应根据上下文提供值包含 description,帮助 AI 了解应提供什么
ManualTaskInput固定/硬编码的值(例如,时区、文件夹路径)只能硬编码字符串。非字符串值(ID、枚举)应在推送后由用户检查
$ 前缀属性名称(SharePoint、OData)

某些 Connector(尤其是 SharePoint)使用 $filter、$orderby、$top 等 OData 参数。这些参数在 TaskDialog YAML 中需要特殊引号 — 同时使用单引号和双引号:

# TaskDialog (actions/*.mcs.yml) — CORRECT
- kind: ManualTaskInput
  propertyName: "'$filter'"
  value: "Status eq 'Active'"

"'$filter'" 表示:外层的 "" 是 YAML 字符串分隔符;内层的 '' 是发送给运行时的字面值的一部分。单独使用 $filter、"$filter" 或 '$filter' 都会失败。

InvokeConnectorAction(主题中的内联操作)使用不同的格式 — 使用 parameters/ 前缀,且不加内层单引号:

# InvokeConnectorAction (inside topics) — CORRECT
- kind: InvokeConnectorAction
  operationId: GetItems
  input:
    parameters/$filter: "Status eq 'Active'"

切勿混用这两种格式。

系统变量

变量说明
System.Bot.NameAgent 的名称
System.Activity.Text用户当前的消息
System.Conversation.Id对话标识符
System.Conversation.InTestMode如果处于测试聊天中,则为 True
System.FallbackCount连续回退的次数
System.Error.Message错误消息
System.Error.Code错误代码
System.SignInReason触发登录的原因
System.Recognizer.IntentOptions用于消歧的匹配意图
System.Recognizer.SelectedIntent用户选择的意图
System.SearchQueryAI 重写后的搜索查询(在 OnKnowledgeRequested 中可用)
System.KeywordSearchQuery搜索查询的关键词版本(在 OnKnowledgeRequested 中可用)
System.SearchResults用于填充自定义搜索结果的表 — 架构:Content、ContentLocation、Title(在 OnKnowledgeRequested 中可用)
System.ContinueResponse在 OnGeneratedResponse 中设为 false 可禁止自动发送
System.Response.FormattedTextAI 生成的响应文本(在 OnGeneratedResponse 中可用)
变量作用域
前缀作用域生命周期
Topic.<name>主题变量仅限当前主题
Global.<name>全局变量整个对话(在 variables/ 文件夹中定义)
System.<name>系统变量内置,只读

全局变量以 YAML 文件形式定义,路径为 variables/<Name>.mcs.yml(kind: GlobalVariableComponent)。aIVisibility 接受 UseInAIContext(编排器可以读取该值并进行推理)或 Hidden(编排器不可见——用于标志和内部簿记)。

预置实体

实体使用场景
BooleanPrebuiltEntity是/否问题
NumberPrebuiltEntity数值输入
StringPrebuiltEntity自由文本
DateTimePrebuiltEntity日期/时间
EMailPrebuiltEntity电子邮件地址

Power Fx 表达式参考

只能使用以下支持列表中的函数。 Copilot Studio 支持 Power Fx 的一个子集——使用不支持的函数会导致错误。

# Arithmetic
value: =Text(Topic.number1 + Topic.number2)

# Date formatting
value: =Text(Now(), DateTimeFormat.UTC)

# Conditions
condition: =System.FallbackCount < 3
condition: =Topic.EndConversation = true
condition: =!IsBlank(Topic.Answer)
condition: =System.Conversation.InTestMode = true
condition: =System.SignInReason = SignInReason.SignInRequired
condition: =System.Recognizer.SelectedIntent.TopicId = "NoTopic"

# String interpolation in activity (uses {} without =)
activity: "Error: {System.Error.Message}"
activity: "Error code: {System.Error.Code}, Time (UTC): {Topic.CurrentTime}"

# Record creation
value: "={ DisplayName: Topic.NoneOfTheseDisplayName, TopicId: \"NoTopic\", TriggerId: \"NoTrigger\", Score: 1.0 }"

# Variable initialization (first assignment uses init: prefix)
variable: init:Topic.UserEmail
variable: init:Topic.CurrentTime
# Subsequent assignments omit init:
variable: Topic.UserEmail
支持的 Power Fx 函数

以下是 Copilot Studio 中所有可用的 Power Fx 函数。请勿使用此列表以外的任何函数。

数学:Abs、Acos、Acot、Asin、Atan、Atan2、Cos、Cot、Degrees、Exp、Int、Ln、Log、Mod、Pi、Power、Radians、Rand、RandBetween、Round、RoundDown、RoundUp、Sin、Sqrt、Sum、Tan、Trunc

文本:Char、Concat、Concatenate、EncodeHTML、EncodeUrl、EndsWith、Find、Left、Len、Lower、Match、MatchAll、Mid、PlainText、Proper、Replace、Right、Search、Split、StartsWith、Substitute、Text、Trim、TrimEnds、UniChar、Upper、Value

日期/时间:Date、DateAdd、DateDiff、DateTime、DateTimeValue、DateValue、Day、EDate、EOMonth、Hour、IsToday、Minute、Month、Now、Second、Time、TimeValue、TimeZoneOffset、Today、Weekday、WeekNum、Year

逻辑:And、Coalesce、If、IfError、IsBlank、IsBlankOrError、IsEmpty、IsError、IsMatch、IsNumeric、IsType、Not、Or、Switch

表格:AddColumns、Column、ColumnNames、Count、CountA、CountIf、CountRows、Distinct、DropColumns、Filter、First、FirstN、ForAll、Index、Last、LastN、LookUp、Patch、Refresh、RenameColumns、Sequence、ShowColumns、Shuffle、Sort、SortByColumns、Summarize、Table

聚合:Average、Max、Min、StdevP、VarP

类型转换:AsType、Boolean、Dec2Hex、Decimal、Float、GUID、Hex2Dec、JSON、ParseJSON

其他:Blank、ColorFade、ColorValue、Error、Language、OptionSetInfo、RGBA、Trace、With

可用模板

插件已打包这些模板。使用模板的技能通过 ${CLAUDE_SKILL_DIR}/../../templates/ 引用它们。

模板文件模式
问候templates/topics/greeting.topic.mcs.ymlOnConversationStart 欢迎语
兜底templates/topics/fallback.topic.mcs.ymlOnUnknownIntent 与升级处理
算术templates/topics/arithmeticsum.topic.mcs.yml带计算的输入/输出
问题 + 分支templates/topics/question-topic.topic.mcs.yml带 ConditionGroup 的问题
知识搜索templates/topics/search-topic.topic.mcs.ymlSearchAndSummarizeContent 兜底
自定义知识源templates/topics/custom-knowledge-source.topic.mcs.yml使用自定义 API 的 OnKnowledgeRequested(仅限 YAML)
移除引用templates/topics/remove-citations.topic.mcs.ymlOnGeneratedResponse 引用清理
身份验证templates/topics/auth-topic.topic.mcs.yml带 OAuthInput 的 OnSignIn
错误处理程序templates/topics/error-handler.topic.mcs.yml带遥测的 OnError
消歧templates/topics/disambiguation.topic.mcs.ymlOnSelectIntent 流程
Agenttemplates/agents/agent.mcs.ymlGptComponentMetadata
连接器操作(通用)templates/actions/connector-action.mcs.yml使用连接器的 TaskDialog(结构参考)
知识(公共网站)templates/knowledge/public-website.knowledge.mcs.ymlPublicSiteSearchSource
知识(SharePoint)templates/knowledge/sharepoint.knowledge.mcs.ymlSharePointSearchSource
全局变量templates/variables/global-variable.variable.mcs.ymlGlobalVariableComponent

评论

支持 Markdown