@salesforce/afv-skills 1.69.0 → 1.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/package.json +1 -1
  2. package/skills/data360-code-extension-generate/SKILL.md +160 -252
  3. package/skills/data360-code-extension-generate/references/README.md +34 -172
  4. package/skills/data360-code-extension-generate/references/environment-setup.md +198 -0
  5. package/skills/data360-code-extension-generate/references/mcp-integration.md +36 -0
  6. package/skills/data360-code-extension-generate/references/quick-reference.md +132 -202
  7. package/skills/data360-code-extension-generate/references/run-logs.md +31 -0
  8. package/skills/data360-code-extension-generate/references/schema-discovery.md +45 -0
  9. package/skills/data360-code-extension-generate/references/troubleshooting.md +45 -0
  10. package/skills/data360-code-extension-generate/scripts/check_env.sh +197 -0
  11. package/skills/data360-code-extension-generate/scripts/venv_hook.sh +22 -0
  12. package/skills/dx-devops-work-item-manage/SKILL.md +24 -8
  13. package/skills/dx-devops-work-item-manage/examples/common-workflows.md +32 -0
  14. package/skills/dx-devops-work-item-manage/references/review-api.md +95 -0
  15. package/skills/dx-org-manage/SKILL.md +12 -12
  16. package/skills/dx-org-manage/examples/scratch-orgs/display_output.json +1 -3
  17. package/skills/dx-org-manage/examples/scratch-orgs/success_shape.json +1 -3
  18. package/skills/dx-org-manage/references/opening-org.md +1 -1
  19. package/skills/dx-org-manage/references/scratch-org-operations.md +15 -20
  20. package/skills/dx-packaging-move-to-2gp-migrate/SKILL.md +1 -1
  21. package/skills/education-cloud-academic-calendar-generate/SKILL.md +2 -2
  22. package/skills/education-cloud-course-catalog-migrate/SKILL.md +1 -1
  23. package/skills/education-cloud-domain-configure/references/domain-features/recruitment-admissions.md +8 -7
  24. package/skills/education-cloud-multi-campus-configure/SKILL.md +1 -0
  25. package/skills/education-cloud-multi-campus-configure/references/error_handling.md +7 -6
  26. package/skills/education-cloud-student-recruitment-agent-configure/SKILL.md +2 -0
  27. package/skills/education-cloud-student-recruitment-agent-configure/references/customer-narration.md +2 -0
  28. package/skills/education-cloud-student-recruitment-agent-configure/references/flows.md +1 -1
  29. package/skills/education-cloud-student-recruitment-agent-configure/references/grounding.md +5 -4
  30. package/skills/education-cloud-student-recruitment-agent-configure/references/permissions.md +1 -1
  31. package/skills/education-cloud-student-recruitment-agent-configure/references/prerequisites.md +1 -1
  32. package/skills/education-cloud-student-recruitment-agent-configure/references/routing.md +1 -1
  33. package/skills/experience-cms-content-type-generate/SKILL.md +7 -6
  34. package/skills/experience-cms-content-type-generate/references/agent-checklist.md +3 -3
  35. package/skills/experience-cms-content-type-generate/references/anti-patterns.md +2 -2
  36. package/skills/experience-cms-content-type-generate/references/discovery-details.md +1 -1
  37. package/skills/experience-cms-content-type-generate/references/retrieve-and-reconcile.md +5 -9
  38. package/skills/experience-ui-bundle-custom-app-generate/scripts/resolve-uibundle-path.mjs +10 -0
  39. package/skills/field-service-data-capture-migrate/references/converter-builder-contract.md +2 -2
  40. package/skills/field-service-data-capture-migrate/references/fsm-dc-capability-catalog.md +2 -2
  41. package/skills/field-service-data-capture-migrate/scripts/analyze_flow.py +1 -1
  42. package/skills/field-service-data-capture-migrate/scripts/convert_to_dc_spec.py +1 -1
  43. package/skills/field-service-data-capture-migrate/scripts/fsm_dc_catalog.py +2 -2
  44. package/skills/field-service-data-capture-migrate/scripts/generate_summary.py +2 -2
  45. package/skills/platform-custom-application-generate/SKILL.md +97 -104
  46. package/skills/platform-custom-application-generate/references/app-properties.md +52 -0
  47. package/skills/platform-custom-application-generate/references/app-visibility.md +19 -0
  48. package/skills/platform-custom-application-generate/references/utility-bar.md +55 -0
  49. package/skills/platform-datamask-run/SKILL.md +1 -1
  50. package/skills/platform-datamask-run/references/policy-authoring.md +41 -18
  51. package/skills/platform-dsar-policy-manage/SKILL.md +7 -6
  52. package/skills/platform-dsar-policy-manage/references/export-and-history.md +10 -8
  53. package/skills/platform-dsar-policy-manage/references/report-format.md +4 -2
  54. package/skills/platform-metadata-grounding-get/SKILL.md +7 -7
  55. package/skills/platform-report-generate/SKILL.md +9 -7
  56. package/skills/platform-report-generate/references/column-names.md +12 -1
  57. package/skills/platform-report-generate/references/errors-and-troubleshooting.md +1 -1
  58. package/skills/platform-sharing-rules-generate/SKILL.md +12 -3
  59. package/skills/platform-sharing-rules-generate/references/rule-types.md +1 -0
  60. package/skills/service-agentforce-channel-configure/SKILL.md +6 -3
  61. package/skills/service-agentforce-channel-configure/references/agent-wiring.md +5 -3
  62. package/skills/service-agentforce-channel-configure/references/channel-branch-email.md +24 -15
  63. package/skills/service-agentforce-channel-configure/references/input-validation.md +23 -0
  64. package/skills/service-agentforce-channel-configure/references/live-traffic-gate.md +13 -7
  65. package/skills/service-agentforce-channel-configure/references/queue-resolution.md +3 -1
  66. package/skills/service-agentforce-human-escalation-configure/references/_vendored/input-validation.md +23 -0
  67. package/skills/service-agentforce-human-escalation-configure/references/_vendored/queue-resolution.md +146 -0
  68. package/skills/service-agentforce-human-escalation-configure/references/escalation-mechanism.md +1 -1
  69. package/skills/service-agentforce-human-escalation-configure/scripts/tests/_bootstrap.py +42 -11
  70. package/skills/service-agentforce-human-escalation-configure/scripts/tests/test_escalation_contracts.py +45 -0
  71. package/skills/service-agentforce-human-escalation-configure/scripts/verify-and-configure.sh +23 -9
  72. package/skills/service-de-channel-activate/SKILL.md +10 -10
  73. package/skills/service-de-channel-activate/references/gotchas.md +4 -4
  74. package/skills/service-de-channel-activate/references/phone-verification.md +43 -19
  75. package/skills/service-de-channel-create/SKILL.md +1 -1
  76. package/skills/service-de-channel-create/references/facebook.md +1 -1
  77. package/skills/service-de-channel-create/references/whatsapp.md +33 -6
  78. package/skills/service-de-channel-routing-configure/SKILL.md +5 -1
  79. package/skills/service-de-channel-routing-configure/references/gotchas.md +3 -1
  80. package/skills/service-de-channel-routing-configure/references/named-queue.md +39 -0
  81. package/skills/service-de-channel-settings-configure/SKILL.md +3 -1
  82. package/skills/service-de-channel-settings-configure/references/channel-settings-facets.md +2 -2
  83. package/skills/service-de-channel-settings-configure/references/gotchas.md +12 -1
  84. package/skills/service-de-headless-channel-configure/SKILL.md +68 -74
  85. package/skills/service-de-headless-channel-configure/references/gotchas.md +6 -2
  86. package/skills/service-de-headless-channel-configure/references/inputs.md +19 -0
  87. package/skills/service-de-headless-channel-configure/references/output-envelopes.md +23 -1
  88. package/skills/service-de-headless-channel-configure/references/partial-success.md +1 -0
  89. package/skills/service-de-headless-channel-configure/references/requested-settings.md +55 -0
  90. package/skills/service-de-headless-channel-configure/references/worked-examples.md +35 -1
  91. package/skills/service-digital-engagement-channel-configure/SKILL.md +3 -3
  92. package/skills/service-digital-engagement-channel-configure/references/onboarding_contract.md +2 -2
  93. package/skills/service-digital-engagement-channel-configure/scripts/check-api-version.sh +1 -1
  94. package/skills/service-digital-engagement-deployment-configure/SKILL.md +2 -2
  95. package/skills/service-digital-engagement-deployment-configure/references/onboarding_contract.md +4 -2
  96. package/skills/service-digital-engagement-deployment-configure/scripts/check-api-version.sh +1 -1
  97. package/skills/service-omni-command-center-configure/SKILL.md +1 -1
  98. package/skills/data360-schema-get/SKILL.md +0 -388
  99. package/skills/data360-schema-get/references/README.md +0 -191
  100. package/skills/data360-schema-get/scripts/get_dlo_schema.py +0 -244
  101. package/skills/data360-schema-get/scripts/get_dmo_schema.py +0 -233
  102. package/skills/field-service-prework-brief-deployer-configure/SKILL.md +0 -646
  103. package/skills/field-service-voice-to-form-configure/SKILL.md +0 -650
