service-de-channel-routing-configure
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConfiguring Channel Routing
配置通道路由
What this skill does
本技能的作用
Ensures a has valid routing configured before activation. The channel's field is a polymorphic foreign key (verified against , ) — it names who the channel routes incoming sessions to. Some targets additionally require a (an Omni-Channel Queue that catches sessions the primary target can't take).
MessagingChannelSessionHandlerMessagingChannel.entity.xmldomain="Queue, FlowDefinition, User, BotDefinition, AgenticCtxtDecorDefinition"FallbackQueueThese skills create Enhanced channels (, SCRT2). All five SessionHandler domains are writable on Enhanced channels. (A Standard/SCRT1 channel would only accept a Flow as SessionHandler — the server rejects any other domain with "Only flows of type Omni-Channel are supported". These skills never create Standard channels, so that path isn't handled here.)
PlatformType=EnhancedWhere this fits: the channel is inserted by (or a per-type leaf); this skill sets routing; sets consent; then flips it live — activation requires both routing and consent. The orchestrator runs all four in sequence.
service-de-channel-createservice-de-channel-consent-configureservice-de-channel-activateservice-de-headless-channel-configureSupported routing types — all set , some also set :
SessionHandlerIdFallbackQueueId| Type | SessionHandler target | Id prefix | FallbackQueue |
|---|---|---|---|
| Omni-Channel Queue | | | must be null |
| Omni-Flow | | | required |
| Agentforce Service Agent (ASA) | | | required |
| Digital Worker | | | required |
| User | | | must be null |
Provisioning behavior:
- Queue — pick an existing -capable Queue, or create a new Queue + QueueRoutingConfig via Metadata API.
MessagingSession - Flow / ASA / Digital Worker / User — locate an existing eligible target and PATCH it. These skills do not create Flows, bots, digital workers, or users — if none eligible exist, the skill reports the precondition and points the user at Setup.
确保在激活前已配置有效的路由。通道的字段是一个多态外键(已通过验证,)——它指定了通道将传入会话路由到的目标对象。部分目标还需要设置(一个Omni-Channel队列,用于接收主目标无法处理的会话)。
MessagingChannelSessionHandlerMessagingChannel.entity.xmldomain="Queue, FlowDefinition, User, BotDefinition, AgenticCtxtDecorDefinition"FallbackQueue这些技能创建的是Enhanced通道(,SCRT2)。所有五种SessionHandler域都可在Enhanced通道上写入。(Standard/SCRT1通道仅接受Flow作为SessionHandler——服务器会拒绝其他域,返回错误信息“Only flows of type Omni-Channel are supported”。本技能从不创建Standard通道,因此无需处理该场景。)
PlatformType=Enhanced适用场景:通道由(或特定类型的分支技能)创建;本技能负责设置路由;负责设置授权;随后将通道激活——激活操作需要同时配置路由和授权。编排器会按顺序执行这四个步骤。
service-de-channel-createservice-de-channel-consent-configureservice-de-channel-activateservice-de-headless-channel-configure支持的路由类型——所有类型都会设置,部分类型还会设置:
SessionHandlerIdFallbackQueueId| 类型 | SessionHandler目标 | ID前缀 | FallbackQueue |
|---|---|---|---|
| Omni-Channel Queue | | | 必须为null |
| Omni-Flow | | | 必填 |
| Agentforce Service Agent (ASA) | | | 必填 |
| Digital Worker | | | 必填 |
| User | | | 必须为null |
配置行为:
- Queue——选择现有的支持的队列,或通过Metadata API创建新的Queue + QueueRoutingConfig。
MessagingSession - Flow / ASA / Digital Worker / User——定位现有的符合条件的目标并执行PATCH操作。本技能不会创建Flow、机器人、数字工作者或用户——如果没有符合条件的目标,技能会报告前置条件未满足,并指引用户前往Setup页面创建。
Reference File Index
参考文件索引
| Reference file | Load when |
|---|---|
| The user picked "create a new queue" on the Queue routing path — full Metadata API scaffold → deploy → ID lookup → optional member add. |
| You need the per-domain SOQL to locate and validate an eligible target (Queue, Flow, ASA, Digital Worker, User) and the FallbackQueue requirement matrix. |
| The user picked ASA (Agentforce Service Agent) routing — precondition check, enumerating live ASAs, and selection. |
| Troubleshooting an unexpected result, or before modifying this skill — the known gotchas. |
| You want a reference run of the reuse-existing-queue, create-new-queue, Flow, or ASA paths. |
| 参考文件 | 加载时机 |
|---|---|
| 用户在Queue路由路径中选择“创建新队列”时——完整的Metadata API脚手架→部署→ID查找→可选成员添加流程。 |
| 需要按域执行SOQL来定位并验证符合条件的目标(Queue、Flow、ASA、Digital Worker、User),以及查看FallbackQueue要求矩阵时。 |
| 用户选择ASA(Agentforce Service Agent)路由时——前置条件检查、枚举可用ASA、选择ASA。 |
| 排查意外结果,或修改本技能之前——查看已知的问题点。 |
| 需要参考复用现有队列、创建新队列、Flow或ASA路径的实际运行示例时。 |
When NOT to use this skill
不适用本技能的场景
- The channel already has or
SessionHandlerIdset. This skill no-ops and tells you — nothing to do. Proceed to activation.FallbackQueueId - The channel doesn't exist yet. Run the insertion skill first; this skill expects a real .
MessagingChannel.Id - You want to replace existing routing. Safer to clear manually in the UI, then re-run this skill. The no-op check is a guardrail, not a limitation worth bypassing automatically.
SessionHandlerId
- 通道已设置或
SessionHandlerId。本技能会直接返回不操作提示——无需执行任何操作。直接进入激活步骤即可。FallbackQueueId - 通道尚未创建。请先运行插入技能;本技能需要一个真实的。
MessagingChannel.Id - 需要替换现有路由。建议先在UI中手动清除,然后重新运行本技能。不操作检查是一个防护机制,不建议自动绕过。
SessionHandlerId
Inputs (from caller)
输入参数(来自调用方)
- — a 15- or 18-char
{CHANNEL_ID}(prefixMessagingChannel.Id). The channel must already exist.0Mj - — optional; the
{ORG_ALIAS}CLI target-org alias. Default: whateversfreturns. All SOQL, PATCH, and Metadata deploys run against this org.sf config get target-org
- ——15或18位的
{CHANNEL_ID}(前缀为MessagingChannel.Id)。通道必须已存在。0Mj - ——可选;
{ORG_ALIAS}CLI的目标组织别名。默认值:sf返回的结果。所有SOQL、PATCH和Metadata部署操作都针对该组织执行。sf config get target-org
Output (to caller)
输出结果(返回给调用方)
One of:
Success — no change needed:
json
{"ok": true, "noop": true, "routingType": "queue|flow|asa|digital_worker|user", "sessionHandlerId": "00G...|300...|0Xx...|1iE...|005...", "fallbackQueueId": "00G...|null", "targetName": "...", "message": "Routing already configured"}Success — Queue routing configured:
json
{"ok": true, "routingType": "queue", "sessionHandlerId": "00G...", "fallbackQueueId": null, "queueName": "...", "queueDeveloperName": "...", "created": true|false}Success — Flow routing configured:
json
{"ok": true, "routingType": "flow", "sessionHandlerId": "300...", "fallbackQueueId": "00G...", "flowName": "...", "flowDeveloperName": "...", "created": false}Success — ASA routing configured:
json
{"ok": true, "routingType": "asa", "sessionHandlerId": "0Xx...", "fallbackQueueId": "00G...", "asaName": "...", "asaDeveloperName": "...", "botUserId": "005...", "botVersionId": "0X9...", "created": false}Success — Digital Worker routing configured:
json
{"ok": true, "routingType": "digital_worker", "sessionHandlerId": "1iE...", "fallbackQueueId": "00G...", "workerName": "...", "created": false}Success — User routing configured:
json
{"ok": true, "routingType": "user", "sessionHandlerId": "005...", "fallbackQueueId": null, "userName": "...", "created": false}Precondition not met:
json
{"ok": false, "kind": "no-eligible-target", "routingType": "flow|asa|digital_worker|user", "hint": "no eligible <target> found on this org — <how to create one in Setup>, then re-run this skill"}
{"ok": false, "kind": "no-fallback-queue", "hint": "Flow/ASA/Digital Worker routing requires a FallbackQueue but no MessagingSession-capable queue exists — create one (Queue routing path) first"}
{"ok": false, "kind": "asa-not-supported", "hint": "this org doesn't have BotDefinition (Agentforce not licensed); use Queue routing instead"}
{"ok": false, "kind": "standard-channel", "hint": "this is a Standard (SCRT1) channel — only Flow routing is supported; these skills only create Enhanced channels, so this is unexpected"}Failure:
json
{"ok": false, "kind": "metadata-deploy-failed", "message": "..."}
{"ok": false, "kind": "patch-failed", "message": "..."}
{"ok": false, "kind": "verify-failed", "hint": "PATCH returned success but re-read shows SessionHandlerId still null — permission or trigger issue"}The PATCH failure often carries the server-side validation error verbatim (from ). Surface it — it tells the user exactly which linking rule failed. Common ones: / / (FallbackQueue required but null), (FallbackQueue set on a Queue/User path where it must be null), (Flow isn't ProcessType=RoutingFlow, or the channel is Standard/SCRT1), (User has no RoutingConfiguration).
messageMessagingChannelFunctionsHelper.validateSessionHandlerMissingFallbackQueueForFlowRouting...ForAsaRouting...ForDigitalWorkerRoutingUnsupportedFallbackQueueInvalidSessionHandlerFlowTypeNoRoutingConfigDefined以下结果之一:
成功——无需修改:
json
{"ok": true, "noop": true, "routingType": "queue|flow|asa|digital_worker|user", "sessionHandlerId": "00G...|300...|0Xx...|1iE...|005...", "fallbackQueueId": "00G...|null", "targetName": "...", "message": "Routing already configured"}成功——已配置Queue路由:
json
{"ok": true, "routingType": "queue", "sessionHandlerId": "00G...", "fallbackQueueId": null, "queueName": "...", "queueDeveloperName": "...", "created": true|false}成功——已配置Flow路由:
json
{"ok": true, "routingType": "flow", "sessionHandlerId": "300...", "fallbackQueueId": "00G...", "flowName": "...", "flowDeveloperName": "...", "created": false}成功——已配置ASA路由:
json
{"ok": true, "routingType": "asa", "sessionHandlerId": "0Xx...", "fallbackQueueId": "00G...", "asaName": "...", "asaDeveloperName": "...", "botUserId": "005...", "botVersionId": "0X9...", "created": false}成功——已配置Digital Worker路由:
json
{"ok": true, "routingType": "digital_worker", "sessionHandlerId": "1iE...", "fallbackQueueId": "00G...", "workerName": "...", "created": false}成功——已配置User路由:
json
{"ok": true, "routingType": "user", "sessionHandlerId": "005...", "fallbackQueueId": null, "userName": "...", "created": false}前置条件未满足:
json
{"ok": false, "kind": "no-eligible-target", "routingType": "flow|asa|digital_worker|user", "hint": "no eligible <target> found on this org — <how to create one in Setup>, then re-run this skill"}
{"ok": false, "kind": "no-fallback-queue", "hint": "Flow/ASA/Digital Worker routing requires a FallbackQueue but no MessagingSession-capable queue exists — create one (Queue routing path) first"}
{"ok": false, "kind": "asa-not-supported", "hint": "this org doesn't have BotDefinition (Agentforce not licensed); use Queue routing instead"}
{"ok": false, "kind": "standard-channel", "hint": "this is a Standard (SCRT1) channel — only Flow routing is supported; these skills only create Enhanced channels, so this is unexpected"}失败:
json
{"ok": false, "kind": "metadata-deploy-failed", "message": "..."}
{"ok": false, "kind": "patch-failed", "message": "..."}
{"ok": false, "kind": "verify-failed", "hint": "PATCH returned success but re-read shows SessionHandlerId still null — permission or trigger issue"}PATCH失败的通常会直接携带服务器端的验证错误信息(来自)。请直接展示该信息——它会准确告知用户哪条链接规则未通过。常见错误包括: / / (需要FallbackQueue但未设置)、(在Queue/User路径中设置了FallbackQueue,而该路径要求必须为null)、(Flow不是ProcessType=RoutingFlow,或者通道是Standard/SCRT1类型)、(User未配置RoutingConfiguration)。
messageMessagingChannelFunctionsHelper.validateSessionHandlerMissingFallbackQueueForFlowRouting...ForAsaRouting...ForDigitalWorkerRoutingUnsupportedFallbackQueueInvalidSessionHandlerFlowTypeNoRoutingConfigDefinedStage 1: Read current routing state
阶段1:读取当前路由状态
Query the channel. If it already has OR , no-op. Otherwise, continue.
SessionHandlerIdFallbackQueueIdbash
sf data query --target-org '{ORG_ALIAS}' \
--query "SELECT Id, DeveloperName, SessionHandlerId, FallbackQueueId FROM MessagingChannel WHERE Id = '{CHANNEL_ID}'" \
--json > /tmp/ccr-channel.jsonParse with or . If the record is missing — halt with
node -ejqError: Channel {CHANNEL_ID} not found — check the id, or run the insertion skill first.If is non-null, branch on the Id prefix to figure out what the existing routing target is, then no-op with the right envelope. The prefix maps 1:1 to the SessionHandler domain (verified against ):
SessionHandlerIdMessagingChannel.entity.xml| Prefix | Domain / Target | Lookup query | routingType |
|---|---|---|---|
| | | |
| | | |
| | | |
| | | |
| | | |
bash
SESSION_HANDLER_ID="$(node -e 'console.log(JSON.parse(require("fs").readFileSync("/tmp/ccr-channel.json","utf8")).result.records[0].SessionHandlerId)')"
PREFIX="${SESSION_HANDLER_ID:0:3}"
case "$PREFIX" in
00G) sf data query --target-org '{ORG_ALIAS}' --query "SELECT Id, Name, DeveloperName FROM Group WHERE Id = '$SESSION_HANDLER_ID' AND Type = 'Queue'" --json > /tmp/ccr-noop-target.json ;;
300) sf data query --target-org '{ORG_ALIAS}' --query "SELECT DurableId, Label, ApiName FROM FlowDefinitionView WHERE DurableId = '$SESSION_HANDLER_ID'" --json > /tmp/ccr-noop-target.json ;;
0Xx) sf data query --target-org '{ORG_ALIAS}' --query "SELECT Id, DeveloperName, MasterLabel, AgentType FROM BotDefinition WHERE Id = '$SESSION_HANDLER_ID'" --json > /tmp/ccr-noop-target.json ;;
1iE) sf data query --target-org '{ORG_ALIAS}' --query "SELECT Id, DeveloperName, MasterLabel FROM AgenticCtxtDecorDefinition WHERE Id = '$SESSION_HANDLER_ID'" --json > /tmp/ccr-noop-target.json ;;
005) sf data query --target-org '{ORG_ALIAS}' --query "SELECT Id, Name FROM User WHERE Id = '$SESSION_HANDLER_ID'" --json > /tmp/ccr-noop-target.json ;;
*) echo "{\"records\":[{\"Id\":\"$SESSION_HANDLER_ID\"}]}" > /tmp/ccr-noop-target.json ;;
esacReport the success-noop envelope (include the existing from the Stage 1 read) and return.
FallbackQueueIdIf is non-null but is null — still no-op. That's a partially-configured Flow/ASA state; don't touch it, but flag it in the envelope () since activation will still fail readiness without a SessionHandler.
FallbackQueueIdSessionHandlerIdmessage"FallbackQueue set but SessionHandler null — incomplete routing, review in Setup"查询通道信息。如果通道已设置或,则不执行任何操作。否则,继续后续步骤。
SessionHandlerIdFallbackQueueIdbash
sf data query --target-org '{ORG_ALIAS}' \
--query "SELECT Id, DeveloperName, SessionHandlerId, FallbackQueueId FROM MessagingChannel WHERE Id = '{CHANNEL_ID}'" \
--json > /tmp/ccr-channel.json使用或解析结果。如果未找到记录——终止并返回错误信息:
node -ejqError: Channel {CHANNEL_ID} not found — check the id, or run the insertion skill first.如果不为空,根据ID前缀判断现有路由目标类型,然后返回对应的不操作信封。前缀与SessionHandler域一一对应(已通过验证):
SessionHandlerIdMessagingChannel.entity.xml| 前缀 | 域 / 目标 | 查询语句 | routingType |
|---|---|---|---|
| | | |
| | | |
| | | |
| | | |
| | | |
bash
SESSION_HANDLER_ID="$(node -e 'console.log(JSON.parse(require("fs").readFileSync("/tmp/ccr-channel.json","utf8")).result.records[0].SessionHandlerId)')"
PREFIX="${SESSION_HANDLER_ID:0:3}"
case "$PREFIX" in
00G) sf data query --target-org '{ORG_ALIAS}' --query "SELECT Id, Name, DeveloperName FROM Group WHERE Id = '$SESSION_HANDLER_ID' AND Type = 'Queue'" --json > /tmp/ccr-noop-target.json ;;
300) sf data query --target-org '{ORG_ALIAS}' --query "SELECT DurableId, Label, ApiName FROM FlowDefinitionView WHERE DurableId = '$SESSION_HANDLER_ID'" --json > /tmp/ccr-noop-target.json ;;
0Xx) sf data query --target-org '{ORG_ALIAS}' --query "SELECT Id, DeveloperName, MasterLabel, AgentType FROM BotDefinition WHERE Id = '$SESSION_HANDLER_ID'" --json > /tmp/ccr-noop-target.json ;;
1iE) sf data query --target-org '{ORG_ALIAS}' --query "SELECT Id, DeveloperName, MasterLabel FROM AgenticCtxtDecorDefinition WHERE Id = '$SESSION_HANDLER_ID'" --json > /tmp/ccr-noop-target.json ;;
005) sf data query --target-org '{ORG_ALIAS}' --query "SELECT Id, Name FROM User WHERE Id = '$SESSION_HANDLER_ID'" --json > /tmp/ccr-noop-target.json ;;
*) echo "{\"records\":[{\"Id\":\"$SESSION_HANDLER_ID\"}]}" > /tmp/ccr-noop-target.json ;;
esac返回成功-不操作信封(包含阶段1读取到的现有)并结束。
FallbackQueueId如果不为空但为空——仍执行不操作。这是一种Flow/ASA的部分配置状态;请勿修改,但需在信封的中标记(),因为如果没有SessionHandler,激活操作仍会因未就绪而失败。
FallbackQueueIdSessionHandlerIdmessage"FallbackQueue set but SessionHandler null — incomplete routing, review in Setup"Stage 2: Confirm the channel is Enhanced, then choose routing type
阶段2:确认通道为Enhanced类型,然后选择路由类型
First confirm . The Stage 1 read didn't include it — add it, or re-query:
PlatformTypebash
sf data query --target-org '{ORG_ALIAS}' \
--query "SELECT Id, PlatformType FROM MessagingChannel WHERE Id = '{CHANNEL_ID}'" --json > /tmp/ccr-platform.jsonIf (i.e. Standard/SCRT1), only Flow routing is writable. These skills only create Enhanced channels, so a Standard channel here is unexpected — emit and stop rather than guessing.
PlatformType != 'Enhanced'{ok:false, kind:"standard-channel", ...}Then ask the user (via a prompt — do NOT auto-pick):
text
The MessagingChannel '{developerName}' ({CHANNEL_ID}) has no routing configured.
Which routing type do you want?
1) queue — Omni-Channel queue routing
2) flow — Omni-Flow (RoutingFlow) + fallback queue
3) asa — Agentforce Service Agent (requires Agentforce license) + fallback queue
4) digital_worker — Digital Worker (Agentic) + fallback queue
5) user — Direct to a specific user (requires a RoutingConfiguration on the user)
Pick [1-5]:Branch on the user's pick. For every non-queue path, load — it holds the per-domain locate SOQL, eligibility filters, FallbackQueue rules, and exact PATCH shape:
references/target-locate.md- 1 (queue) — continue to Stage 3-Queue below.
- 2 (flow) — locate an eligible (ProcessType=RoutingFlow, active version) + a FallbackQueue, then Stage 5.
FlowDefinition - 3 (asa) — continue to Stage 3-ASA; ASA requires a FallbackQueue too.
- 4 (digital_worker) — locate an eligible + a FallbackQueue, then Stage 5.
AgenticCtxtDecorDefinition - 5 (user) — locate a that has a RoutingConfiguration, then Stage 5.
User
If a path finds no eligible target, emit (see for the per-domain Setup pointer) and return — do not fabricate an id.
{ok:false, kind:"no-eligible-target", routingType, hint}references/target-locate.md首先确认。阶段1的查询未包含该字段——需添加该字段重新查询:
PlatformTypebash
sf data query --target-org '{ORG_ALIAS}' \
--query "SELECT Id, PlatformType FROM MessagingChannel WHERE Id = '{CHANNEL_ID}'" --json > /tmp/ccr-platform.json如果(即Standard/SCRT1),则仅支持Flow路由写入。本技能仅创建Enhanced通道,因此出现Standard通道属于意外情况——返回并终止,而非尝试猜测处理。
PlatformType != 'Enhanced'{ok:false, kind:"standard-channel", ...}然后提示用户选择(需手动选择,请勿自动选择):
text
The MessagingChannel '{developerName}' ({CHANNEL_ID}) has no routing configured.
Which routing type do you want?
1) queue — Omni-Channel queue routing
2) flow — Omni-Flow (RoutingFlow) + fallback queue
3) asa — Agentforce Service Agent (requires Agentforce license) + fallback queue
4) digital_worker — Digital Worker (Agentic) + fallback queue
5) user — Direct to a specific user (requires a RoutingConfiguration on the user)
Pick [1-5]:根据用户的选择分支处理。对于所有非Queue路径,加载——该文件包含按域定位的SOQL、 eligibility过滤器、FallbackQueue规则和精确的PATCH格式:
references/target-locate.md- 1(queue)——继续执行下方的阶段3-Queue。
- 2(flow)——定位符合条件的(ProcessType=RoutingFlow,版本处于激活状态)+ 一个FallbackQueue,然后进入阶段5。
FlowDefinition - 3(asa)——继续执行阶段3-ASA;ASA也需要FallbackQueue。
- 4(digital_worker)——定位符合条件的+ 一个FallbackQueue,然后进入阶段5。
AgenticCtxtDecorDefinition - 5(user)——定位带有RoutingConfiguration的,然后进入阶段5。
User
如果某路径未找到符合条件的目标,返回(参考中的域特定Setup指引)并终止——请勿伪造ID。
{ok:false, kind:"no-eligible-target", routingType, hint}references/target-locate.mdStage 3-Queue: Pick an existing queue, or create a new one
阶段3-Queue:选择现有队列,或创建新队列
(This stage runs only on the Queue path. ASA path: see Stage 3-ASA below.)
Enumerate eligible queues. The UI's routing dropdown () lists Groups where — i.e. Omni-Channel-enabled queues. For a MessagingChannel we additionally want the queue to accept . Query the intersection: enumerate MessagingSession-capable queues, then keep only those with a QueueRoutingConfig.
MessagingRoutingMethodDataProviderController.getOmniQueuesQueueRoutingConfigId != nullMessagingSessionbash
undefined(本阶段仅在Queue路径中执行。ASA路径:请查看下方的阶段3-ASA。)
枚举符合条件的队列。UI中的路由下拉菜单()列出了的Group——即启用Omni-Channel的队列。对于MessagingChannel,我们还需要队列支持。查询两者的交集:枚举支持MessagingSession的队列,然后仅保留带有QueueRoutingConfig的队列。
MessagingRoutingMethodDataProviderController.getOmniQueuesQueueRoutingConfigId != nullMessagingSessionbash
undefinedMessagingSession-capable queues that are also Omni-enabled (QueueRoutingConfigId != null)
支持MessagingSession且已启用Omni的队列(QueueRoutingConfigId != null)
sf data query --target-org '{ORG_ALIAS}'
--query "SELECT Id, Name, DeveloperName FROM Group WHERE Type = 'Queue' AND QueueRoutingConfigId != null AND Id IN (SELECT QueueId FROM QueueSobject WHERE SobjectType = 'MessagingSession') ORDER BY Name"
--json > /tmp/ccr-queues.json
--query "SELECT Id, Name, DeveloperName FROM Group WHERE Type = 'Queue' AND QueueRoutingConfigId != null AND Id IN (SELECT QueueId FROM QueueSobject WHERE SobjectType = 'MessagingSession') ORDER BY Name"
--json > /tmp/ccr-queues.json
Each row's `Id` is the `00G` `Group.Id` — that is what gets written to `SessionHandlerId`. (If the semi-join subquery errors on an org, fall back to two queries: list `QueueSobject WHERE SobjectType='MessagingSession'`, then filter to those whose `Group.QueueRoutingConfigId != null`.)
Present the user with a numbered list plus a final "create new" option:
```text
Omni-enabled MessagingSession queues on {ORG_ALIAS}:
1) Messaging Queue (Messaging_Queue) — 00GSG0000000LSf2AM
2) MyQueue (MyQueue) — 00GSG000000144n2AA
...
N) Create a new queue
Pick [1-N]:- If the user picks an existing queue: record its as
Id(this is the{QUEUE_ID}). Skip to Stage 5.Group.Id - If the user picks "create new": go to Stage 4.
If the list is empty AND the user picks (1) "Create a new queue" implicitly, skip directly to Stage 4.
sf data query --target-org '{ORG_ALIAS}'
--query "SELECT Id, Name, DeveloperName FROM Group WHERE Type = 'Queue' AND QueueRoutingConfigId != null AND Id IN (SELECT QueueId FROM QueueSobject WHERE SobjectType = 'MessagingSession') ORDER BY Name"
--json > /tmp/ccr-queues.json
--query "SELECT Id, Name, DeveloperName FROM Group WHERE Type = 'Queue' AND QueueRoutingConfigId != null AND Id IN (SELECT QueueId FROM QueueSobject WHERE SobjectType = 'MessagingSession') ORDER BY Name"
--json > /tmp/ccr-queues.json
每行的`Id`是`00G`格式的`Group.Id`——该ID将被写入`SessionHandlerId`。(如果半连接子查询在某些组织中报错,可退化为两次查询:先列出`QueueSobject WHERE SobjectType='MessagingSession'`,然后筛选出`Group.QueueRoutingConfigId != null`的队列。)
向用户展示编号列表,最后添加“创建新队列”选项:
```text
Omni-enabled MessagingSession queues on {ORG_ALIAS}:
1) Messaging Queue (Messaging_Queue) — 00GSG0000000LSf2AM
2) MyQueue (MyQueue) — 00GSG000000144n2AA
...
N) Create a new queue
Pick [1-N]:- 如果用户选择现有队列:记录其为
Id(即{QUEUE_ID})。跳至阶段5。Group.Id - 如果用户选择“创建新队列”:进入阶段4。
如果列表为空,用户默认选择(1)“创建新队列”,则直接跳至阶段4。
Stage 3-Queue, continued: Create a new Queue via Metadata API
阶段3-Queue续:通过Metadata API创建新队列
(Continuation of the Queue path. Skip if the user picked an existing queue above.)
We deploy a Queue + QueueRoutingConfig pair using a minimal scratch sfdx project (the pattern), then look up the new Queue's Id and optionally add the current user as a member.
help-agent-acceleratorTo create a new Queue via the Metadata API (sfdx project scaffold → deploy → ID lookup → optional member add), load and follow it — it is the complete guide for this flow.
references/queue-creation.mdAfter that stage, jump to Stage 5 (PATCH).
(Queue路径的延续。如果用户选择了现有队列,请跳过本阶段。)
我们使用最小化的scratch sfdx项目(模式)部署Queue + QueueRoutingConfig组合,然后查找新Queue的Id,并可选地将当前用户添加为成员。
help-agent-accelerator要通过Metadata API创建新队列(sfdx项目脚手架→部署→ID查找→可选成员添加),请加载并按照指引操作——该文件包含完整的流程说明。
references/queue-creation.md完成本阶段后,跳至阶段5(PATCH操作)。
Stage 3-ASA: Pick an existing ASA
阶段3-ASA:选择现有ASA
(This stage runs only on the ASA path. Queue path: skip to Stage 5.)
ASA routing points at an existing, live Agentforce Service Agent (). This skill never creates a new ASA — it verifies the org supports one (Agentforce licensed), enumerates the live/routable ones, and lets the user pick.
SessionHandlerIdBotDefinitionFor ASA precondition checks, enumeration, and selection, load . After selection, continue to Stage 5 (PATCH).
references/asa-routing.md(本阶段仅在ASA路径中执行。Queue路径:跳至阶段5。)
ASA路由将指向现有的、已激活的Agentforce Service Agent()。本技能从不创建新的ASA——它会验证组织是否支持ASA(已授权Agentforce),枚举可用的/可路由的ASA,让用户选择。
SessionHandlerIdBotDefinition关于ASA的前置条件检查、枚举和选择,请加载。 选择完成后,继续执行阶段5(PATCH操作)。
references/asa-routing.mdStage 5: PATCH MessagingChannel.SessionHandlerId
(+ FallbackQueueId
)
MessagingChannel.SessionHandlerIdFallbackQueueId阶段5:PATCH MessagingChannel.SessionHandlerId
(+ FallbackQueueId
)
MessagingChannel.SessionHandlerIdFallbackQueueIdBy this point we have a routing target id in and know its :
{TARGET_ID}{ROUTING_TYPE}| routingType | | FallbackQueue write |
|---|---|---|
| | none (must stay null) |
| | set |
| | set |
| | set |
| | none (must stay null) |
SessionHandler[Group, FlowDefinition, User, BotDefinition, AgenticCtxtDecorDefinition]MessagingChannel.entity.xmlvalidateSessionHandlerFor the FallbackQueue paths, write both fields in one PATCH so the record never passes through an invalid intermediate state:
bash
undefined此时我们已获得形式的路由目标ID,并知晓其:
{TARGET_ID}{ROUTING_TYPE}| routingType | | FallbackQueue写入操作 |
|---|---|---|
| | 无(必须保持为null) |
| | 设置 |
| | 设置 |
| | 设置 |
| | 无(必须保持为null) |
SessionHandler[Group, FlowDefinition, User, BotDefinition, AgenticCtxtDecorDefinition]MessagingChannel.entity.xmlvalidateSessionHandler对于需要FallbackQueue的路径,在一次PATCH操作中同时写入两个字段,确保记录不会处于无效的中间状态:
bash
undefinedqueue / user — SessionHandler only
queue / user — 仅设置SessionHandler
sf data update record --target-org '{ORG_ALIAS}' --sobject MessagingChannel
--record-id '{CHANNEL_ID}'
--values 'SessionHandlerId={TARGET_ID}' --json > /tmp/ccr-patch.json
--record-id '{CHANNEL_ID}'
--values 'SessionHandlerId={TARGET_ID}' --json > /tmp/ccr-patch.json
sf data update record --target-org '{ORG_ALIAS}' --sobject MessagingChannel
--record-id '{CHANNEL_ID}'
--values 'SessionHandlerId={TARGET_ID}' --json > /tmp/ccr-patch.json
--record-id '{CHANNEL_ID}'
--values 'SessionHandlerId={TARGET_ID}' --json > /tmp/ccr-patch.json
flow / asa / digital_worker — SessionHandler + FallbackQueue together
flow / asa / digital_worker — 同时设置SessionHandler + FallbackQueue
sf data update record --target-org '{ORG_ALIAS}' --sobject MessagingChannel
--record-id '{CHANNEL_ID}'
--values 'SessionHandlerId={TARGET_ID} FallbackQueueId={FALLBACK_QUEUE_ID}' --json > /tmp/ccr-patch.json
--record-id '{CHANNEL_ID}'
--values 'SessionHandlerId={TARGET_ID} FallbackQueueId={FALLBACK_QUEUE_ID}' --json > /tmp/ccr-patch.json
If `status !== 0`: emit `{ok:false, kind:"patch-failed", message: ...}` and return. Surface the server message verbatim — it names the exact linking rule that failed (see the failure-envelope note under "Output (to caller)").
---sf data update record --target-org '{ORG_ALIAS}' --sobject MessagingChannel
--record-id '{CHANNEL_ID}'
--values 'SessionHandlerId={TARGET_ID} FallbackQueueId={FALLBACK_QUEUE_ID}' --json > /tmp/ccr-patch.json
--record-id '{CHANNEL_ID}'
--values 'SessionHandlerId={TARGET_ID} FallbackQueueId={FALLBACK_QUEUE_ID}' --json > /tmp/ccr-patch.json
如果`status !== 0`:返回`{ok:false, kind:"patch-failed", message: ...}`并终止。直接展示服务器返回的信息——它会指出未通过的具体链接规则(请参考“输出结果(返回给调用方)”下的失败信封说明)。
---Stage 6: Verify
阶段6:验证
Re-read the channel:
bash
sf data query --target-org '{ORG_ALIAS}' \
--query "SELECT Id, SessionHandlerId, FallbackQueueId FROM MessagingChannel WHERE Id = '{CHANNEL_ID}'" \
--jsonIf the freshly-read doesn't equal — or (for flow/asa/digital_worker) doesn't equal :
SessionHandlerId{TARGET_ID}FallbackQueueId{FALLBACK_QUEUE_ID}json
{"ok": false, "kind": "verify-failed", "hint": "PATCH returned success but re-read shows SessionHandlerId/FallbackQueueId not persisted — check user permissions or field-level security on MessagingChannel"}Otherwise, emit the path-appropriate success envelope (see "Output (to caller)" at the top of this file — one shape per routingType, each carrying ).
fallbackQueueId重新读取通道信息:
bash
sf data query --target-org '{ORG_ALIAS}' \
--query "SELECT Id, SessionHandlerId, FallbackQueueId FROM MessagingChannel WHERE Id = '{CHANNEL_ID}'" \
--json如果重新读取到的不等于——或者(对于flow/asa/digital_worker路径)不等于:
SessionHandlerId{TARGET_ID}FallbackQueueId{FALLBACK_QUEUE_ID}json
{"ok": false, "kind": "verify-failed", "hint": "PATCH returned success but re-read shows SessionHandlerId/FallbackQueueId not persisted — check user permissions or field-level security on MessagingChannel"}否则,返回对应路径的成功信封(请参考本文档顶部的“输出结果(返回给调用方)”——每种routingType对应一种格式,均包含)。
fallbackQueueIdStage 7: Report to caller
阶段7:向调用方报告结果
Report the JSON envelope. If this skill is the leaf (user invoked it directly), render:
Queue path:
Success — Routing configured — channel {CHANNEL_ID} now routes to Queue '{QUEUE_LABEL}' ({QUEUE_ID}).{'' if created else ' (reused existing queue)'}- (no-op path)
Info: Routing already configured — Queue '{name}' ({QUEUE_ID}). No changes.
Flow path:
Success — Routing configured — channel {CHANNEL_ID} now routes to Omni-Flow '{FLOW_LABEL}' ({TARGET_ID}), fallback Queue {FALLBACK_QUEUE_ID}.
ASA path:
Success — Routing configured — channel {CHANNEL_ID} now routes to Agentforce Service Agent '{ASA_LABEL}' ({ASA_ID}), fallback Queue {FALLBACK_QUEUE_ID}. Bot user: {BOT_USER_ID}. Active version: {BOT_VERSION_ID}.- (no-op path)
Info: Routing already configured — ASA '{MasterLabel}' ({ASA_ID}). No changes.
Digital Worker path:
Success — Routing configured — channel {CHANNEL_ID} now routes to Digital Worker '{WORKER_LABEL}' ({TARGET_ID}), fallback Queue {FALLBACK_QUEUE_ID}.
User path:
Success — Routing configured — channel {CHANNEL_ID} now routes directly to User '{USER_NAME}' ({TARGET_ID}).
Failure / precondition:
- (no-eligible-target)
Warning: No eligible {routingType} target found. {per-domain Setup pointer from references/target-locate.md}. Then re-run this skill. - (no-fallback-queue)
Warning: {routingType} routing needs a fallback queue but none exists. Create a MessagingSession queue first (queue path), then re-run. - (asa-not-supported)
Warning: This org doesn't have Agentforce licensed (no BotDefinition entity). Use Queue routing instead. - (standard-channel)
Warning: This is a Standard (SCRT1) channel — only Flow routing is supported. These skills only create Enhanced channels, so this is unexpected; check the channel. - (other failures — the message names the server-side validation rule that failed)
Error: {kind}: {message}
返回JSON信封。如果本技能是直接由用户调用的叶子技能,则展示以下内容:
Queue路径:
Success — Routing configured — channel {CHANNEL_ID} now routes to Queue '{QUEUE_LABEL}' ({QUEUE_ID}).{'' if created else ' (reused existing queue)'}- (不操作路径)
Info: Routing already configured — Queue '{name}' ({QUEUE_ID}). No changes.
Flow路径:
Success — Routing configured — channel {CHANNEL_ID} now routes to Omni-Flow '{FLOW_LABEL}' ({TARGET_ID}), fallback Queue {FALLBACK_QUEUE_ID}.
ASA路径:
Success — Routing configured — channel {CHANNEL_ID} now routes to Agentforce Service Agent '{ASA_LABEL}' ({ASA_ID}), fallback Queue {FALLBACK_QUEUE_ID}. Bot user: {BOT_USER_ID}. Active version: {BOT_VERSION_ID}.- (不操作路径)
Info: Routing already configured — ASA '{MasterLabel}' ({ASA_ID}). No changes.
Digital Worker路径:
Success — Routing configured — channel {CHANNEL_ID} now routes to Digital Worker '{WORKER_LABEL}' ({TARGET_ID}), fallback Queue {FALLBACK_QUEUE_ID}.
User路径:
Success — Routing configured — channel {CHANNEL_ID} now routes directly to User '{USER_NAME}' ({TARGET_ID}).
失败 / 前置条件未满足:
- (no-eligible-target)
Warning: No eligible {routingType} target found. {per-domain Setup pointer from references/target-locate.md}. Then re-run this skill. - (no-fallback-queue)
Warning: {routingType} routing needs a fallback queue but none exists. Create a MessagingSession queue first (queue path), then re-run. - (asa-not-supported)
Warning: This org doesn't have Agentforce licensed (no BotDefinition entity). Use Queue routing instead. - (standard-channel)
Warning: This is a Standard (SCRT1) channel — only Flow routing is supported. These skills only create Enhanced channels, so this is unexpected; check the channel. - (其他失败——message字段会指出未通过的服务器端验证规则)
Error: {kind}: {message}
Worked examples
实际运行示例
For reference runs of both the reuse-an-existing-queue fast path (validated on test1) and the create-a-new-queue-via-Metadata-API path, see .
references/worked-examples.md如需参考复用现有队列的快速路径(已在test1上验证)和通过Metadata API创建新队列的路径的实际运行示例,请查看。
references/worked-examples.mdGotchas
常见问题
Known gotchas — filtering, DeveloperName uniqueness, QueueRoutingConfig naming, empty-queue caveats, Metadata-API-only queue creation, the per-domain FallbackQueue requirement matrix, the server-side / readiness enforcement point, the Standard-vs-Enhanced SessionHandler write restriction, and polymorphism across org shapes.
Group.TypenullQueueIdSessionHandlerWhen troubleshooting an unexpected result, or before modifying this skill, load and follow it — it is the complete list.
references/gotchas.md已知的问题点——过滤、DeveloperName唯一性、QueueRoutingConfig命名、空队列注意事项、仅通过Metadata API创建队列、按域划分的FallbackQueue要求矩阵、服务器端 / 就绪状态强制检查点、Standard与Enhanced通道的SessionHandler写入限制,以及跨组织形态的多态性。
Group.TypenullQueueIdSessionHandler排查意外结果或修改本技能之前,请加载并查看——该文件包含完整的问题列表。
references/gotchas.md