关于 playbook-generation
用于根据自然语言描述生成 ServiceNow Process Automation Designer (PAD) playbook 的技能,面向构建引导式流程自动化的团队。它支持配置阶段、泳道、活动、数据输入以及活动间的条件转换。
主要功能
- 01从需求描述梳理 playbook 结构
- 02配置阶段与并行泳道
- 03添加审批、决策和通知活动
- 04定义活动数据输入与输出
- 05设置条件转换和流程上下文
适用场景
- 01构建事件分诊与处理流程
- 02为 Agent 创建交互式工作指引
- 03编排包含审批和决策的多阶段流程
MCP 相关
使用 ServiceNow MCP 工具查询现有 playbook,并创建、配置、验证和发布 playbook、阶段、泳道、活动及转换。
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ happy-technologies-llc/ happy-platform-skills --skill playbook-generation安装后在 Claude Code 中输入/playbook-generation确认已加载。
详细介绍
流程自动化设计器手册生成
概述
本技能涵盖根据自然语言描述生成 ServiceNow 流程自动化设计器(PAD)手册:
- 创建用于自动执行流程的标准手册
- 构建包含引导式交互步骤、面向 Agent 的手册
- 定义用于并行和顺序工作流的泳道
- 添加活动:数据收集、审批、决策和通知
- 配置用于手册上下文的数据输入和输出
- 设置基于阶段的多阶段流程推进
- 将手册关联到目录项、事件、案例和其他记录类型
适用场景: 构建引导式流程自动化、创建包含数据收集步骤的面向 Agent 的工作流,或自动执行需要人工与系统交互的多泳道业务流程。
前置条件
- 角色:
process_automation_designer或admin - 插件:
com.snc.process_flow(流程自动化设计器)、com.glide.hub.flow_designer(流程设计器) - 访问权限: sys_process_flow、sys_pd_activity、sys_pd_lane、sys_pd_transition 表
- 知识: 对流程自动化概念(手册、泳道、活动、阶段)有基本了解
- 相关技能:
genai/flow-generation(用于流程设计器流程)、genai/skill-kit-custom(用于 Now Assist 技能集成)
流程
第 1 步:分析自然语言描述
解析用户请求,确定:
- 手册类型: 标准(自动化)或面向 Agent(交互式)
- 目标表: 手册支持的记录类型(incident、case、change_request、sc_req_item)
- 泳道: 并行工作流,或基于角色的任务划分
- 活动: 手册应执行的步骤(数据收集、审批、通知、子流程)
- 阶段: 流程的主要阶段(例如,分流、调查、解决)
- 条件: 决策点和分支逻辑
第 2 步:查询现有手册以获取模式
MCP 方式:
Use SN-Query-Table on sys_process_flow:
- query: active=true^sys_class_name=sys_pd_playbook
- fields: sys_id,name,description,table,playbook_type,active,status
- limit: 10
REST 方式:
GET /api/now/table/sys_process_flow
?sysparm_query=active=true^sys_class_name=sys_pd_playbook
&sysparm_fields=sys_id,name,description,table,playbook_type,active,status
&sysparm_limit=10
查询现有手册活动,以查找可复用的模式:
Use SN-Query-Table on sys_pd_activity:
- query: playbook=<playbook_sys_id>
- fields: sys_id,name,activity_type,lane,order,stage
- limit: 50
第 3 步:创建手册记录
标准手册(自动化):
MCP 方式:
Use SN-Create-Record on sys_pd_playbook:
- name: "Incident Resolution Playbook"
- description: "Guides agents through structured incident resolution process"
- table: "incident"
- playbook_type: "standard"
- status: "draft"
- active: false
- trigger_type: "record"
- trigger_condition: "priority<=2^category=network"
REST 方式:
POST /api/now/table/sys_pd_playbook
Body: {
"name": "Incident Resolution Playbook",
"description": "Guides agents through structured incident resolution process",
"table": "incident",
"playbook_type": "standard",
"status": "draft",
"active": false,
"trigger_type": "record",
"trigger_condition": "priority<=2^category=network"
}
面向 Agent 的手册(交互式):
Use SN-Create-Record on sys_pd_playbook:
- name: "Customer Onboarding Playbook"
- description: "Interactive playbook guiding agents through customer onboarding"
- table: "sn_csm_case"
- playbook_type: "agent_facing"
- status: "draft"
- active: false
第 4 步:定义手册阶段
阶段代表流程的主要阶段。
MCP 方式:
Use SN-Create-Record on sys_pd_stage:
- playbook: "<playbook_sys_id>"
- name: "Triage"
- label: "Triage"
- order: 100
- description: "Initial assessment and categorization"
Use SN-Create-Record on sys_pd_stage:
- playbook: "<playbook_sys_id>"
- name: "Investigation"
- label: "Investigation"
- order: 200
- description: "Root cause analysis and troubleshooting"
Use SN-Create-Record on sys_pd_stage:
- playbook: "<playbook_sys_id>"
- name: "Resolution"
- label: "Resolution"
- order: 300
- description: "Apply fix and verify resolution"
REST 方式:
POST /api/now/table/sys_pd_stage
Body: {
"playbook": "<playbook_sys_id>",
"name": "Triage",
"label": "Triage",
"order": 100,
"description": "Initial assessment and categorization"
}
第 5 步:创建泳道
泳道用于定义并行工作流,或基于角色的任务分组。
主要泳道类型:
| 泳道类型 | 说明 | 使用场景 |
|---|---|---|
| 系统 | 无需用户交互的自动化操作 | 后台任务、通知 |
| Agent | 由指定 Agent 执行的任务 | 数据收集、手动步骤 |
| 审批 | 专用于审批的泳道 | 经理或 CAB 审批 |
| 客户 | 面向客户的活动 | 自助式数据收集 |
MCP 方式:
Use SN-Create-Record on sys_pd_lane:
- playbook: "<playbook_sys_id>"
- name: "Agent Lane"
- lane_type: "agent"
- order: 100
- description: "Primary agent activities"
Use SN-Create-Record on sys_pd_lane:
- playbook: "<playbook_sys_id>"
- name: "System Lane"
- lane_type: "system"
- order: 200
- description: "Automated background processing"
REST 方式:
POST /api/now/table/sys_pd_lane
Body: {
"playbook": "<playbook_sys_id>",
"name": "Agent Lane",
"lane_type": "agent",
"order": 100,
"description": "Primary agent activities"
}
第 6 步:添加活动
活动是手册中的各个步骤。
常见活动类型:
| 活动类型 | 值 | 说明 |
|---|---|---|
| 数据收集 | data_gathering | 从用户或 Agent 收集信息 |
| 决策 | decision | 根据条件进行分支 |
| 审批 | approval | 向用户请求审批 |
| 通知 | notification | 发送电子邮件或推送通知 |
| 子流程 | subflow | 执行流程设计器子流程 |
| 更新记录 | update_record | 修改手册上下文记录 |
| 等待 | wait | 暂停,直到满足条件 |
| 完成阶段 | complete_stage | 将阶段标记为已完成 |
数据收集活动(面向 Agent):
MCP 方式:
Use SN-Create-Record on sys_pd_activity:
- playbook: "<playbook_sys_id>"
- lane: "<agent_lane_sys_id>"
- stage: "<triage_stage_sys_id>"
- name: "Gather Incident Details"
- activity_type: "data_gathering"
- order: 100
- mandatory: true
- description: "Collect key incident information from the caller"
决策活动:
Use SN-Create-Record on sys_pd_activity:
- playbook: "<playbook_sys_id>"
- lane: "<system_lane_sys_id>"
- stage: "<triage_stage_sys_id>"
- name: "Check Priority Level"
- activity_type: "decision"
- order: 200
- condition: "current.priority <= 2"
- description: "Route based on incident priority"
审批活动:
Use SN-Create-Record on sys_pd_activity:
- playbook: "<playbook_sys_id>"
- lane: "<approval_lane_sys_id>"
- stage: "<investigation_stage_sys_id>"
- name: "Manager Approval"
- activity_type: "approval"
- order: 300
- approval_type: "approve_reject"
- approvers: "current.assignment_group.manager"
- due_date_interval: "2 days"
步骤 7:配置活动的数据输入
数据输入定义了在信息收集活动中要收集哪些信息。
MCP 方式:
Use SN-Create-Record on sys_pd_data_input:
- activity: "<data_gathering_activity_sys_id>"
- name: "affected_ci"
- label: "Affected Configuration Item"
- type: "reference"
- reference_table: "cmdb_ci"
- mandatory: true
- order: 100
- help_text: "Select the CI experiencing the issue"
Use SN-Create-Record on sys_pd_data_input:
- activity: "<data_gathering_activity_sys_id>"
- name: "impact_description"
- label: "Business Impact"
- type: "string"
- mandatory: true
- order: 200
- help_text: "Describe how this incident impacts business operations"
Use SN-Create-Record on sys_pd_data_input:
- activity: "<data_gathering_activity_sys_id>"
- name: "users_affected"
- label: "Number of Users Affected"
- type: "integer"
- mandatory: false
- order: 300
REST 方式:
POST /api/now/table/sys_pd_data_input
Body: {
"activity": "<data_gathering_activity_sys_id>",
"name": "affected_ci",
"label": "Affected Configuration Item",
"type": "reference",
"reference_table": "cmdb_ci",
"mandatory": true,
"order": 100
}
步骤 8:定义活动之间的转换
转换用于控制活动之间的流程,包括条件路由。
MCP 方式:
Use SN-Create-Record on sys_pd_transition:
- playbook: "<playbook_sys_id>"
- source_activity: "<activity_1_sys_id>"
- target_activity: "<activity_2_sys_id>"
- condition: ""
- order: 100
- label: "Proceed to investigation"
条件转换(来自决策):
Use SN-Create-Record on sys_pd_transition:
- playbook: "<playbook_sys_id>"
- source_activity: "<decision_activity_sys_id>"
- target_activity: "<high_priority_activity_sys_id>"
- condition: "result == 'yes'"
- order: 100
- label: "High Priority Path"
Use SN-Create-Record on sys_pd_transition:
- playbook: "<playbook_sys_id>"
- source_activity: "<decision_activity_sys_id>"
- target_activity: "<standard_activity_sys_id>"
- condition: "result == 'no'"
- order: 200
- label: "Standard Priority Path"
步骤 9:设置 Playbook 上下文
Playbook 上下文会将 Playbook 关联到运行时执行数据。
MCP 方式:
Use SN-Query-Table on sys_pd_context:
- query: playbook=<playbook_sys_id>
- fields: sys_id,state,started_by,record,stage
- limit: 10
验证 Playbook 触发器配置:
Use SN-Query-Table on sys_pd_playbook:
- query: sys_id=<playbook_sys_id>
- fields: trigger_type,trigger_condition,table,auto_start
步骤 10:激活并测试 Playbook
MCP 方式:
Use SN-Update-Record on sys_pd_playbook:
- sys_id: "<playbook_sys_id>"
- status: "published"
- active: true
验证 Playbook 是否已准备就绪:
Use SN-Query-Table on sys_pd_playbook:
- query: sys_id=<playbook_sys_id>
- fields: sys_id,name,status,active,table
工具用法
| 工具 | 用途 | 使用时机 |
|---|---|---|
| SN-Query-Table | 查找现有 Playbook 和活动 | 发现模式并进行验证 |
| SN-Create-Record | 创建 Playbook、阶段、泳道和活动 | 构建新的 Playbook 组件 |
| SN-Update-Record | 修改 Playbook 设置、激活 Playbook | 编辑和发布 |
| SN-Get-Table-Schema | 发现 Playbook 表字段 | 了解可用的配置选项 |
最佳实践
- 始终以草稿状态创建 Playbook ——切勿直接发布未经测试的 Playbook
- 使用能清晰描述阶段的名称,体现业务流程阶段,而非技术步骤
- 将 Agent 活动和系统活动分别放在专用泳道中,以便清晰区分
- 仅在后续步骤确实需要相关信息时,才将数据收集字段设为必填
- 为数据输入添加帮助文本,以便 Agent 了解要收集哪些信息
- 使用决策活动代替复杂的条件转换,以提高可读性
- 大多数 Playbook 的阶段数应限制在 3–5 个,避免 Agent 困惑
- 激活前使用符合触发条件的示例记录进行测试
- 为审批活动设置适当的截止日期,防止流程停滞
- 通过 sys_pd_context 监控 Playbook 执行情况,以便分析运行时数据并识别瓶颈
故障排除
| 问题 | 原因 | 解决方法 |
|---|---|---|
| Playbook 未启动 | 触发条件不匹配或 Playbook 未激活 | 验证 sys_pd_playbook.active=true,且 trigger_condition 与记录匹配 |
| 活动停留在待处理状态 | 缺少必填数据输入或转换中断 | 检查 sys_pd_data_input 必填字段和 sys_pd_transition 链接 |
| 数据收集表单为空 | 活动未关联任何数据输入 | 创建引用该活动的 sys_pd_data_input 记录 |
| 泳道不可见 | 泳道未分配任何活动 | 至少向泳道添加一个活动 |
| 阶段推进受阻 | 上一阶段的活动尚未完成 | 验证当前阶段中的所有必填活动均已完成 |
| Playbook 多次运行 | 触发器未设置重复执行防护 | 添加条件,排除具有活动 Playbook 上下文的记录 |
| 审批未路由 | 审批人引用无法解析 | 验证审批人字段能解析为具有审批角色的活动用户 |
示例
示例 1:面向 Agent 的事件分诊 Playbook
为处理网络事件的 Agent 生成交互式 Playbook:
- 触发器: 在
incident上创建记录,且满足category=network^priority<=2 - 阶段: 分诊、调查、解决
- 泳道 1(Agent): 收集 CI 详情、记录业务影响、记录故障排查步骤
- 泳道 2(系统): 自动查找相关 CI、发送通知、更新事件字段
- 数据收集: 受影响的 CI(引用 cmdb_ci)、影响描述(字符串)、受影响用户数(整数)
- 决策: 如果
users_affected > 100,则升级至重大事件处理流程
示例 2:客户入驻手册
为客户成功经理(CSM)客户入驻生成标准手册:
- 触发条件: 在
sn_csm_case上创建记录,且case_type=onboarding - 阶段: 欢迎、配置、培训、正式上线
- 泳道 1(Agent): 收集客户需求,分配资源
- 泳道 2(系统): 配置账户、配置集成、发送欢迎邮件
- 泳道 3(客户): 填写信息收集表,安排培训课程
- 转换: 阶段按顺序推进,各泳道并行执行
示例 3:变更请求风险评估手册
生成用于评估变更请求风险的手册:
- 触发条件: 更新
change_request上的记录,且state=assess - 阶段: 风险评估、审批、排期
- 泳道 1(Agent): 填写风险问卷,记录回滚计划
- 泳道 2(审批): 如果
risk=high,则转交 CAB;如果为中等风险,则转交经理 - 数据收集: 风险评分(整数)、回滚计划(多行文本)、停机时间估算(时长)
- 决策: 根据计算出的风险评分,分流至相应的审批路径
相关技能
genai/flow-generation- 用于非交互式自动化的 Flow Designer 流genai/spoke-generation- 用于外部连接的 Integration Hub spokegenai/skill-kit-custom- 可触发手册的自定义 Now Assist 技能catalog/approval-workflows- 特定于目录的审批配置itsm/incident-lifecycle- 事件表结构和字段