@@ -124,7 +124,7 @@ Type-specific inputs:
124
124
  {"ok": false, "kind": "verify-failed", "hint": "Connect returned 201 but follow-up SOQL shows no matching channel"}
125
125
  ```
126
126
  Type-specific failure kinds (`partnership-blocked`, `user-declined`, `waba-manage-failed`,
127
- `meta-precondition` for WhatsApp; `line-token-invalid` for LINE; `apple-precondition` for Apple;
127
+ `unified-messaging-required`, `meta-precondition` for WhatsApp; `line-token-invalid` for LINE; `apple-precondition` for Apple;
128
128
  `oauth-not-complete`, `oauth-failed` for Facebook) are documented in the per-type reference files.
129
129
 
130
130
  ---
@@ -34,7 +34,7 @@ sf data query --target-org '{ORG_ALIAS}' \
34
34
  ```
35
35
  Record `{AUTH_PROVIDER_ID}` = `records[0].Id` and `{OAUTH_KICKOFF_URL}` = `records[0].OauthKickoffUrl`
36
36
  (e.g. `https://<myDomain>/services/auth/oauth/LiveMessageSetup`). If no record →
37
- `{ok:false, kind:"missing-authprovider", hint:"LiveMessageSetup AuthProvider not found — org may not have Facebook Messenger enabled"}`.
37
+ `{ok:false, kind:"missing-authprovider", hint:"LiveMessageSetup AuthProvider not found — run the Messaging Setup wizard once in Setup → Messaging Settings (enabling messaging alone doesn't create it), then re-run"}`.
38
38
 
39
39
  > **Use `OauthKickoffUrl`, NOT the generic `/services/auth/sso/<orgId>/LiveMessageSetup` SSO URL.**
40
40
  > That SSO door runs the AuthProvider's Apex *registration handler* to log a user in; `LiveMessageSetup`
@@ -33,19 +33,30 @@ Suite. There's no Graph API to probe this without a customer Meta token, so invo
33
33
  - `{ok:false, kind:"user-declined"}` → propagate; re-run when ready
34
34
 
35
35
  **Stage 3 — SF-side management.** The customer-side share from Stage 2 alone does not subscribe SF's
36
- webhook or share SF's Meta line of credit. Call the sanctioned Connect endpoint. **The WABA id (and
37
- phone id) go in the URL query string, NOT the JSON body** — the endpoint reads `wabaId`/`phoneId`
38
- from the query and ignores a body `externalAccountId`. Send an empty body:
36
+ webhook or share SF's Meta line of credit. Call the sanctioned Connect endpoint. It needs
37
+ `{AUTH_PROVIDER_ID}`, so **run the Stage 4.1 AuthProvider lookup (SKILL.md) first** — on a fresh run
38
+ Stage 3 executes before Stage 4. **The WABA id (and phone id) go in the URL query string, NOT the
39
+ JSON body** — the endpoint reads `wabaId`/`phoneId` from the query and ignores a body
40
+ `externalAccountId`. The body is empty, but **pass `--body '{}'` explicitly**: current `sf` CLI
41
+ versions reject a body-less POST locally with `No 'mode' found in 'body'` before anything reaches the
42
+ server.
39
43
 
40
44
  ```bash
41
45
  sf api request rest \
42
46
  "/services/data/v{API_VERSION}/connect/livemessage/whatsapp/business-account?authProviderId=${AUTH_PROVIDER_ID}&wabaId=${WABA_ID}&phoneId=${PHONE_NUMBER_ID}" \
43
47
  --method POST --target-org '{ORG_ALIAS}' \
44
48
  --header 'Content-Type: application/json' --header 'Accept: application/json' \
45
- --include
49
+ --body '{}' --include > "${SCRATCH_DIR}/waba-manage.txt" 2>&1
46
50
  ```
47
- On failure emit
48
- `{ok:false, kind:"waba-manage-failed", hint:"manageWhatsAppBusinessAccount failed — SF could not subscribe its webhook / share credit line with this WABA. Most likely: WABA not actually shared yet (partnership landed Meta-side but hasn't propagated), or the WABA id is wrong.", message:"..."}`.
51
+
52
+ **Classify by the response body's `success` field, not the HTTP status** (gotcha #7). This endpoint
53
+ returns **HTTP 201 even when it fails**, with `{"success":false,"errorMessage":"..."}` in the body.
54
+ - `success:true` → proceed to Stage 4.
55
+ - `success:false` with `errorMessage` containing `DE Unlimited Access orgs must create Unified Messaging channels`
56
+ → emit `{ok:false, kind:"unified-messaging-required", message:"<errorMessage>", hint:"This org's Digital Engagement license (DE Unlimited Access) only allows Unified Messaging WhatsApp channels; these skills create Enhanced WhatsApp channels, so WhatsApp can't be set up headlessly here. Set WhatsApp up in Setup → Messaging Settings instead. Other channel types aren't affected."}`. Stop — don't
57
+ attempt the insert; it fails on the same gate with a less readable error.
58
+ - any other `success:false`, or a non-2xx status → emit
59
+ `{ok:false, kind:"waba-manage-failed", hint:"manageWhatsAppBusinessAccount failed — SF could not subscribe its webhook / share credit line with this WABA. Most likely: WABA not actually shared yet (partnership landed Meta-side but hasn't propagated), or the WABA id is wrong.", message:"<errorMessage or response body>"}`.
49
60
 
50
61
  > **Do NOT put the WABA id in the body** (gotcha #6). A body of `{"externalAccountId":"<WABA_ID>"}` —
51
62
  > or even `{"wabaId":"<WABA_ID>"}` — returns `400 INVALID_API_INPUT "wabaId is required"`, because the
@@ -74,6 +85,8 @@ WhatsApp inserts across orgs; Facebook lands as `New`). Any pre-activation value
74
85
  - `partnership-blocked` — from Stage 2 (`service-de-waba-integrate`).
75
86
  - `user-declined` — user cancelled the WABA-linking prompt.
76
87
  - `waba-manage-failed` — from Stage 3 (SF-side `manageWhatsAppBusinessAccount`).
88
+ - `unified-messaging-required` — from Stage 3; the org's license only allows Unified Messaging
89
+ WhatsApp channels (gotcha #8).
77
90
  - `meta-precondition` — Connect rejected the insert (WABA not shared, phone not OTP'd on Meta side,
78
91
  etc.); hint `"Connect API rejected the request — WABA not shared, phone not OTP'd on Meta side"`.
79
92
 
@@ -96,3 +109,17 @@ WhatsApp inserts across orgs; Facebook lands as `New`). Any pre-activation value
96
109
  body shape `{"externalAccountId":"<WABA_ID>"}` returns `400 INVALID_API_INPUT "wabaId is required"`
97
110
  (as does `{"wabaId":...}` in the body). Pass `?...&wabaId=<WABA_ID>&phoneId=<PHONE_NUMBER_ID>` with an
98
111
  empty body — see Stage 3.
112
+ 7. **WABA-manage reports failure inside a 201.** A failed call returns HTTP 201 with
113
+ `{"success":false,"errorMessage":"..."}`. Classifying by status alone treats it as success and
114
+ pushes the run into an insert that fails anyway. Always read `success`.
115
+ 8. **DE Unlimited Access orgs can't create Enhanced WhatsApp channels.** On orgs licensed "DE
116
+ Unlimited Access" (Messaging Unlimited), both WhatsApp Connect calls are blocked by the same
117
+ server-side check: `DE Unlimited Access orgs must create Unified Messaging channels.` WABA-manage
118
+ returns it readably (201 + `success:false`). The insert returns it as
119
+ `400 CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY`, or on some builds as an opaque `500 UNKNOWN_EXCEPTION`
120
+ ("Error creating a new Messaging Channel"), which is why Stage 3 stops on it. Setting
121
+ `platformType:"Unified"` in the insert body isn't a workaround — it's rejected with
122
+ `Invalid value for platform type`. The check fires before the WABA partnership matters, and it
123
+ only affects WhatsApp: Facebook, MIAW and Voice channels on the same org stay Enhanced. There's no
124
+ headless Unified Messaging path in these skills, so the user has to set up WhatsApp in Setup.
125
+ (Verified on a 264 DE Unlimited Access org, 2026-10-05, and a local 266 org, 2026-09-23.)
@@ -49,6 +49,7 @@ Provisioning behavior:
49
49
  | --- | --- |
50
50
  | `references/queue-creation.md` | The user picked "create a new queue" on the Queue routing path — full Metadata API scaffold → deploy → ID lookup → optional member add. |
51
51
  | `references/target-locate.md` | You need the per-domain SOQL to locate and validate an eligible target (Queue, Flow, ASA, Digital Worker, User) and the FallbackQueue requirement matrix. |
52
+ | `references/named-queue.md` | The caller supplied `{QUEUE}` (a queue the user named). |
52
53
  | `references/asa-routing.md` | The user picked ASA (Agentforce Service Agent) routing — precondition check, enumerating live ASAs, and selection. |
53
54
  | `references/gotchas.md` | Troubleshooting an unexpected result, or before modifying this skill — the known gotchas. |
54
55
  | `references/worked-examples.md` | You want a reference run of the reuse-existing-queue, create-new-queue, Flow, or ASA paths. |
@@ -62,6 +63,7 @@ Provisioning behavior:
62
63
  ## Inputs (from caller)
63
64
 
64
65
  - `{CHANNEL_ID}` — a 15- or 18-char `MessagingChannel.Id` (prefix `0Mj`). The channel must already exist.
66
+ - `{QUEUE}` — optional; a queue the user named (label, DeveloperName, or `00G` Id). Implies Queue routing — no routing-type prompt.
65
67
  - `{ORG_ALIAS}` — optional; the `sf` CLI target-org alias. Default: whatever `sf config get target-org` returns. All SOQL, PATCH, and Metadata deploys run against this org.
66
68
 
67
69
  ## Output (to caller)
@@ -175,7 +177,7 @@ sf data query --target-org '{ORG_ALIAS}' \
175
177
 
176
178
  If `PlatformType != 'Enhanced'` (i.e. Standard/SCRT1), only Flow routing is writable. These skills only create Enhanced channels, so a Standard channel here is unexpected — emit `{ok:false, kind:"standard-channel", ...}` and stop rather than guessing.
177
179
 
178
- Then ask the user (via a prompt — do NOT auto-pick):
180
+ If `{QUEUE}` was supplied, the routing type is `queue` — skip the prompt and go to Stage 3-Queue. Otherwise ask the user (via a prompt — do NOT auto-pick):
179
181
 
180
182
  ```text
181
183
  The MessagingChannel '{developerName}' ({CHANNEL_ID}) has no routing configured.
@@ -217,6 +219,8 @@ sf data query --target-org '{ORG_ALIAS}' \
217
219
 
218
220
  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`.)
219
221
 
222
+ **If `{QUEUE}` was supplied**, validate it against this list instead of prompting — **load `references/named-queue.md` and follow it.**
223
+
220
224
  Present the user with a numbered list plus a final "create new" option:
221
225
 
222
226
  ```text
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: service-de-channel-routing-configure-gotchas
3
- description: "Load when debugging an unexpected result from service-de-channel-routing-configure, or before implementing changes to it. Covers the known gotchas: Group.Type filtering, DeveloperName uniqueness, QueueRoutingConfig naming, empty-queue caveats, Metadata-API-only queue creation, the per-domain FallbackQueue requirement matrix, the server-side nullQueueId enforcement point, the Standard-vs-Enhanced SessionHandler write restriction, and SessionHandler polymorphism differences across org shapes. DO NOT load this during a normal first-time routing configuration run — only when troubleshooting or modifying the skill."
3
+ description: "Load when debugging an unexpected result from service-de-channel-routing-configure, or before implementing changes to it. Covers the known gotchas: Group.Type filtering, DeveloperName uniqueness, QueueRoutingConfig naming, empty-queue caveats, Metadata-API-only queue creation, the per-domain FallbackQueue requirement matrix, the server-side nullQueueId enforcement point, the Standard-vs-Enhanced SessionHandler write restriction, SessionHandler polymorphism differences across org shapes, and the MessagingSession-eligibility rule the server doesn't enforce. DO NOT load this during a normal first-time routing configuration run — only when troubleshooting or modifying the skill."
4
4
  metadata:
5
5
  version: "1.0"
6
6
  related-skills: service-de-channel-routing-configure
@@ -25,3 +25,5 @@ metadata:
25
25
  8. **Standard (SCRT1) channels only accept a Flow as SessionHandler; Enhanced (SCRT2) channels accept all five domains.** `validateSessionHandler` (the `PlatformType==STANDARD` branch) rejects any non-Flow SessionHandler on a Standard channel with *"Only flows of type Omni-Channel are supported for a Messaging Channel"* — verified live: a `00G` Queue and a `0Xx` ASA both failed with that exact message on a Standard channel, and both succeeded on an Enhanced one. These skills create only Enhanced channels, so Stage 2 confirms `PlatformType=Enhanced` and bails with `kind:"standard-channel"` if it ever sees otherwise.
26
26
 
27
27
  9. **`MessagingChannel.SessionHandler` polymorphism is org-shape-dependent.** The full domain is `[Group, FlowDefinition, User, BotDefinition, AgenticCtxtDecorDefinition]`, but `BotDefinition` (ASA) only materializes on Agentforce-licensed orgs and `AgenticCtxtDecorDefinition` (Digital Worker) only when `orgHasOmniChannelScrt2DigitalWorkerRouting` is enabled (not present on sdb6c). The ASA precondition check (Stage 3-ASA.0) and the Digital Worker `INVALID_TYPE` guard (`references/target-locate.md`) catch the missing-domain cases before a PATCH is attempted. Note the SOQL field surface is thinner than the internal representation: the Data-API `BotDefinition` sObject exposes only `Type`/`AgentType`/`AgentTemplate`, so the active-version check goes through the `BotVersions` child relationship, not an `ActiveVersionId` column.
28
+
29
+ 10. **The server does not enforce MessagingSession eligibility on the SessionHandler PATCH.** Validation (Round 5, release 264) routed both a MIAW and a Facebook channel to a queue whose supported objects were only `ContactRequest` and `VoiceCall`, and the PATCH succeeded. So the skill's eligible-queue filter (`QueueRoutingConfigId != null` + `QueueSobject.SobjectType='MessagingSession'`) is stricter than the server. Keep the filter as the **recommended** rule — a queue can only own records of the object types it supports, and the runtime effect of routing sessions to such a queue hasn't been verified — but treat it as advice, not a hard block: when the user names an ineligible queue, explain what's missing and let them choose (Stage 3-Queue). Don't send a user who named a real queue down the "create a new queue" branch just because the filtered list is empty.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: service-de-channel-routing-configure-named-queue
3
+ description: "Load when the caller of service-de-channel-routing-configure supplied {QUEUE} (a queue the user already named) and it has to be validated on the Queue routing path. Covers matching it against the eligible list, the unfiltered lookup when it isn't eligible, the three-way prompt (use anyway / pick eligible / create new), and the warning added to the success envelope. DO NOT load when no {QUEUE} was supplied — the normal Stage 3-Queue list applies."
4
+ metadata:
5
+ version: "1.0"
6
+ related-skills: service-de-channel-routing-configure
7
+ ---
8
+
9
+ # Validating a queue the user named (`{QUEUE}`)
10
+
11
+ Match `{QUEUE}` against the Stage 3-Queue eligible list by `Id`, `DeveloperName`, or `Name`.
12
+
13
+ - **Match** → record `{QUEUE_ID}`, skip to Stage 5, no prompt.
14
+ - **No match** → look it up without the eligibility filters:
15
+
16
+ ```bash
17
+ sf data query --target-org '{ORG_ALIAS}' \
18
+ --query "SELECT Id, Name, DeveloperName, QueueRoutingConfigId FROM Group WHERE Type='Queue' AND (DeveloperName='{QUEUE}' OR Name='{QUEUE}')" \
19
+ --json
20
+ ```
21
+
22
+ If `{QUEUE}` is an Id (15 or 18 chars starting with `00G`), filter on `Id='{QUEUE}'` instead. Don't combine the two: comparing `Id` to a name fails the whole query with `INVALID_QUERY_FILTER_OPERATOR` ("invalid ID field").
23
+
24
+ If it exists, tell the user exactly what's missing. Never silently accept it, and never silently fall through to "create new":
25
+
26
+ ```text
27
+ Queue '{QUEUE}' exists but isn't set up for messaging: {"it doesn't list Messaging Session as a supported object" | "it has no Omni-Channel routing configuration"}.
28
+ The server will accept it, but the skill can't confirm sessions will route there.
29
+
30
+ 1) Use it anyway
31
+ 2) Pick an eligible queue from the list
32
+ 3) Create a new messaging queue
33
+ ```
34
+
35
+ On (1), record `{QUEUE_ID}`, add `"warning": "queue is not MessagingSession-capable / Omni-enabled"` to the success envelope, and continue to Stage 5. (2) → the normal numbered list. (3) → `references/queue-creation.md`.
36
+
37
+ - **No queue matches `{QUEUE}` at all** → say so, then show the normal numbered list.
38
+
39
+ Why the rule and the server disagree: see `references/gotchas.md` #10.
@@ -168,6 +168,8 @@ Outline:
168
168
  3. Deploy it back (`sf project deploy start -m MessagingChannel:{DeveloperName}`).
169
169
  4. On deploy failure: `{ok:false, kind:"metadata-deploy-failed", message: <componentFailures>}`.
170
170
 
171
+ > **Facebook:** real metadata changes currently fail with an opaque numeric error (e.g. `(-462367322)`). It's a known platform issue, not bad input. Don't retry; return `metadata-deploy-failed` with the Setup-UI fallback hint (see `references/gotchas.md` #16).
172
+
171
173
  **Never emit `<actionParameterMappings>`** (0 occurrences across a 191-channel scan — it's a Tooling-only mapping done in the UI post-deploy).
172
174
 
173
175
  ---
@@ -176,7 +178,7 @@ Outline:
176
178
 
177
179
  Run only when requested **and** applicable to this `MessageType`:
178
180
 
179
- - **Facet 4 (inactivity):** the four timeout fields (`endUserIdleTimeOut` 5–30, `endUserIdleAction` = `Inactivate`|`End`|`InactivateAndEnd`, `endInactiveSessionTimeOut`, `isAgentMessageResetInactivityEnabled`) are **top-level siblings of `<embeddedConfig>`**, not inside it. Full four fields → **MIAW only**; `isAgentMessageResetInactivityEnabled` also valid on Apple/Facebook; **not applicable on SMS/WhatsApp/LINE** → emit `facet-not-applicable`. (On 262-line pods only `endUserIdleTimeOut` deploys — see `references/gotchas.md`.)
181
+ - **Facet 4 (inactivity):** the four timeout fields (`endUserIdleTimeOut` 5–30, `endUserIdleAction` = `Inactivate`|`End`|`InactivateAndEnd`, `endInactiveSessionTimeOut`, `isAgentMessageResetInactivityEnabled`) are **top-level siblings of `<embeddedConfig>`**, not inside it. Full four fields → **MIAW only**; `isAgentMessageResetInactivityEnabled` also valid on Apple/Facebook; **not applicable on SMS/WhatsApp/LINE** → emit `facet-not-applicable`. (Release-gated: on 262 pods only `endUserIdleTimeOut` deploys and the reset flag is silently dropped; all four work on 264+ — see `references/gotchas.md` #15.)
180
182
  - **Facet 5 (parameters):** `<customParameters>` (`name`, `masterLabel`, `externalParameterName`, `parameterDataType=String`, optional `maxLength`) and `<standardParameters>` — **MIAW pre-chat only**, rare. Skip unless the caller explicitly configures pre-chat.
181
183
 
182
184
  Both use the same retrieve→edit→deploy flow as Stage 3 (`references/channel-settings-facets.md`).
@@ -117,7 +117,7 @@ Four fields, **siblings of `<embeddedConfig>`** (top-level, NOT nested inside it
117
117
  <endUserIdleTimeOut>5</endUserIdleTimeOut>
118
118
  ```
119
119
 
120
- **Per-type scope (verified live):** all four → **MIAW (EmbeddedMessaging) only**. `isAgentMessageResetInactivityEnabled` alone also appears on **Apple** and **Facebook**. **SMS/WhatsApp/LINE carry no inactivity fields** — emit `facet-not-applicable`. On 262-line pods only `endUserIdleTimeOut` deploys (`endInactiveSessionTimeOut`/`endUserIdleAction` land at 264+) — see `gotchas.md`.
120
+ **Per-type scope (verified live):** all four → **MIAW (EmbeddedMessaging) only**. `isAgentMessageResetInactivityEnabled` alone also appears on **Apple** and **Facebook**. **SMS/WhatsApp/LINE carry no inactivity fields** — emit `facet-not-applicable`. Release-gated: on 262-line pods only `endUserIdleTimeOut` deploys (`endInactiveSessionTimeOut`/`endUserIdleAction` are rejected, and `isAgentMessageResetInactivityEnabled` reports `Succeeded` but is silently dropped); all four deploy and persist on 264+ — see `gotchas.md` #15.
121
121
 
122
122
  ---
123
123
 
@@ -149,4 +149,4 @@ Four fields, **siblings of `<embeddedConfig>`** (top-level, NOT nested inside it
149
149
  | Inactivity — reset flag (4) | yes | yes | yes | no | no | no |
150
150
  | Pre-chat parameters (5) | pre-chat only | no | no | no | no | no |
151
151
 
152
- Derived from a Metadata-API retrieve of real channels of each type. Don't deploy a facet a type doesn't support — the deploy will either fail or silently drop the element.
152
+ Derived from a Metadata-API retrieve of real channels of each type. **Facebook caveat:** the facets are supported, but real metadata updates to Facebook channels currently fail with an opaque error — see `gotchas.md` #16. Don't deploy a facet a type doesn't support — the deploy will either fail or silently drop the element.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: service-de-channel-settings-configure-gotchas
3
- description: "Load when debugging an unexpected result from service-de-channel-settings-configure, or before implementing changes to it. Covers the known gotchas: the exact per-ConsentType activation-readiness contract and its source, the ImplicitOptIn-still-needs-a-keyword-record trap, comma-separated keyword storage, one-record-per-language uniqueness, the Unified-SMS help/French-custom rules, the OptInPrompt Unified-SMS/WhatsApp/RCS exemption, the outbound-only auto-pass, the Enhanced-only gate, the legacy OptInResponse/OptOutResponse deprecation, and why MsgChannelLanguageKeyword must be written over the Data/SObjects API rather than the Tooling API despite its setupEntity perApiAccess block. DO NOT load this during a normal first-time consent run — only when troubleshooting or modifying the skill."
3
+ description: "Load when debugging an unexpected result from service-de-channel-settings-configure, or before implementing changes to it. Covers the known gotchas: the exact per-ConsentType activation-readiness contract and its source, the ImplicitOptIn-still-needs-a-keyword-record trap, comma-separated keyword storage, one-record-per-language uniqueness, the Unified-SMS help/French-custom rules, the OptInPrompt Unified-SMS/WhatsApp/RCS exemption, the outbound-only auto-pass, the Enhanced-only gate, the legacy OptInResponse/OptOutResponse deprecation, why MsgChannelLanguageKeyword must be written over the Data/SObjects API rather than the Tooling API despite its setupEntity perApiAccess block, which inactivity fields deploy on 262 vs 264 pods, and the Facebook metadata-update failure. DO NOT load this during a normal first-time consent run — only when troubleshooting or modifying the skill."
4
4
  metadata:
5
5
  version: "1.0"
6
6
  related-skills: service-de-channel-settings-configure
@@ -39,3 +39,14 @@ metadata:
39
39
  13. **`ConsentType` requires minApiVersion 224.** All consent fields (`ConsentType`, `OptInPrompt`, `DoubleOptInPrompt`, `IsRequireDoubleOptIn`) and the `MsgChannelLanguageKeyword` entity were introduced in API 224. The skill declares `minApiVersion: "67.0"` (well above 224); on an older org the fields won't exist and the Stage 1 query will error.
40
40
 
41
41
  14. **Write `MsgChannelLanguageKeyword` over the regular Data/SObjects API — NOT the Tooling API.** `sf data create/update record --sobject MsgChannelLanguageKeyword` (the path this skill uses) works and is the sanctioned write path — verified live on sdb6c 2026-08-13: a `sf data update record` returned `success=true` at API v69.0, and `sf sobject describe` reports the object `createable: true, updateable: true`. **The entity XML is misleading here.** `MsgChannelLanguageKeyword.entity.xml` is a `setupEntity` carrying `<perApiAccess minApiVersion="246" apiAccess="isDevInternal || isUiTier" sobjectFamily="TOOLING"/>`. That block reads like a blanket write gate, but `sobjectFamily="TOOLING"` scopes it to the **Tooling API family only** — `ApiDictionaryInitializer._getFieldAccessStrategy` selects the `TOOLING` `perApiAccess` seed exclusively when `apiFamily.isTooling()`, so a regular SObjects/Data API request never applies it and instead uses the entity's base `createAccess`/`editAccess` (`LiveMessage.userCanCustomizeSetup`, which a setup-capable admin satisfies). Consequently a **Tooling** API write (`sf ... --use-tooling-api`, or the Tooling REST/SOAP endpoints) returns `NOT_FOUND` for this entity for external callers, while the Data API write succeeds. If a keyword write fails, first suspect a transient org issue (sdb6c 503 maintenance windows produced spurious `UNKNOWN_EXCEPTION` on Data-API writes during testing) and retry — do NOT switch to the Tooling API thinking it's the "real" write path; it isn't.
42
+
43
+ 15. **Inactivity fields are release-gated: 262 vs 264.** The Metadata API only exposes all four facet-4 fields from release **264**. The Setup UI can set all of them on 262 because it writes through a different layer. Check the org's release (`sf org display` → API version: v67.0 = 262, v69.0 = 264) before promising the full set:
44
+ | Field | 262 pods | 264+ |
45
+ | --- | --- | --- |
46
+ | `endUserIdleTimeOut` | deploys and persists | deploys and persists |
47
+ | `endUserIdleAction` | **rejected** by the deploy schema | deploys and persists |
48
+ | `endInactiveSessionTimeOut` | **rejected** by the deploy schema | deploys and persists |
49
+ | `isAgentMessageResetInactivityEnabled` | deploy reports `Succeeded` but the field is **silently dropped** | deploys and persists |
50
+ No org setting turns these on; only a 264+ build has them. On 262, deploy only `endUserIdleTimeOut` and report the other three as unsupported on this release. The Stage 5 re-retrieve is what catches the silent drop of the reset flag — never trust a `Succeeded` deploy on its own. The 5–30 minute bound on `endUserIdleTimeOut` is enforced server-side on both (`must be between 5 and 30 minutes`; the org value is unchanged). (Verified on a v67.0/262 org and a v69.0/264 org, Round 4/5 validation, 2026-10.)
51
+
52
+ 16. **Facebook channels reject any real metadata change with an opaque numeric error.** Deploying an edited `.messagingChannel-meta.xml` for a Facebook channel fails with a bare code like `(-462367322)`, even when the only change is `masterLabel`. Redeploying the unchanged retrieved file succeeds, but only because nothing changed. It reproduces on a brand-new, correctly configured Facebook channel on a 264 org (2026-10), so it isn't corruption of one channel; the root cause is unknown and looks like a platform defect. MIAW channels on the same org deploy fine. Until it's fixed, facets 2–4 can't be written headlessly on Facebook: don't retry. Emit `{ok:false, kind:"metadata-deploy-failed", message:"<the code>", hint:"Facebook channels currently reject metadata updates with this opaque error (known platform issue, not your input). Configure these settings in Setup → Messaging Settings → this channel instead."}`. Consent (facet 1, Data API) is unaffected.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: service-de-headless-channel-configure
3
- description: "Top-level orchestrator: given a messaging channel type and its inputs, produces an activated Enhanced `MessagingChannel` in the target org — without the Meta/LINE/Apple setup popups. Prompts for `{MESSAGE_TYPE}` if not supplied, then sequences insert → route → consent → activate via the type-agnostic dispatcher (`service-de-channel-create`) plus the shared routing/consent/activation leaves. Resumes from partial state on re-run. Use to set up an Enhanced channel (WhatsApp, Facebook, LINE, Apple, SMS) end-to-end, bypassing in-org setup popups. Do not use for a single stage of an already-inserted channel — use the matching leaf skill (`service-de-channel-activate`, `service-de-channel-settings-configure`, `service-de-channel-routing-configure`) instead."
3
+ description: "Top-level orchestrator: given a messaging channel type and its inputs, produces an activated Enhanced `MessagingChannel` in the target org — without the Meta/LINE/Apple setup popups. Prompts for `{MESSAGE_TYPE}` if not supplied, then sequences insert → route → consent → activate → requested settings (auto-responses, keywords, session inactivity) via the type-agnostic dispatcher (`service-de-channel-create`) plus the shared routing/settings/activation leaves, and reports every requested setting as configured, not applicable, or failed. Resumes from partial state on re-run. Use to set up an Enhanced channel (WhatsApp, Facebook, LINE, Apple, SMS) end-to-end, bypassing in-org setup popups. Do not use for a single stage of an already-inserted channel — use the matching leaf skill (`service-de-channel-activate`, `service-de-channel-settings-configure`, `service-de-channel-routing-configure`) instead."
4
4
  metadata:
5
5
  version: "1.0"
6
6
  minApiVersion: "67.0"
@@ -20,17 +20,18 @@ metadata:
20
20
 
21
21
  ## What this skill does
22
22
 
23
- Takes a channel type (`WhatsApp` | `Line` | `AppleBusinessChat` | `Facebook` | `Text`) plus its type-specific inputs and drives it to an activated `MessagingChannel`. It first gates on the Enhanced Messaging Terms and Conditions, then runs four steps:
23
+ Takes a channel type (`WhatsApp` | `Line` | `AppleBusinessChat` | `Facebook` | `Text`) plus its type-specific inputs and drives it to an activated `MessagingChannel`. It first gates on the Enhanced Messaging Terms and Conditions, then runs four core steps plus an optional settings step:
24
24
 
25
25
  0. **Accept Terms and Conditions** — renders the Enhanced Messaging disclaimer and requires the user to certify they have authority to bind their org, mirroring the in-org "Add a Channel" wizard. Blocking — a decline ends the run before any org work. *(Stage 0.5, in this skill)*
26
- 1. **Insert the channel** — invokes `service-de-channel-create`, which handles the per-type third-party prereq internally (e.g. WhatsApp's `service-de-waba-integrate` runs inside `service-de-channel-create`). *(skill: `service-de-channel-create`)*
26
+ 1. **Insert the channel** — invokes `service-de-channel-create`, which handles each type's third-party prereq (e.g. WhatsApp's `service-de-waba-integrate`). *(skill: `service-de-channel-create`)*
27
27
  2. **Configure routing** — sets `SessionHandlerId` to an Omni-Channel Queue (pick existing or create new). Message-type-agnostic. *(skill: `service-de-channel-routing-configure`)*
28
- 3. **Configure consent** — ensures a valid `ConsentType` + matching `MsgChannelLanguageKeyword` record. The Connect insert auto-seeds a default `ConsentType=ImplicitOptIn` + opt-out keyword, so on a fresh channel this step is frequently a **no-op** — or an *upgrade* if the caller wants ExplicitOptIn/DoubleOptIn. Activation's readiness check requires both routing AND consent, so this runs before activation. *(skill: `service-de-channel-settings-configure`)*
29
- 4. **Activate** — PATCHes `MessagingChannelUsage.DeploymentStatus` to `Provisioning` via REST; the server-side save-hook drives the full observer chain synchronously and returns 204 once the MCU reaches `Active` and `MessagingChannel.IsActive=true`. Message-type-agnostic. *(skill: `service-de-channel-activate`)*
28
+ 3. **Configure consent** — ensures a valid `ConsentType` + matching `MsgChannelLanguageKeyword` record (often a **no-op**: the insert auto-seeds `ImplicitOptIn`). Activation's readiness check needs routing AND consent, so this runs before activation. *(skill: `service-de-channel-settings-configure`)*
29
+ 4. **Activate** — PATCHes `MessagingChannelUsage.DeploymentStatus` to `Provisioning`; the save-hook runs synchronously and returns 204 once the channel is `IsActive=true`. Message-type-agnostic. *(skill: `service-de-channel-activate`)*
30
+ 5. **Configure requested settings** — only if the request asked for auto-responses, keywords, or session inactivity. Runs **after** activation and is **non-blocking**: a failure is a warning, never a failed run, and every requested setting is reported as configured, not applicable, or failed. *(skill: `service-de-channel-settings-configure`, Stage 4.5)*
30
31
 
31
- **Resume-by-default.** Each step is idempotent — if you re-run after a failure, the orchestrator detects existing state and skips steps that already succeeded.
32
+ **Resume-by-default.** Each step is idempotent: a re-run detects existing state and skips steps that already succeeded.
32
33
 
33
- **Prompt mid-flow.** If `{MESSAGE_TYPE}` isn't in the initial request, the orchestrator asks upfront. Routing choices (pick queue / create new) are prompted when step 2 runs, not upfront — keeps leaf skills self-contained.
34
+ **Prompt mid-flow.** A missing `{MESSAGE_TYPE}` is asked upfront; routing choices are prompted when step 2 runs.
34
35
 
35
36
  ## Reference File Index
36
37
 
@@ -40,8 +41,9 @@ Takes a channel type (`WhatsApp` | `Line` | `AppleBusinessChat` | `Facebook` | `
40
41
  | `references/terms-and-conditions.md` | Rendering the Stage 0.5 disclaimer and certification prompt — verbatim text and per-type label/third-party mappings. |
41
42
  | `references/output-envelopes.md` | Wiring error handling or parsing the canonical success/failure/terms-declined JSON envelope shapes. |
42
43
  | `references/partial-success.md` | The orchestrator fails mid-way and you need to render the partial-success/resume report. |
43
- | `references/gotchas.md` | Debugging unexpected behavior — duplicate-key errors, resume/idempotency questions, preflight SOQL shape, unattended/CI usage. |
44
- | `references/worked-examples.md` | You need a reference trace (fresh WhatsApp run, resume after failure, Apple dispatch, unsupported-type rejection) for exact envelope shapes. |
44
+ | `references/gotchas.md` | Debugging unexpected behavior — duplicate-key errors, resume/idempotency questions, preflight SOQL shape, unattended/CI usage, dropped settings, missing AuthProvider. |
45
+ | `references/requested-settings.md` | Running Stage 4.5 (auto-responses, keywords, inactivity) or rendering requested settings in the Stage 5 report. |
46
+ | `references/worked-examples.md` | You need a reference trace (fresh run, resume, Apple dispatch, unsupported type, requested settings) for exact envelope shapes. |
45
47
 
46
48
  ---
47
49
 
@@ -51,32 +53,28 @@ Takes a channel type (`WhatsApp` | `Line` | `AppleBusinessChat` | `Facebook` | `
51
53
 
52
54
  When you invoke a leaf skill (service-de-channel-create, service-de-channel-routing-configure, service-de-channel-settings-configure, service-de-channel-activate) and it returns via function_results:
53
55
 
54
- - **DO:** Immediately parse the function_results return value and continue to the next stage
55
- - **DO:** Run Stage 0.5 → Stage 1 → Stage 2 → Stage 3 → Stage 3.5 → Stage 4 → Stage 5 consecutively in ONE response
56
- - **DO NOT:** Stop and report back to the user between stages
57
- - **DO NOT:** Wait for user confirmation between stages
58
- - **DO NOT:** Treat each stage as a separate turn in the conversation
56
+ - **DO:** Parse the return value immediately and run Stages 0.5 → 1 → 2 → 3 → 3.5 → 4 → 4.5 → 5 consecutively in ONE response
57
+ - **DO NOT:** Stop, report back, or wait for confirmation between stages, or treat each stage as a separate turn
59
58
 
60
- **Why this matters:** The user invoked THIS orchestrator skill to get an end-to-end activated channel. They did NOT invoke the individual leaf skills. Your job is to run the entire pipeline autonomously and report the final result. Stopping mid-flow breaks the orchestrator pattern and forces the user to manually resume each stage.
59
+ **Why:** the user asked for an end-to-end activated channel; stopping mid-flow forces them to resume each stage by hand.
61
60
 
62
- **Exception:** Only stop mid-flow if a leaf skill returns `ok: false` with a terminal error (not a recoverable prompt), or if the user declines the Stage 0.5 Terms and Conditions gate (emit `terms-not-accepted` and halt). Then report the failure immediately with context about which stage failed and what state was reached.
61
+ **Exception:** Only stop mid-flow if a leaf skill returns `ok: false` with a terminal error (not a recoverable prompt), or if the user declines the Stage 0.5 Terms and Conditions gate (emit `terms-not-accepted` and halt). The WhatsApp OTP prompts in `service-de-channel-activate` are also an allowed pause — wait for the user's input, then continue. Then report the failure immediately with context about which stage failed and what state was reached.
63
62
 
64
- **Stage 0.5 is a required blocking prompt.** The Terms and Conditions gate is the one prompt that must be answered affirmatively before any org work. It is not optional and must not be auto-accepted. A `no`/decline ends the run per the exception above; a `yes` continues to Stage 1 in the same response.
63
+ **Stage 0.5 is a required blocking prompt** — never auto-accepted. A decline ends the run; a `yes` continues to Stage 1 in the same response.
65
64
 
66
- **Leaf skill prompts:** Some leaf skills (like `service-de-waba-integrate` or `service-de-channel-routing-configure`) may prompt the user for input mid-execution. That's fine — answer those prompts as they come up, but then CONTINUE to the next stage immediately after the prompt is answered. Don't stop just because a prompt was involved.
65
+ **Leaf skill prompts:** leaves like `service-de-waba-integrate` or `service-de-channel-routing-configure` may prompt mid-execution. Once a prompt is answered, CONTINUE to the next stage immediately.
67
66
 
68
67
  ---
69
68
 
70
69
  ## When NOT to use this skill
71
70
 
72
- - **You only want one step.** Invoke the leaf skill directly (`service-de-channel-create`, `service-de-channel-routing-configure`, `service-de-channel-activate`). This orchestrator is for the full automated path from nothing → activated channel.
73
- - **You want to run stages independently in separate conversation turns.** This orchestrator runs all stages consecutively in one response. If you need manual control between stages, invoke the leaf skills individually.
74
- - **You want a message type outside `WhatsApp` / `Line` / `AppleBusinessChat` / `Facebook` / `Text`.** The dispatcher will return `unsupported-type`. WeChat / MsCopilot / Alexa would need their own leaves + a dispatcher update.
75
- - **The prereq hasn't been met (WABA not shared, LINE channel not created, Apple account not registered, SMS number not provisioned).** The per-type insert skill's Stage 2-equivalent surfaces this clearly and returns; no orchestration fixes it. (For SMS/Text the number-provisioning prereq isn't checked at insert — an unprovisioned number surfaces later as an activation-time `provisioning-error`.)
71
+ - **You only want one step, or manual control between stages.** Invoke the leaf skill directly (`service-de-channel-create`, `service-de-channel-routing-configure`, `service-de-channel-settings-configure`, `service-de-channel-activate`).
72
+ - **You want a message type outside `WhatsApp` / `Line` / `AppleBusinessChat` / `Facebook` / `Text`.** The dispatcher returns `unsupported-type`.
73
+ - **The prereq hasn't been met (WABA not shared, LINE channel not created, Apple account not registered, SMS number not provisioned).** The per-type insert skill surfaces this and returns. (SMS number provisioning isn't checked at insert — it surfaces later as an activation `provisioning-error`.)
76
74
 
77
75
  ## Inputs (from user)
78
76
 
79
- `{MESSAGE_TYPE}` (prompted if omitted) and `{ORG_ALIAS}` (optional), plus type-specific fields for WhatsApp, LINE, AppleBusinessChat, Facebook, and Text (SMS) forwarded to the dispatcher. **Load `references/inputs.md` and follow it** for the full field list and the omitted-type prompt text.
77
+ `{MESSAGE_TYPE}` (prompted if omitted) and `{ORG_ALIAS}` (optional), plus type-specific fields for WhatsApp, LINE, AppleBusinessChat, Facebook, and Text (SMS) forwarded to the dispatcher. Optional: `{QUEUE}` (a queue the user named for routing) and `{REQUESTED_SETTINGS}` (auto-responses, keywords, inactivity, consent upgrade — extracted from the request). **Load `references/inputs.md` and follow it** for the full field list, the omitted-type prompt text, and how to extract `{REQUESTED_SETTINGS}`.
80
78
 
81
79
  ## Output (to user)
82
80
 
@@ -88,7 +86,7 @@ Three top-level outcomes: success, step-annotated failure, and terms-declined. *
88
86
 
89
87
  If `{MESSAGE_TYPE}` is omitted, prompt the user (see "Inputs" above). Refuse to proceed without one — there's no sensible default.
90
88
 
91
- Once known, determine the **preflight key** — the field we'll filter the `MessagingChannel` SOQL on to detect existing state. It's always `MessagingPlatformKey`, but what that value *is* varies by type:
89
+ Once known, determine the **preflight key** used to detect existing state. It's always `MessagingPlatformKey`, but its value varies by type:
92
90
 
93
91
  | `{MESSAGE_TYPE}` | Preflight key value `{PLATFORM_KEY}` | Notes |
94
92
  | --- | --- | --- |
@@ -98,15 +96,15 @@ Once known, determine the **preflight key** — the field we'll filter the `Mess
98
96
  | `Facebook` | `{PAGE_ID}` | Optional - OAuth → fetch pages → prompt if not provided |
99
97
  | `Text` | `{SMS_NUMBER}` | Required upfront (the phone number / short code itself) |
100
98
 
101
- **Facebook is unique:** If `{PAGE_ID}` is not provided, the orchestrator cannot run its own Stage 1 preflight. Instead, skip Stage 1 and let `service-de-channel-create` handle the full OAuth → page selection → preflight → creation flow. The insertion skill has its own Stage 1 preflight that runs after page selection.
99
+ For non-Facebook types, validate the required type-specific inputs now; if missing, prompt or halt rather than letting the dispatcher return `missing-input`.
102
100
 
103
- For non-Facebook types, validate that the caller provided the required type-specific inputs for `{MESSAGE_TYPE}` (see Inputs above). If missing, prompt or halt — don't call the dispatcher, it will re-validate and return `missing-input`, wasting a round trip.
101
+ **Capture `{REQUESTED_SETTINGS}` now:** each auto-response, keyword group, inactivity timeout, or consent upgrade in the request is a separate item (mapping in `references/inputs.md`). Also record `{QUEUE}` if the user named one. Every item must be accounted for in the Stage 5 report — none may be silently dropped.
104
102
 
105
103
  ---
106
104
 
107
105
  ## Stage 0.5: Enhanced Messaging Terms and Conditions (blocking gate)
108
106
 
109
- **Run this before any org query or channel work.** The in-org "Add a Channel" wizard requires the admin to accept the Enhanced Messaging Terms and Conditions before it will let them proceed to channel setup. The headless flow must enforce the same gate — do not skip it, do not accept on the user's behalf. This runs once per orchestrator invocation, after `{MESSAGE_TYPE}` is known (the disclaimer names the channel) and before Stage 1.
107
+ **Run this before any org query or channel work.** Do not skip it or accept on the user's behalf. It runs once per invocation, after `{MESSAGE_TYPE}` is known (the disclaimer names the channel).
110
108
 
111
109
  **Render the disclaimer and certification prompt from `references/terms-and-conditions.md` (verbatim, substituting the channel label) — load it and follow it for the exact wording and per-type label/third-party mappings.**
112
110
 
@@ -118,15 +116,15 @@ For non-Facebook types, validate that the caller provided the required type-spec
118
116
  {"ok": false, "kind": "terms-not-accepted",
119
117
  "hint": "user did not accept the Enhanced Messaging Terms and Conditions — channel setup cannot proceed. Re-run when ready to accept."}
120
118
  ```
121
- - Acceptance is required on **every** orchestrator invocation, including resume runs. It is a per-session gate, not persisted — we don't have a place to durably record it, and the cost of re-confirming is one prompt.
119
+ - Acceptance is required on **every** invocation, including resume runs — it isn't persisted.
122
120
 
123
121
  ---
124
122
 
125
123
  ## Stage 1: Pre-flight state detection (resume support)
126
124
 
127
- **Skip this stage entirely if `MESSAGE_TYPE=Facebook` and `{PAGE_ID}` was not provided.** The Facebook insertion skill needs to run OAuth first before we know which PAGE_ID to check for. Let the insertion skill handle its own preflight in Stage 1 after page selection.
125
+ **Skip this stage entirely if `MESSAGE_TYPE=Facebook` and `{PAGE_ID}` was not provided** — the page isn't known until OAuth, and `service-de-channel-create` runs its own preflight after page selection.
128
126
 
129
- For all other cases, query the org to see how far a prior run got. This enables skip-ahead on resume. **Two queries, not a subquery** — the `(SELECT ... FROM MessagingChannelUsages)` subquery fails on some orgs where the child relationship is unnameable. Use FK-keyed second query instead (see gotcha #9).
127
+ For all other cases, query the org to see how far a prior run got. This enables skip-ahead on resume. **Two queries, not a subquery** — the `MessagingChannelUsages` child relationship is unnameable on some orgs (gotcha #9).
130
128
 
131
129
  ```bash
132
130
  sf data query --target-org '{ORG_ALIAS}' \
@@ -149,11 +147,19 @@ Parse the combined result to figure out `{CURRENT_STATE}`:
149
147
  | No records | `fresh` | Step 1 (insert) |
150
148
  | Record exists, `IsActive=false`, `SessionHandlerId=null` and `FallbackQueueId=null` | `inserted-no-routing` | Step 2 (configure routing) |
151
149
  | Record exists, `IsActive=false`, routing set | `routed-not-active` | Step 3 (configure consent), then Step 4 (activate) |
152
- | Record exists, `IsActive=true` | `already-active` | Emit no-op success envelope; return. |
150
+ | Record exists, `IsActive=true` | `already-active` | If `{REQUESTED_SETTINGS}` is empty: emit the no-op success envelope and return. Otherwise skip insert, route, and activate (add them to `STEPS_SKIPPED`). Run Stage 3.5 if a consent upgrade is requested, else add `consent` to `STEPS_SKIPPED`. Then run Stage 4.5. **Never return a no-op success while requested settings are outstanding.** |
153
151
 
154
- Record the existing `{CHANNEL_ID}` and `{MCU_ID}` if present — downstream steps need them.
152
+ Record the existing `{CHANNEL_ID}` and `{MCU_ID}` if present. Initialize `{STEPS_RUN} = []`, `{STEPS_SKIPPED} = []`, `{T0} = Date.now()` before applying the row above.
155
153
 
156
- Initialize `{STEPS_RUN} = []`, `{STEPS_SKIPPED} = []`, `{T0} = Date.now()`.
154
+ **AuthProvider preflight (fresh channels, every type except `Text`).** When `CURRENT_STATE=fresh` (or Stage 1 was skipped for Facebook), confirm the org-global `LiveMessageSetup` AuthProvider exists before starting the insert — every non-Text insert needs it, and so does WhatsApp's WABA-manage call:
155
+
156
+ ```bash
157
+ sf data query --target-org '{ORG_ALIAS}' \
158
+ --query "SELECT Id FROM AuthProvider WHERE DeveloperName = 'LiveMessageSetup'" \
159
+ --json > /tmp/hcs-authprovider.json
160
+ ```
161
+
162
+ Zero rows → halt with `failedStep: "insert"`, `failedStepIndex: 1`, `kind: "missing-authprovider"`, and render the missing-AuthProvider message from `references/output-envelopes.md`. It's a known manual prerequisite (gotcha #11); catching it here avoids a wasted OAuth round trip or WABA prompt.
157
163
 
158
164
  ---
159
165
 
@@ -167,7 +173,7 @@ Otherwise invoke `service-de-channel-create` with:
167
173
  - All type-specific inputs (forwarded verbatim — dispatcher routes to the right leaf)
168
174
  - `{ORG_ALIAS}`
169
175
 
170
- The insertion skill handles per-type prereqs internally (e.g., for WhatsApp, `service-de-channel-create` invokes `service-de-waba-integrate` as its Stage 2). This orchestrator doesn't need to know about WABA linking, LINE token verification, or Apple registration — `service-de-channel-create` owns the prereq semantics for whichever type it's running.
176
+ `service-de-channel-create` owns the per-type prereqs (WABA linking, LINE token verification, Apple registration).
171
177
 
172
178
  Handle the envelope:
173
179
 
@@ -175,11 +181,10 @@ Handle the envelope:
175
181
  | --- | --- |
176
182
  | `{ok: true, channelId, mcuId, ...}` | Record `{CHANNEL_ID}` and `{MCU_ID}`. Append `"insert"` to `STEPS_RUN`. Continue. |
177
183
  | `{ok: false, kind: "partnership-blocked" \| "user-declined" \| "apple-registration-pending" \| "line-prereq-missing"}` | These come from the per-type prereq stage. Pass through as `failedStep: "insert"`, `failedStepIndex: 1`. Return. |
184
+ | `{ok: false, kind: "unified-messaging-required"}` | WhatsApp on a DE Unlimited Access org, which only allows Unified Messaging WhatsApp. Pass through the leaf's `hint` as `failedStep: "insert"` (re-running won't fix it). Return. |
178
185
  | `{ok: false, kind: "missing-input" \| "unsupported-type"}` | Should have been caught in Stage 0 — emit failure with `failedStep: "insert"` and a note that the caller's inputs were incomplete. |
179
186
  | `{ok: false, kind: <anything else>}` | Emit failure envelope with `failedStep: "insert"`, `failedStepIndex: 1`. Return. |
180
187
 
181
- At this point we have `{CHANNEL_ID}` and `{MCU_ID}` regardless of whether step 1 ran or was skipped.
182
-
183
188
  **→ Continue immediately to Stage 3 in this same response. DO NOT STOP.**
184
189
 
185
190
  ---
@@ -191,9 +196,10 @@ Skip this stage if `CURRENT_STATE === "routed-not-active"` — routing is alread
191
196
  Otherwise invoke `service-de-channel-routing-configure`:
192
197
 
193
198
  - `{CHANNEL_ID}` = recorded above
199
+ - `{QUEUE}` = the queue the user named, if any (the leaf validates it and only prompts if it's ineligible)
194
200
  - `{ORG_ALIAS}`
195
201
 
196
- This is the step that **prompts the user** for queue choice (pick existing / create new / escape hatch). Don't try to pre-empt the prompts — forward the user's answers as-is.
202
+ Without a `{QUEUE}`, this step **prompts the user** for queue choice. Don't pre-empt the prompts — forward the answers as-is.
197
203
 
198
204
  Handle the envelope:
199
205
 
@@ -209,22 +215,24 @@ Handle the envelope:
209
215
 
210
216
  ## Stage 3.5: Configure consent (before activation)
211
217
 
218
+ Skip if `already-active` with no consent upgrade requested (Stage 1 logged it skipped). A requested upgrade on a live channel runs here — Stage 4.5 never applies consent.
219
+
212
220
  Activation's readiness check requires **consent AND routing** — a fully-routed channel still fails to activate if consent isn't configured. Invoke `service-de-channel-settings-configure`:
213
221
 
214
222
  - `{CHANNEL_ID}` = recorded above
215
223
  - `{CONSENT_TYPE}`, `{LANGUAGE}`, and the keyword/prompt values — forward whatever the user supplied; omit what they didn't
216
224
  - `{ORG_ALIAS}`
217
225
 
218
- This stage **ensures consent is activation-ready** — it doesn't always write. The Connect insert **auto-seeds** `ConsentType=ImplicitOptIn` plus a default opt-out `MsgChannelLanguageKeyword`, which already satisfies the readiness check. So the leaf's Stage 1 will frequently find the channel *already* ready and return `noop: true` — the expected outcome on a fresh `ImplicitOptIn` channel, not a bug. It performs a **real write only** to upgrade (ExplicitOptIn/DoubleOptIn) or override the seeded keywords/prompts. When the user pre-supplied inputs asking for an upgrade, expect a write and let the leaf prompt for missing values — don't suppress those prompts.
226
+ Pass **only the `consent` facet** here — consent upgrades and keywords given with a consent type are resolved in this stage; the metadata facets (auto-responses, keywords, inactivity) wait for Stage 4.5 so a metadata-deploy failure can't block activation.
227
+
228
+ The insert auto-seeds `ImplicitOptIn` plus a default opt-out keyword, so `noop: true` is normal on a fresh channel. The leaf writes only to upgrade (ExplicitOptIn/DoubleOptIn) or override the seeded keywords/prompts, and prompts for missing values.
219
229
 
220
230
  Handle the envelope:
221
231
 
222
232
  | Leaf envelope | Orchestrator action |
223
233
  | --- | --- |
224
234
  | `{ok: true, ...}` (including `noop: true`) | Append `"consent"` to `STEPS_RUN` (or `STEPS_SKIPPED` if `noop`). Continue. |
225
- | `{ok: false, kind: "not-enhanced"}` | Shouldn't happen — these skills only create Enhanced channels. Emit failure with `failedStep: "consent"`. Return. |
226
- | `{ok: false, kind: "missing-consent-input", hint}` | The user didn't supply a required keyword/prompt for the chosen ConsentType. Emit failure with `failedStep: "consent"` and pass through the `hint`. Return. |
227
- | `{ok: false, ...}` (any other kind — `channel-patch-failed`, `keyword-record-failed`, `verify-failed`, or an unrecognized envelope) | Emit failure with `failedStep: "consent"` and pass through the leaf's `kind` and message verbatim. Return. |
235
+ | `{ok: false, ...}` (`missing-consent-input`, `not-enhanced`, `channel-patch-failed`, `keyword-record-failed`, `verify-failed`, or anything else) | Emit failure with `failedStep: "consent"`, passing through the leaf's `kind`, message, and `hint` verbatim. Return. |
228
236
 
229
237
  **→ Continue immediately to Stage 4 in this same response. DO NOT STOP.**
230
238
 
@@ -232,49 +240,41 @@ Handle the envelope:
232
240
 
233
241
  ## Stage 4: Activate (step 4 of 4)
234
242
 
235
- Always run (unless `CURRENT_STATE === "already-active"`, in which case Stage 1 returned early).
243
+ Skip if `CURRENT_STATE === "already-active"` (Stage 1 already added `"activate"` to `STEPS_SKIPPED`).
236
244
 
237
245
  Invoke `service-de-channel-activate`:
238
246
 
239
247
  - `{CHANNEL_ID}` = recorded above
240
248
  - `{ORG_ALIAS}`
241
249
 
242
- No timeout knobs — activation is a single synchronous PATCH. The leaf does a defensive poll if the server ever returns mid-transition, but the expected path is one round-trip.
243
-
244
250
  Handle the envelope:
245
251
 
246
252
  | Leaf envelope | Orchestrator action |
247
253
  | --- | --- |
248
- | `{ok: true, isActive: true, ...}` (including `noop: true`) | Record results. Append `"activate"` to `STEPS_RUN`. Continue to Stage 5. |
249
- | `{ok: false, kind: "no-routing"}` | Unusual (we just set it) — probably a race or permission issue. Emit failure with a hint about the permissions check. Return. |
250
- | `{ok: false, kind: "no-mcu" \| "channel-missing"}` | Shouldn't happen after successful insert. Emit failure with the leaf's envelope. Return. |
251
- | `{ok: false, kind: "readiness-failed", errorMessage}` | `validateChannelReadinessOnProvisioning` rejected the PATCH — missing consent (STOP/HELP keyword record). Stage 3.5 should have caught this; if it re-appears, re-run `service-de-channel-settings-configure` for the channel. Emit failure and pass through the resume hint. Return. |
254
+ | `{ok: true, isActive: true, ...}` (including `noop: true`) | Record results. Append `"activate"` to `STEPS_RUN`. Continue to Stage 4.5. |
255
+ | `{ok: false, kind: "no-routing" \| "no-mcu" \| "channel-missing"}` | Unexpected after Stages 2–3 (race or permissions). Emit failure with the leaf's envelope. Return. |
256
+ | `{ok: false, kind: "readiness-failed", errorMessage}` | Missing consent (STOP/HELP keyword record) — Stage 3.5 should have caught it. Emit failure; resume hint: re-run `service-de-channel-settings-configure`. Return. |
252
257
  | `{ok: false, kind: "provisioning-error", errorReason, errorDetails}` | Third-party side rejected (Meta `/register` failed, etc.). MCU is now in `Error`. Emit failure and pass through `errorReason`/`errorDetails`. Return. |
258
+ | `{ok: false, kind: "verification-declined" \| "verification-request-failed" \| "verification-failed"}` | WhatsApp OTP verification didn't complete. Emit failure, pass through `errorDetails`/`message`; resume hint: re-run to retry verification. Return. |
253
259
  | `{ok: false, kind: "auth" \| "transport"}` | REST call failed at the HTTP layer (401 from `sf` auth, 5xx from the instance). Pass through. Return. |
254
260
 
261
+ **→ Continue immediately to Stage 4.5 in this same response. DO NOT STOP.**
262
+
263
+ ---
264
+
265
+ ## Stage 4.5: Configure requested settings (non-blocking)
266
+
267
+ Skip if `{REQUESTED_SETTINGS}` has no auto-response, keyword, or inactivity items. Otherwise invoke `service-de-channel-settings-configure` once with the requested facets and the user's values, then classify each item as `configured`, `notApplicable`, or `failed`. **Never fail the run here** — the channel is already live, so failures become Stage 5 warnings. **Load `references/requested-settings.md` and follow it** for what to forward, per-type applicability, the classification table, and the Facebook metadata defect.
268
+
269
+ **→ Continue immediately to Stage 5 in this same response. DO NOT STOP.**
270
+
255
271
  ---
256
272
 
257
273
  ## Stage 5: Final report
258
274
 
259
- Build the success envelope:
260
-
261
- ```json
262
- {
263
- "ok": true,
264
- "messageType": "{MESSAGE_TYPE}",
265
- "channelId": "{CHANNEL_ID}",
266
- "mcuId": "{MCU_ID}",
267
- "channelName": "{CHANNEL_NAME or inferred}",
268
- "sessionHandlerId": "{SESSION_HANDLER_ID}",
269
- "queueName": "{QUEUE_NAME}",
270
- "isActive": true,
271
- "stepsRun": [...],
272
- "stepsSkipped": [...],
273
- "totalDurationMs": Date.now() - T0
274
- }
275
- ```
275
+ Build the success envelope (`ok`, `messageType`, `channelId`, `mcuId`, `channelName`, `sessionHandlerId`, `queueName`, `isActive`, `stepsRun`, `stepsSkipped`, `settings`, `totalDurationMs = Date.now() - T0`; exact shape in `references/output-envelopes.md`).
276
276
 
277
- Render to the user as:
277
+ Include `settings` only when `{REQUESTED_SETTINGS}` was non-empty. Render to the user as:
278
278
 
279
279
  ```text
280
280
  Success — {MESSAGE_TYPE} channel '{CHANNEL_NAME}' is live on {ORG_ALIAS}.
@@ -284,7 +284,7 @@ Success — {MESSAGE_TYPE} channel '{CHANNEL_NAME}' is live on {ORG_ALIAS}.
284
284
  Total time: {formatted from durationMs}
285
285
  ```
286
286
 
287
- If any step was skipped due to resume, the report should make that visible.
287
+ If any step was skipped due to resume, the report should make that visible. With requested settings, add the "Requested settings" block and the failure warning from `references/requested-settings.md` — every Stage 0 item must land in exactly one bucket.
288
288
 
289
289
  ---
290
290
 
@@ -294,12 +294,6 @@ If the orchestrator fails mid-way, the envelope always includes `stateSoFar` des
294
294
 
295
295
  ---
296
296
 
297
- ## Worked examples
298
-
299
- For reference traces (fresh WhatsApp run, resume after routing failure, Apple dispatch, unsupported-type rejection), see `references/worked-examples.md`.
300
-
301
- ---
302
-
303
297
  ## Gotchas
304
298
 
305
- Nine known gotchas covering prereq ownership, `MessagingPlatformKey` uniqueness, resume semantics, CSOT-only support, error-classification boundaries, prompt placement, platform-key mapping, wall-clock duration, and the two-query preflight workaround. **When debugging unexpected behavior, load `references/gotchas.md` and follow it.**
299
+ Eleven known gotchas (resume semantics, preflight shape, error classification, dropped settings, the `LiveMessageSetup` prerequisite, and more). **When debugging unexpected behavior, load `references/gotchas.md` and follow it.** For reference traces, see `references/worked-examples.md`.