@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.
- package/package.json +1 -1
- package/skills/data360-code-extension-generate/SKILL.md +160 -252
- package/skills/data360-code-extension-generate/references/README.md +34 -172
- package/skills/data360-code-extension-generate/references/environment-setup.md +198 -0
- package/skills/data360-code-extension-generate/references/mcp-integration.md +36 -0
- package/skills/data360-code-extension-generate/references/quick-reference.md +132 -202
- package/skills/data360-code-extension-generate/references/run-logs.md +31 -0
- package/skills/data360-code-extension-generate/references/schema-discovery.md +45 -0
- package/skills/data360-code-extension-generate/references/troubleshooting.md +45 -0
- package/skills/data360-code-extension-generate/scripts/check_env.sh +197 -0
- package/skills/data360-code-extension-generate/scripts/venv_hook.sh +22 -0
- package/skills/dx-devops-work-item-manage/SKILL.md +24 -8
- package/skills/dx-devops-work-item-manage/examples/common-workflows.md +32 -0
- package/skills/dx-devops-work-item-manage/references/review-api.md +95 -0
- package/skills/dx-org-manage/SKILL.md +12 -12
- package/skills/dx-org-manage/examples/scratch-orgs/display_output.json +1 -3
- package/skills/dx-org-manage/examples/scratch-orgs/success_shape.json +1 -3
- package/skills/dx-org-manage/references/opening-org.md +1 -1
- package/skills/dx-org-manage/references/scratch-org-operations.md +15 -20
- package/skills/dx-packaging-move-to-2gp-migrate/SKILL.md +1 -1
- package/skills/education-cloud-academic-calendar-generate/SKILL.md +2 -2
- package/skills/education-cloud-course-catalog-migrate/SKILL.md +1 -1
- package/skills/education-cloud-domain-configure/references/domain-features/recruitment-admissions.md +8 -7
- package/skills/education-cloud-multi-campus-configure/SKILL.md +1 -0
- package/skills/education-cloud-multi-campus-configure/references/error_handling.md +7 -6
- package/skills/education-cloud-student-recruitment-agent-configure/SKILL.md +2 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/customer-narration.md +2 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/flows.md +1 -1
- package/skills/education-cloud-student-recruitment-agent-configure/references/grounding.md +5 -4
- package/skills/education-cloud-student-recruitment-agent-configure/references/permissions.md +1 -1
- package/skills/education-cloud-student-recruitment-agent-configure/references/prerequisites.md +1 -1
- package/skills/education-cloud-student-recruitment-agent-configure/references/routing.md +1 -1
- package/skills/experience-cms-content-type-generate/SKILL.md +7 -6
- package/skills/experience-cms-content-type-generate/references/agent-checklist.md +3 -3
- package/skills/experience-cms-content-type-generate/references/anti-patterns.md +2 -2
- package/skills/experience-cms-content-type-generate/references/discovery-details.md +1 -1
- package/skills/experience-cms-content-type-generate/references/retrieve-and-reconcile.md +5 -9
- package/skills/experience-ui-bundle-custom-app-generate/scripts/resolve-uibundle-path.mjs +10 -0
- package/skills/field-service-data-capture-migrate/references/converter-builder-contract.md +2 -2
- package/skills/field-service-data-capture-migrate/references/fsm-dc-capability-catalog.md +2 -2
- package/skills/field-service-data-capture-migrate/scripts/analyze_flow.py +1 -1
- package/skills/field-service-data-capture-migrate/scripts/convert_to_dc_spec.py +1 -1
- package/skills/field-service-data-capture-migrate/scripts/fsm_dc_catalog.py +2 -2
- package/skills/field-service-data-capture-migrate/scripts/generate_summary.py +2 -2
- package/skills/platform-custom-application-generate/SKILL.md +97 -104
- package/skills/platform-custom-application-generate/references/app-properties.md +52 -0
- package/skills/platform-custom-application-generate/references/app-visibility.md +19 -0
- package/skills/platform-custom-application-generate/references/utility-bar.md +55 -0
- package/skills/platform-datamask-run/SKILL.md +1 -1
- package/skills/platform-datamask-run/references/policy-authoring.md +41 -18
- package/skills/platform-dsar-policy-manage/SKILL.md +7 -6
- package/skills/platform-dsar-policy-manage/references/export-and-history.md +10 -8
- package/skills/platform-dsar-policy-manage/references/report-format.md +4 -2
- package/skills/platform-metadata-grounding-get/SKILL.md +7 -7
- package/skills/platform-report-generate/SKILL.md +9 -7
- package/skills/platform-report-generate/references/column-names.md +12 -1
- package/skills/platform-report-generate/references/errors-and-troubleshooting.md +1 -1
- package/skills/platform-sharing-rules-generate/SKILL.md +12 -3
- package/skills/platform-sharing-rules-generate/references/rule-types.md +1 -0
- package/skills/service-agentforce-channel-configure/SKILL.md +6 -3
- package/skills/service-agentforce-channel-configure/references/agent-wiring.md +5 -3
- package/skills/service-agentforce-channel-configure/references/channel-branch-email.md +24 -15
- package/skills/service-agentforce-channel-configure/references/input-validation.md +23 -0
- package/skills/service-agentforce-channel-configure/references/live-traffic-gate.md +13 -7
- package/skills/service-agentforce-channel-configure/references/queue-resolution.md +3 -1
- package/skills/service-agentforce-human-escalation-configure/references/_vendored/input-validation.md +23 -0
- package/skills/service-agentforce-human-escalation-configure/references/_vendored/queue-resolution.md +146 -0
- package/skills/service-agentforce-human-escalation-configure/references/escalation-mechanism.md +1 -1
- package/skills/service-agentforce-human-escalation-configure/scripts/tests/_bootstrap.py +42 -11
- package/skills/service-agentforce-human-escalation-configure/scripts/tests/test_escalation_contracts.py +45 -0
- package/skills/service-agentforce-human-escalation-configure/scripts/verify-and-configure.sh +23 -9
- package/skills/service-de-channel-activate/SKILL.md +10 -10
- package/skills/service-de-channel-activate/references/gotchas.md +4 -4
- package/skills/service-de-channel-activate/references/phone-verification.md +43 -19
- package/skills/service-de-channel-create/SKILL.md +1 -1
- package/skills/service-de-channel-create/references/facebook.md +1 -1
- package/skills/service-de-channel-create/references/whatsapp.md +33 -6
- package/skills/service-de-channel-routing-configure/SKILL.md +5 -1
- package/skills/service-de-channel-routing-configure/references/gotchas.md +3 -1
- package/skills/service-de-channel-routing-configure/references/named-queue.md +39 -0
- package/skills/service-de-channel-settings-configure/SKILL.md +3 -1
- package/skills/service-de-channel-settings-configure/references/channel-settings-facets.md +2 -2
- package/skills/service-de-channel-settings-configure/references/gotchas.md +12 -1
- package/skills/service-de-headless-channel-configure/SKILL.md +68 -74
- package/skills/service-de-headless-channel-configure/references/gotchas.md +6 -2
- package/skills/service-de-headless-channel-configure/references/inputs.md +19 -0
- package/skills/service-de-headless-channel-configure/references/output-envelopes.md +23 -1
- package/skills/service-de-headless-channel-configure/references/partial-success.md +1 -0
- package/skills/service-de-headless-channel-configure/references/requested-settings.md +55 -0
- package/skills/service-de-headless-channel-configure/references/worked-examples.md +35 -1
- package/skills/service-digital-engagement-channel-configure/SKILL.md +3 -3
- package/skills/service-digital-engagement-channel-configure/references/onboarding_contract.md +2 -2
- package/skills/service-digital-engagement-channel-configure/scripts/check-api-version.sh +1 -1
- package/skills/service-digital-engagement-deployment-configure/SKILL.md +2 -2
- package/skills/service-digital-engagement-deployment-configure/references/onboarding_contract.md +4 -2
- package/skills/service-digital-engagement-deployment-configure/scripts/check-api-version.sh +1 -1
- package/skills/service-omni-command-center-configure/SKILL.md +1 -1
- package/skills/data360-schema-get/SKILL.md +0 -388
- package/skills/data360-schema-get/references/README.md +0 -191
- package/skills/data360-schema-get/scripts/get_dlo_schema.py +0 -244
- package/skills/data360-schema-get/scripts/get_dmo_schema.py +0 -233
- package/skills/field-service-prework-brief-deployer-configure/SKILL.md +0 -646
- package/skills/field-service-voice-to-form-configure/SKILL.md +0 -650
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Queue resolution
|
|
2
|
+
|
|
3
|
+
Run this before any channel wiring. The fallback queue must exist and have the correct `QueueSobject` record for the channel type's SobjectType.
|
|
4
|
+
|
|
5
|
+
## Step 1 — Query existing compatible queues
|
|
6
|
+
|
|
7
|
+
Determine the SobjectType from the channel type (see `references/channel-types.md`), then query:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
sf data query --target-org $ORG --json \
|
|
11
|
+
--query "SELECT Queue.Name, Queue.DeveloperName, Queue.Id
|
|
12
|
+
FROM QueueSobject
|
|
13
|
+
WHERE SobjectType='{SOBJECT_TYPE}'"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Step 2 — Present to user via AskUserQuestion
|
|
17
|
+
|
|
18
|
+
- **One or more found** → present each as an option: `{Queue.Name} ({Queue.DeveloperName})`, plus a final option *"Create a new queue"*. If the user picks an existing queue, capture its `Name`, `DeveloperName`, and `Id` as `QUEUE_NAME`, `QUEUE_DEVELOPER_NAME`, and `QUEUE_ID`, validate all three per [input-validation.md](input-validation.md), and skip queue creation. If one fails its grammar, don't use that queue; offer to create a new one.
|
|
19
|
+
- **Zero found** → inform the user no compatible queue exists; proceed directly to create one.
|
|
20
|
+
|
|
21
|
+
## Step 3 — Create a new queue (if needed)
|
|
22
|
+
|
|
23
|
+
**Naming:** `{ChannelTypeLabel} Queue` / DeveloperName `{Channel_Type_Label}_Queue`
|
|
24
|
+
|
|
25
|
+
Examples:
|
|
26
|
+
- Voice → `Voice Queue` / `Voice_Queue`
|
|
27
|
+
- Enhanced Chat → `Enhanced Chat Queue` / `Enhanced_Chat_Queue`
|
|
28
|
+
- Email → `Email Queue` / `Email_Queue`
|
|
29
|
+
|
|
30
|
+
### 1. Create the Group record
|
|
31
|
+
```bash
|
|
32
|
+
QUEUE_ID=$(sf data create record --target-org $ORG \
|
|
33
|
+
--sobject Group \
|
|
34
|
+
--values "Type='Queue' Name='{QUEUE_NAME}' DeveloperName='{QUEUE_DEVELOPER_NAME}'" \
|
|
35
|
+
--json | python3 -c "import sys,json; print(json.load(sys.stdin)['result']['id'])")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 2. Grant queue access to the correct SobjectType
|
|
39
|
+
```bash
|
|
40
|
+
sf data create record --target-org $ORG \
|
|
41
|
+
--sobject QueueSobject \
|
|
42
|
+
--values "QueueId='$QUEUE_ID' SobjectType='{SOBJECT_TYPE}'"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 3. Add the running user as a queue member
|
|
46
|
+
```bash
|
|
47
|
+
ORG_USERNAME=$(sf org display --target-org $ORG --json \
|
|
48
|
+
| python3 -c "import sys,json; print(json.load(sys.stdin)['result']['username'])")
|
|
49
|
+
UNAME_RE='^[A-Za-z0-9][A-Za-z0-9._@+-]*$'
|
|
50
|
+
[[ "$ORG_USERNAME" =~ $UNAME_RE ]] || { echo "Org username '$ORG_USERNAME' fails the ORG_USERNAME grammar. Stopping."; exit 1; }
|
|
51
|
+
RUNNING_USER_ID=$(sf data query --target-org $ORG --json \
|
|
52
|
+
--query "SELECT Id FROM User WHERE Username='$ORG_USERNAME'" \
|
|
53
|
+
| python3 -c "import sys,json; print(json.load(sys.stdin)['result']['records'][0]['Id'])")
|
|
54
|
+
sf data create record --target-org $ORG \
|
|
55
|
+
--sobject GroupMember \
|
|
56
|
+
--values "GroupId='$QUEUE_ID' UserOrGroupId='$RUNNING_USER_ID'"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Step 4 — Resolve or create a Routing Configuration
|
|
60
|
+
|
|
61
|
+
The queue must have a `QueueRoutingConfig` so Omni-Channel knows how to handle capacity. `QueueRoutingConfig` has **no `QueueId` column** — the link is the reverse direction (the queue's `Group` record points at the config via `QueueRoutingConfigId`), so resolve an existing config through the `Group` record, not by filtering the config on a queue Id:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
sf data query --target-org $ORG --json \
|
|
65
|
+
--query "SELECT QueueRoutingConfigId FROM Group WHERE Id='{QUEUE_ID}'"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- **`QueueRoutingConfigId` is non-null** → the queue already has a routing config; use it as-is and skip creation.
|
|
69
|
+
- **`QueueRoutingConfigId` is null** → create one using the capacity percentage for the channel type, then link it to the queue:
|
|
70
|
+
|
|
71
|
+
| Channel type | `CapacityPercentage` |
|
|
72
|
+
|---|---|
|
|
73
|
+
| Enhanced Chat / Enhanced Messaging | `50` |
|
|
74
|
+
| Voice | `100` |
|
|
75
|
+
| Email-to-Case | `25` |
|
|
76
|
+
|
|
77
|
+
All use `RoutingModel: LeastActive`.
|
|
78
|
+
|
|
79
|
+
`QueueRoutingConfig` uses `MasterLabel` (there is **no `Name` field**), has **no `QueueId`**, and **requires `RoutingPriority`** — a non-nillable integer with no default; set `1`. Create the config standalone, capture its Id, then point the queue's `Group` record at it:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
QRC_ID=$(sf data create record --target-org $ORG \
|
|
83
|
+
--sobject QueueRoutingConfig \
|
|
84
|
+
--values "MasterLabel='{QUEUE_NAME} Routing' DeveloperName='{QUEUE_DEVELOPER_NAME}_Routing' CapacityPercentage={CAPACITY_PERCENTAGE} RoutingModel='LeastActive' RoutingPriority=1 IsAttributeBased=false" \
|
|
85
|
+
--json | python3 -c "import sys,json; print(json.load(sys.stdin)['result']['id'])")
|
|
86
|
+
|
|
87
|
+
# Link is the REVERSE direction — the queue's Group record points at the config:
|
|
88
|
+
sf data update record --target-org $ORG \
|
|
89
|
+
--sobject Group --record-id "{QUEUE_ID}" \
|
|
90
|
+
--values "QueueRoutingConfigId='$QRC_ID'"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Verify the queue now references the config:
|
|
94
|
+
```bash
|
|
95
|
+
sf data query --target-org $ORG --json \
|
|
96
|
+
--query "SELECT Id, QueueRoutingConfigId FROM Group WHERE Id='{QUEUE_ID}'"
|
|
97
|
+
```
|
|
98
|
+
`QueueRoutingConfigId` must be non-null.
|
|
99
|
+
|
|
100
|
+
## Step 5 — Capture for use in Phase 2
|
|
101
|
+
|
|
102
|
+
Store:
|
|
103
|
+
- `QUEUE_DEVELOPER_NAME` — used in the MessagingChannel XML (Branch A) or RoutingFlow `queueId` lookup (Branches B/C)
|
|
104
|
+
- `QUEUE_NAME` (the `Name` field, e.g. `Voice Queue`) — used as `queueLabel` in the RoutingFlow XML
|
|
105
|
+
- `QUEUE_ID` (18-char record Id) — used as `queueId` in the RoutingFlow XML
|
|
106
|
+
|
|
107
|
+
If an existing queue was chosen, query its Id if not already available:
|
|
108
|
+
```bash
|
|
109
|
+
QUEUE_ID=$(sf data query --target-org $ORG --json \
|
|
110
|
+
--query "SELECT Id FROM Group WHERE Type='Queue' AND DeveloperName='{QUEUE_DEVELOPER_NAME}'" \
|
|
111
|
+
| python3 -c "import sys,json; print(json.load(sys.stdin)['result']['records'][0]['Id'])")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Step 6 — Escalation queue resolution (Phase 3 only)
|
|
117
|
+
|
|
118
|
+
Run this step when the user opts into outbound escalation (Branches A/B). The escalation queue is the human queue that receives escalated conversations — it may be the same as the inbound fallback queue, or a different one.
|
|
119
|
+
|
|
120
|
+
### Check whether other compatible queues exist
|
|
121
|
+
|
|
122
|
+
Query for queues with the correct SobjectType, excluding the inbound fallback queue already selected:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
sf data query --target-org $ORG --json \
|
|
126
|
+
--query "SELECT Queue.Name, Queue.DeveloperName, Queue.Id
|
|
127
|
+
FROM QueueSobject
|
|
128
|
+
WHERE SobjectType='{SOBJECT_TYPE}'
|
|
129
|
+
AND Queue.DeveloperName != '{QUEUE_DEVELOPER_NAME}'"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Branch on results
|
|
133
|
+
|
|
134
|
+
**Zero other queues exist** → no choice to offer; reuse the inbound fallback queue. Set `ESCALATION_QUEUE_DEVELOPER_NAME = QUEUE_DEVELOPER_NAME` and `ESCALATION_QUEUE_ID = QUEUE_ID`. Continue without asking.
|
|
135
|
+
|
|
136
|
+
**One or more other queues exist** → ask the user via `AskUserQuestion`:
|
|
137
|
+
|
|
138
|
+
> *"Which queue should receive escalated conversations from the agent?"*
|
|
139
|
+
> - *Use the same queue as inbound fallback: `{QUEUE_NAME}` ({QUEUE_DEVELOPER_NAME})* **(Recommended)**
|
|
140
|
+
> - *{OtherQueue.Name} ({OtherQueue.DeveloperName})* — one option per additional compatible queue
|
|
141
|
+
|
|
142
|
+
If the user picks the fallback: `ESCALATION_QUEUE_DEVELOPER_NAME = QUEUE_DEVELOPER_NAME`, `ESCALATION_QUEUE_ID = QUEUE_ID`.
|
|
143
|
+
|
|
144
|
+
If the user picks a different queue: capture its `DeveloperName` and `Id` as `ESCALATION_QUEUE_DEVELOPER_NAME` and `ESCALATION_QUEUE_ID`.
|
|
145
|
+
|
|
146
|
+
Use `ESCALATION_QUEUE_DEVELOPER_NAME` (not `QUEUE_DEVELOPER_NAME`) when writing the outbound RoutingFlow XML in Phase 3.
|
package/skills/service-agentforce-human-escalation-configure/references/escalation-mechanism.md
CHANGED
|
@@ -51,7 +51,7 @@ After deploy, `FlowDefinitionView.ActiveVersionId` for the flow must be non-null
|
|
|
51
51
|
|
|
52
52
|
The escalation target is a queue whose `QueueSobject` includes the routed context object
|
|
53
53
|
(`MessagingSession` by default, for Enhanced Chat / MIAW), plus a `QueueRoutingConfig`. See
|
|
54
|
-
[queue-resolution.md](
|
|
54
|
+
[queue-resolution.md](_vendored/queue-resolution.md)
|
|
55
55
|
for the create-or-adopt recipe. Provision any broader routing infrastructure through an
|
|
56
56
|
approved Omni setup workflow before running this skill.
|
|
57
57
|
|
|
@@ -12,16 +12,25 @@ from pathlib import Path
|
|
|
12
12
|
SKILLS_ROOT = Path(__file__).resolve().parents[3]
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
_COORDINATOR = "service-itsm-agentic-setup-agentforce-coordinate"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _find_flat_skills_root(start: Path) -> Path | None:
|
|
19
|
+
"""Walk up from this file to the directory holding the ITSM coordinator skill: the repo's
|
|
20
|
+
flat skills/ root, or its team directory under contributed-skills/. Cross-skill references
|
|
21
|
+
that aren't part of this skill's own plugin roster (like the coordinator's verdict script
|
|
22
|
+
below) must resolve here, not under SKILLS_ROOT, since a plugin mirror's SKILLS_ROOT only
|
|
23
|
+
contains its own bundled skills. The walk stops at the repo root so a stray skills/ tree in
|
|
24
|
+
a parent directory is never executed; None means the coordinator isn't in this checkout."""
|
|
20
25
|
for parent in start.parents:
|
|
21
|
-
|
|
22
|
-
if candidate.is_dir():
|
|
26
|
+
if (parent / "skills" / _COORDINATOR).is_dir():
|
|
23
27
|
return parent / "skills"
|
|
24
|
-
|
|
28
|
+
for team_copy in sorted((parent / "contributed-skills").glob(f"*/{_COORDINATOR}")):
|
|
29
|
+
if team_copy.is_dir():
|
|
30
|
+
return team_copy.parent
|
|
31
|
+
if (parent / ".git").exists():
|
|
32
|
+
break
|
|
33
|
+
return None
|
|
25
34
|
|
|
26
35
|
|
|
27
36
|
FLAT_SKILLS_ROOT = _find_flat_skills_root(Path(__file__).resolve())
|
|
@@ -196,7 +205,15 @@ start_agent support_agent:
|
|
|
196
205
|
AGENT
|
|
197
206
|
fi
|
|
198
207
|
elif printf '%s' "$args" | grep -q "GenAiPlugin:"; then
|
|
199
|
-
|
|
208
|
+
if [ "${FAKE_AUTHORING_FIXTURE:-0}" = "1" ]; then
|
|
209
|
+
# Metadata-format bundle whose GenAiPlugin has no XSD anchor, so the canEscalate patcher
|
|
210
|
+
# refuses after the deactivate and the rollback path runs.
|
|
211
|
+
mkdir -p "$dir/genAiPlugins"
|
|
212
|
+
echo '<?xml version="1.0"?><Package xmlns="x"></Package>' > "$dir/package.xml"
|
|
213
|
+
printf '<?xml version="1.0"?>\n<GenAiPlugin xmlns="x"></GenAiPlugin>\n' > "$dir/genAiPlugins/Escalate_Topic.genAiPlugin"
|
|
214
|
+
else
|
|
215
|
+
echo '<canEscalate>true</canEscalate>' > "$dir/plugin.xml"
|
|
216
|
+
fi
|
|
200
217
|
elif printf '%s' "$args" | grep -q "GenAiPlannerBundle:"; then
|
|
201
218
|
[ "$TARGET_MODEL" = "classic" ] || [ "$TARGET_MODEL" = "both" ] || exit 1
|
|
202
219
|
cat > "$dir/bundle.xml" <<BXML
|
|
@@ -215,14 +232,28 @@ BXML
|
|
|
215
232
|
echo '{"status":0,"result":{"success":true}}'; exit 0;;
|
|
216
233
|
"project deploy")
|
|
217
234
|
echo '{"status":0,"result":{"success":true,"files":[{"fullName":"Human_Escalation_Outbound_Flow","type":"Flow","state":"Created"}]}}'; exit 0;;
|
|
235
|
+
"agent activate")
|
|
236
|
+
# FAKE_ACTIVATE_FAIL=1 → reactivation fails, so a rollback must report the agent left inactive.
|
|
237
|
+
if [ "${FAKE_ACTIVATE_FAIL:-0}" = "1" ]; then
|
|
238
|
+
echo '{"status":1,"message":"FAKE_ACTIVATE_FAILED"}'; exit 1
|
|
239
|
+
fi
|
|
240
|
+
echo '{"status":0,"result":{}}'; exit 0;;
|
|
218
241
|
*) echo '{"status":0,"result":{}}'; exit 0;;
|
|
219
242
|
esac
|
|
220
243
|
"""
|
|
221
244
|
|
|
245
|
+
# Only what bash, node, and version-manager shims need, so tokens, SF_* overrides, and
|
|
246
|
+
# NODE_OPTIONS from the developer's shell never reach the scripts under test.
|
|
247
|
+
_ENV_PASSTHROUGH = ("PATH", "HOME", "TERM", "TMPDIR", "LANG", "LC_ALL", "USER", "SHELL")
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _base_env():
|
|
251
|
+
return {k: os.environ[k] for k in _ENV_PASSTHROUGH if k in os.environ}
|
|
252
|
+
|
|
222
253
|
|
|
223
254
|
def run(args, path_prefix=None, scrub_sf=False, extra_env=None):
|
|
224
255
|
"""Run the orchestrator; return (returncode, merged stdout+stderr)."""
|
|
225
|
-
env =
|
|
256
|
+
env = _base_env()
|
|
226
257
|
if scrub_sf:
|
|
227
258
|
kept = [d for d in env.get("PATH", "").split(os.pathsep)
|
|
228
259
|
if d and not os.path.exists(os.path.join(d, "sf"))]
|
|
@@ -244,7 +275,7 @@ def run_node(script_rel, args, root=None):
|
|
|
244
275
|
base = root if root is not None else SKILLS_ROOT
|
|
245
276
|
proc = subprocess.run(
|
|
246
277
|
["node", str(base / script_rel), *args],
|
|
247
|
-
capture_output=True, text=True, cwd=str(base),
|
|
278
|
+
capture_output=True, text=True, cwd=str(base), env=_base_env(),
|
|
248
279
|
)
|
|
249
280
|
return proc.returncode, (proc.stdout or "")
|
|
250
281
|
|
|
@@ -113,6 +113,14 @@ class InputContractTests(unittest.TestCase):
|
|
|
113
113
|
self.assertEqual(rc, 1, out)
|
|
114
114
|
self.assertIn("planner_bundle_api_name", out)
|
|
115
115
|
|
|
116
|
+
def test_injection_service_channel_name_rejected(self):
|
|
117
|
+
# Substituted into the flow XML via sed: a `|` would end the s||| expression and run
|
|
118
|
+
# a `w` (write-file) command.
|
|
119
|
+
rc, out = run(["myorg"], scrub_sf=True,
|
|
120
|
+
extra_env={"SERVICE_CHANNEL_DEV_NAME": "x|w /tmp/esc-pwn"})
|
|
121
|
+
self.assertEqual(rc, 1, out)
|
|
122
|
+
self.assertIn("service_channel_developer_name", out)
|
|
123
|
+
|
|
116
124
|
|
|
117
125
|
class ProductionGuardTests(unittest.TestCase):
|
|
118
126
|
def test_production_org_refused(self):
|
|
@@ -699,6 +707,7 @@ class NgaClassifierHardeningTests(unittest.TestCase):
|
|
|
699
707
|
self.assertEqual(rc, 3)
|
|
700
708
|
|
|
701
709
|
|
|
710
|
+
@unittest.skipIf(FLAT_SKILLS_ROOT is None, "ITSM coordinator skill not present in this checkout")
|
|
702
711
|
class CoordinatorGateTests(unittest.TestCase):
|
|
703
712
|
def test_escalation_verdict_mapping(self):
|
|
704
713
|
rc, out = run_node(VERDICT_SCRIPT, ["escalation", "CONFIGURED"], root=FLAT_SKILLS_ROOT)
|
|
@@ -895,6 +904,42 @@ class AuthorSurfacesContractTests(unittest.TestCase):
|
|
|
895
904
|
self.assertIn("AUTHOR_SURFACES=1 requires escalation_topic_api_name and/or planner_bundle_api_name",
|
|
896
905
|
self.block)
|
|
897
906
|
|
|
907
|
+
def test_no_activation_result_is_swallowed(self):
|
|
908
|
+
offending = [ln.strip() for ln in self.src.splitlines()
|
|
909
|
+
if "agent activate" in ln and "|| true" in ln]
|
|
910
|
+
self.assertEqual(offending, [], f"activation outcome discarded: {offending}")
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
class RecoveryReportingTests(unittest.TestCase):
|
|
914
|
+
"""A patch failure after deactivate must report both the failure and whether reactivation worked."""
|
|
915
|
+
|
|
916
|
+
def _run(self, activate_fails):
|
|
917
|
+
env = {"AUTHOR_SURFACES": "1", "FAKE_AUTHORING_FIXTURE": "1"}
|
|
918
|
+
if activate_fails:
|
|
919
|
+
env["FAKE_ACTIVATE_FAIL"] = "1"
|
|
920
|
+
with FakeSf(_FAKE_SF_SANDBOX) as fake:
|
|
921
|
+
rc, out = run(["sbx", "Support_Agent", "Human_Support_Queue", "Escalate_Topic"],
|
|
922
|
+
path_prefix=fake, extra_env=env)
|
|
923
|
+
return rc, out, _last_json(out) or {}
|
|
924
|
+
|
|
925
|
+
def test_failed_reactivation_is_reported(self):
|
|
926
|
+
rc, out, verdict = self._run(activate_fails=True)
|
|
927
|
+
self.assertEqual(rc, 1, out)
|
|
928
|
+
self.assertEqual(verdict.get("status"), "BLOCKED", out)
|
|
929
|
+
issue = verdict.get("blocking_issue", "")
|
|
930
|
+
self.assertIn("could not safely set canEscalate", issue)
|
|
931
|
+
self.assertIn("Recovery FAILED", issue)
|
|
932
|
+
self.assertIn("INACTIVE", issue)
|
|
933
|
+
self.assertTrue(verdict.get("manual_actions"), "a stranded agent needs a manual fix")
|
|
934
|
+
|
|
935
|
+
def test_successful_reactivation_is_reported(self):
|
|
936
|
+
rc, out, verdict = self._run(activate_fails=False)
|
|
937
|
+
self.assertEqual(rc, 1, out)
|
|
938
|
+
self.assertEqual(verdict.get("status"), "BLOCKED", out)
|
|
939
|
+
issue = verdict.get("blocking_issue", "")
|
|
940
|
+
self.assertIn("could not safely set canEscalate", issue)
|
|
941
|
+
self.assertIn("was reactivated", issue)
|
|
942
|
+
|
|
898
943
|
|
|
899
944
|
if __name__ == "__main__":
|
|
900
945
|
unittest.main(verbosity=2)
|
package/skills/service-agentforce-human-escalation-configure/scripts/verify-and-configure.sh
CHANGED
|
@@ -75,6 +75,12 @@ if ! [[ "$FLOW_DEV_NAME" =~ $DN_RE ]]; then
|
|
|
75
75
|
echo "{\"error\":\"Invalid flow_developer_name '$FLOW_DEV_NAME'. Must match the DeveloperName grammar.\"}" >&2
|
|
76
76
|
exit 1
|
|
77
77
|
fi
|
|
78
|
+
# SERVICE_CHANNEL_DEV_NAME is substituted unescaped into the flow XML via sed; the grammar excludes
|
|
79
|
+
# the sed (| & \) and XML (< > & " ') metacharacters that could rewrite the deployed RoutingFlow.
|
|
80
|
+
if ! [[ "$SERVICE_CHANNEL_DEV_NAME" =~ $DN_RE ]]; then
|
|
81
|
+
echo "{\"error\":\"Invalid service_channel_developer_name '$SERVICE_CHANNEL_DEV_NAME'. Must match the DeveloperName grammar.\"}" >&2
|
|
82
|
+
exit 1
|
|
83
|
+
fi
|
|
78
84
|
# DEFAULT_FAILURE_THRESHOLD must be a small positive integer (1-99).
|
|
79
85
|
if ! [[ "$DEFAULT_FAILURE_THRESHOLD" =~ ^[1-9][0-9]?$ ]]; then
|
|
80
86
|
echo "{\"error\":\"Invalid DEFAULT_FAILURE_THRESHOLD '$DEFAULT_FAILURE_THRESHOLD'. Must be a positive integer between 1 and 99.\"}" >&2
|
|
@@ -130,6 +136,18 @@ emit_plan() {
|
|
|
130
136
|
exit 0
|
|
131
137
|
}
|
|
132
138
|
|
|
139
|
+
# Rollback after the agent was deactivated for authoring: try to reactivate, then block with the
|
|
140
|
+
# original failure AND the recovery outcome, so a failed reactivation never hides an inactive agent.
|
|
141
|
+
block_after_recovery() {
|
|
142
|
+
local msg="$1" rec_out
|
|
143
|
+
if rec_out=$(echo "Y" | sf agent activate --api-name "$AGENT_DN" --target-org "$ORG" --json 2>&1); then
|
|
144
|
+
emit_blocked "$msg Recovery: agent '$AGENT_DN' was reactivated."
|
|
145
|
+
else
|
|
146
|
+
emit_blocked "$msg Recovery FAILED: agent '$AGENT_DN' is left INACTIVE. Raw: $(echo "$rec_out" | head -c 400)" \
|
|
147
|
+
"Setup → Agentforce → Agents → '$AGENT_DN' → activate the latest version"
|
|
148
|
+
fi
|
|
149
|
+
}
|
|
150
|
+
|
|
133
151
|
# Step 1 - Organization + safe_to_write guard
|
|
134
152
|
ORG_JSON=$(sf data query --target-org "$ORG" \
|
|
135
153
|
--query "SELECT Id, IsSandbox, TrialExpirationDate, OrganizationType FROM Organization LIMIT 1" \
|
|
@@ -509,25 +527,21 @@ if [ "${AUTHOR_SURFACES:-0}" = "1" ] && [ "$QUEUE_HAS_ACTIVE_DIRECT_USER_MEMBER"
|
|
|
509
527
|
fi
|
|
510
528
|
AGENT_ACTIVE=false
|
|
511
529
|
|
|
512
|
-
# 4) Patch (XSD-ordered) + deploy (--metadata-dir); on failure,
|
|
530
|
+
# 4) Patch (XSD-ordered) + deploy (--metadata-dir); on failure, reactivate and report both outcomes.
|
|
513
531
|
if [ -n "$APLUGIN" ]; then
|
|
514
532
|
if ! node "$SCRIPT_DIR/patch-escalation-surfaces.mjs" canEscalate "$APLUGIN" >/dev/null 2>&1; then
|
|
515
|
-
|
|
516
|
-
emit_blocked "AUTHOR_SURFACES: could not safely set canEscalate=true on GenAiPlugin '$ESCALATION_TOPIC' (no safe XSD-ordered insertion point)."
|
|
533
|
+
block_after_recovery "AUTHOR_SURFACES: could not safely set canEscalate=true on GenAiPlugin '$ESCALATION_TOPIC' (no safe XSD-ordered insertion point)."
|
|
517
534
|
fi
|
|
518
535
|
if ! DEPLOY_OUT=$(sf project deploy start --target-org "$ORG" --metadata-dir "$AROOT_PLUGIN" --json 2>/dev/null); then
|
|
519
|
-
|
|
520
|
-
emit_blocked "AUTHOR_SURFACES: failed to deploy canEscalate patch for '$ESCALATION_TOPIC'. Raw: $(echo "$DEPLOY_OUT" | head -c 400)"
|
|
536
|
+
block_after_recovery "AUTHOR_SURFACES: failed to deploy canEscalate patch for '$ESCALATION_TOPIC'. Raw: $(echo "$DEPLOY_OUT" | head -c 400)"
|
|
521
537
|
fi
|
|
522
538
|
fi
|
|
523
539
|
if [ -n "$ABUNDLE" ]; then
|
|
524
540
|
if ! node "$SCRIPT_DIR/patch-escalation-surfaces.mjs" outboundRoute "$ABUNDLE" "$FLOW_DEV_NAME" >/dev/null 2>&1; then
|
|
525
|
-
|
|
526
|
-
emit_blocked "AUTHOR_SURFACES: could not safely wire outboundRouteConfigs on a Messaging surface of '$PLANNER_BUNDLE' (no Messaging-class planner surface / <surface> anchor found)."
|
|
541
|
+
block_after_recovery "AUTHOR_SURFACES: could not safely wire outboundRouteConfigs on a Messaging surface of '$PLANNER_BUNDLE' (no Messaging-class planner surface / <surface> anchor found)."
|
|
527
542
|
fi
|
|
528
543
|
if ! DEPLOY_OUT=$(sf project deploy start --target-org "$ORG" --metadata-dir "$AROOT_BUNDLE" --json 2>/dev/null); then
|
|
529
|
-
|
|
530
|
-
emit_blocked "AUTHOR_SURFACES: failed to deploy outboundRouteConfigs patch for '$PLANNER_BUNDLE'. Raw: $(echo "$DEPLOY_OUT" | head -c 400)"
|
|
544
|
+
block_after_recovery "AUTHOR_SURFACES: failed to deploy outboundRouteConfigs patch for '$PLANNER_BUNDLE'. Raw: $(echo "$DEPLOY_OUT" | head -c 400)"
|
|
531
545
|
fi
|
|
532
546
|
fi
|
|
533
547
|
|
|
@@ -34,7 +34,7 @@ Given a `{CHANNEL_ID}`, reads the channel's `MessagingChannelUsage.Id`, then fir
|
|
|
34
34
|
- `TEXT` → `registerCsotSms`.
|
|
35
35
|
- `AppleBusinessChat`, `Line`, everything else → `default` branch, no external callout, no network wait.
|
|
36
36
|
- On success: writes `DeploymentStatus = 'Active'` via PLSQL.
|
|
37
|
-
- On failure: writes `DeploymentStatus = 'Error'` plus `
|
|
37
|
+
- On failure: writes `DeploymentStatus = 'Error'` plus `ErrorDetails` (the actual cause — always read this) and a coarse `ErrorReason` category.
|
|
38
38
|
4. Inside the same observer, a second pass syncs `MessagingChannel.IsActive = true` once MCU reaches `Active` (the `isTransitioningStatus` flag skips the flip while status is still `Provisioning`).
|
|
39
39
|
|
|
40
40
|
All synchronous within the PATCH request — the 204 response only comes back after the full chain completes. WhatsApp: ~15-21s (Meta `/register` round-trip). Apple / Line: ~1s (no external call; just the local save-hook + observer + PLSQL write). Verified on wadtesting 2026-04-30.
|
|
@@ -43,7 +43,7 @@ All synchronous within the PATCH request — the 204 response only comes back af
|
|
|
43
43
|
|
|
44
44
|
| Reference file | Load when |
|
|
45
45
|
| --- | --- |
|
|
46
|
-
| `references/phone-verification.md` | Stage 3 comes back with `
|
|
46
|
+
| `references/phone-verification.md` | Stage 3 comes back `Error` on a WhatsApp channel with `ErrorDetails` containing `NUMBER_NOT_VERIFIED` or `REVERIFICATION` — the phone-number OTP verification sub-flow. |
|
|
47
47
|
| `references/worked-examples.md` | You want a reference run of the WhatsApp happy-path, Apple activation, a readiness failure, or the already-active no-op. |
|
|
48
48
|
| `references/gotchas.md` | Troubleshooting an unexpected result, or before modifying this skill — the eleven known gotchas. |
|
|
49
49
|
|
|
@@ -90,7 +90,7 @@ Unlike the old Aura-based version of this skill, there are no `{POLL_TIMEOUT_S}`
|
|
|
90
90
|
```json
|
|
91
91
|
{"ok": false, "kind": "readiness-failed", "errorCode": "FIELD_INTEGRITY_EXCEPTION",
|
|
92
92
|
"message": "...", "hint": "validateChannelReadinessOnProvisioning rejected the write — most commonly missing consent; run service-de-channel-settings-configure first"}
|
|
93
|
-
{"ok": false, "kind": "provisioning-error", "mcuId": "0gL...", "errorReason": "
|
|
93
|
+
{"ok": false, "kind": "provisioning-error", "mcuId": "0gL...", "errorReason": "ProvisioningError", "errorDetails": "WhatsAppNumberRegistrationError__..."}
|
|
94
94
|
{"ok": false, "kind": "verification-failed", "hint": "WhatsApp phone number verification failed or was declined by user"}
|
|
95
95
|
{"ok": false, "kind": "verification-request-failed", "errorCode": "...", "message": "...", "hint": "Could not request verification code from Meta"}
|
|
96
96
|
```
|
|
@@ -150,10 +150,10 @@ sf api request rest \
|
|
|
150
150
|
--body '{"DeploymentStatus":"Provisioning"}' \
|
|
151
151
|
--include \
|
|
152
152
|
> /tmp/amc-patch-response.txt 2>&1
|
|
153
|
-
HTTP_CODE=$(
|
|
153
|
+
HTTP_CODE=$(grep -m1 -oE '^HTTP/[0-9.]+ [0-9]{3}' /tmp/amc-patch-response.txt | awk '{print $2}')
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
-
`--include` prints the HTTP status/headers block ahead of the (typically empty, on 204) body
|
|
156
|
+
`--include` prints the HTTP status/headers block ahead of the (typically empty, on 204) body. Match the `HTTP/x.y NNN` status line itself — **not** `head -1`: with `2>&1`, the CLI's `Warning: @salesforce/cli update available from 2.150.6 to 2.154.4` line can come first, and a bare 3-digit grep then returns `150`.
|
|
157
157
|
|
|
158
158
|
Classify by HTTP status:
|
|
159
159
|
|
|
@@ -190,14 +190,14 @@ sf data query --target-org '{ORG_ALIAS}' \
|
|
|
190
190
|
| Status | Handling |
|
|
191
191
|
| --- | --- |
|
|
192
192
|
| `Active` | Continue to Stage 4. |
|
|
193
|
-
| `Error`
|
|
194
|
-
| `Error` (other) | Emit `{ok:false, kind:"provisioning-error", mcuId, errorReason, errorDetails}
|
|
193
|
+
| `Error`, WhatsApp, `ErrorDetails` contains `NUMBER_NOT_VERIFIED` or `REVERIFICATION` | Phone number needs OTP verification with Meta. Continue to Stage 3.2. (`ErrorReason` is just `ProvisioningError` here — the verification signal is only in `ErrorDetails`; see gotcha #9.) `ErrorDetails` is capped at 255 chars, so the Meta message at the end will usually be cut off mid-sentence — that's expected and harmless. All you need is the `NUMBER_NOT_VERIFIED (code 100, subcode 2593005)` part near the start, which always survives. |
|
|
194
|
+
| `Error` (other) | Emit `{ok:false, kind:"provisioning-error", mcuId, errorReason, errorDetails}`, with `errorDetails` verbatim — it is the actual cause; surface it to the user, not just `errorReason` (gotcha #8). |
|
|
195
195
|
| `Provisioning` | Unexpected — the observer was supposed to terminate before the PATCH returned 204. Fall through to a defensive poll (see Stage 3.1). |
|
|
196
196
|
| `Disabled` | The PATCH returned 204 but the write didn't take? Emit `{ok:false, kind:"transport", message:"PATCH returned 204 but MCU is still Disabled — observer didn't commit"}`. |
|
|
197
197
|
|
|
198
|
-
### Stage 3.2: WhatsApp phone number verification (only if
|
|
198
|
+
### Stage 3.2: WhatsApp phone number verification (only if `ErrorDetails` contains `NUMBER_NOT_VERIFIED` or `REVERIFICATION`)
|
|
199
199
|
|
|
200
|
-
This sub-flow only runs for WhatsApp channels
|
|
200
|
+
This sub-flow only runs for WhatsApp channels whose activation failed because Meta hasn't verified the phone number. **If the MCU comes back `Error` with `ErrorDetails` containing `NUMBER_NOT_VERIFIED` or `REVERIFICATION` (WhatsApp only), load `references/phone-verification.md` and follow it** to drive the phone-number verification sub-flow (request code → prompt user → validate code → retry activation once). Move into it directly — don't emit `provisioning-error` for this case. Its terminal envelopes are the Stage 4 success, `verification-declined`, `verification-request-failed`, or `verification-failed`.
|
|
201
201
|
|
|
202
202
|
### Stage 3.1: Defensive poll (only if Stage 3 saw `Provisioning`)
|
|
203
203
|
|
|
@@ -269,4 +269,4 @@ For end-to-end activation traces (WhatsApp happy-path, Apple activation, a readi
|
|
|
269
269
|
|
|
270
270
|
## Gotchas
|
|
271
271
|
|
|
272
|
-
Eleven known gotchas — synchronous PATCH timing for WhatsApp, valid API status transitions, the `IsActive` sync pass, relationship-name variance across orgs, consent preconditions, `DeploymentStatus` picklist casing, the REST-vs-Apex equivalence, `
|
|
272
|
+
Eleven known gotchas — synchronous PATCH timing for WhatsApp, valid API status transitions, the `IsActive` sync pass, relationship-name variance across orgs, consent preconditions, `DeploymentStatus` picklist casing, the REST-vs-Apex equivalence, reading failures from `ErrorDetails` (not `ErrorReason`), detecting the OTP-verification case, OAuth token extraction, and the Status-code-409 Admin API conflict. Before troubleshooting an unexpected result or modifying this skill, load `references/gotchas.md` and follow it.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: service-de-channel-activate-gotchas
|
|
3
|
-
description: "Load when debugging an unexpected result from service-de-channel-activate, or before implementing changes to it. Covers the eleven known gotchas: synchronous PATCH timing for WhatsApp, valid API status transitions, the IsActive sync pass, relationship-name variance across orgs, consent preconditions, DeploymentStatus picklist casing, the REST-vs-Apex equivalence, ErrorReason
|
|
3
|
+
description: "Load when debugging an unexpected result from service-de-channel-activate, or before implementing changes to it. Covers the eleven known gotchas: synchronous PATCH timing for WhatsApp, valid API status transitions, the IsActive sync pass, relationship-name variance across orgs, consent preconditions, DeploymentStatus picklist casing, the REST-vs-Apex equivalence, the ErrorReason picklist and ErrorDetails reason format, detecting OTP verification from ErrorDetails, keeping auth inside the CLI transport (sf api request rest), and the Status-code-409 Admin API conflict. DO NOT load this during a normal first-time activation run — only when troubleshooting or modifying the skill."
|
|
4
4
|
metadata:
|
|
5
5
|
version: "1.0"
|
|
6
6
|
related-skills: service-de-channel-activate
|
|
@@ -22,10 +22,10 @@ metadata:
|
|
|
22
22
|
|
|
23
23
|
7. **The REST PATCH is equivalent to the old Apex `activateChannelUsage` method** but without the Aura session machinery or the quirk where that method returned `isSuccessful:false` with a misleading error even on success.
|
|
24
24
|
|
|
25
|
-
8. **
|
|
25
|
+
8. **On failure, read `ErrorDetails` — it is the field that says what went wrong.** The MCU lands on `Error` with `ErrorDetails` (text, truncated at 255 chars) carrying the actual cause. For Meta `/register` failures it reads `WhatsAppNumberRegistrationError__WhatsApp number registration failed <phoneId>: <REASON> (code <c>, subcode <s>) [fbtrace_id …]: <Meta message>`, where `<REASON>` is derived server-side: `NUMBER_NOT_VERIFIED` (code 100 / subcode 2593005), `REVERIFICATION` (133006), `RATE_LIMITED` (133016), `TWO_FACTOR_MISMATCH` (133005), `TWO_STEP_GUESSED_TOO_FAST` (133009), `BUSINESS_LOCKED` (131031), `DELETED_NUMBER` (33), `LOGGED_IN_ON_SMB_APP` / `DISABLE_2FA_ON_SOURCE_NUMBER` (subcode 2388001), and others. Admin API failures use the `AdminApiRegistrationError__` prefix instead (gotcha #11). Branch on `ErrorDetails`, and pass it through verbatim in the `provisioning-error` envelope. `ErrorReason` is only a coarse restricted-picklist category (`ProvisioningError`, `InternalError`, `InvalidSelection`, `DeprovisioningError`, `WHATSAPP_PROV_ERR_*` / `WHATSAPP_DEPROV_ERR_*`) — Meta registration failures are all plain `ProvisioningError`, so never branch on it; include it in the envelope for context only.
|
|
26
26
|
|
|
27
|
-
9.
|
|
27
|
+
9. **The OTP-verification case is signalled in `ErrorDetails`, not `ErrorReason`.** There is no `VERIFICATION_REQUIRED` value — it isn't in the `ErrorReason` picklist, so a check on it never fires and an unverified number falls through to a generic `provisioning-error`. Trigger Stage 3.2 when a WhatsApp MCU is `Error` and `ErrorDetails` contains `NUMBER_NOT_VERIFIED` or `REVERIFICATION`; the reason token comes right after the phone id, so it survives the 255-char truncation. Observed on sdb6 (2026-10-20, channel `<channel-id>`): `ErrorReason=ProvisioningError`, `ErrorDetails=WhatsAppNumberRegistrationError__WhatsApp number registration failed <phone-id>: NUMBER_NOT_VERIFIED (code 100, subcode 2593005) [fbtrace_id …]: Phone number is not verified through sms or voice, …`. After verification, retry activation once (Stage 3.2 Step 5) — `Error → Provisioning` is a valid transition.
|
|
28
28
|
|
|
29
29
|
10. **Auth stays inside the CLI transport — use `sf api request rest`, not a manually-extracted bearer token.** The skill used to extract an OAuth token via `SF_TEMP_SHOW_SECRETS=true sf org display` + `jq -r '.result.accessToken'` and pass it as an `Authorization: Bearer` header to `curl`. That pattern put a live access token into shell state (visible in process lists, shell history, and any logging) and was removed as an S1 security anti-pattern. `sf api request rest --target-org '{ORG_ALIAS}'` manages the same OAuth session internally and never surfaces the token to the shell. Historical note: the old pattern's failure mode — omitting `SF_TEMP_SHOW_SECRETS` left the token field null, which surfaced as a 401 `INVALID_AUTH_HEADER` — no longer applies now that the CLI handles auth end-to-end.
|
|
30
30
|
|
|
31
|
-
11. **`ErrorDetails` containing "Status code = 409" comes from the *Salesforce* Admin API, not Meta.** When `ErrorReason = "ProvisioningError"` with `ErrorDetails = "AdminApiRegistrationError__Error occured in admin api with error code and error message Channel Registration response from Admin Api is a failure. Status code = 409"`, this indicates the phone number is already registered to a *different Salesforce org*. The Salesforce Admin API enforces a global constraint: one phone number can only be registered to one org at a time. To resolve: deactivate and deregister the phone from the other org, or use a different phone number for this org. This is distinct from Meta
|
|
31
|
+
11. **`ErrorDetails` containing "Status code = 409" comes from the *Salesforce* Admin API, not Meta.** When `ErrorReason = "ProvisioningError"` with `ErrorDetails = "AdminApiRegistrationError__Error occured in admin api with error code and error message Channel Registration response from Admin Api is a failure. Status code = 409"`, this indicates the phone number is already registered to a *different Salesforce org*. The Salesforce Admin API enforces a global constraint: one phone number can only be registered to one org at a time. To resolve: deactivate and deregister the phone from the other org, or use a different phone number for this org. This is distinct from Meta `/register` errors, which also land as `ProvisioningError` but carry the `WhatsAppNumberRegistrationError__` prefix and a Meta code/subcode in `ErrorDetails` (gotcha #8).
|
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: service-de-channel-activate-phone-verification
|
|
3
|
-
description: "Load when service-de-channel-activate's Stage 3 read comes back with MessagingChannelUsage.
|
|
3
|
+
description: "Load when service-de-channel-activate's Stage 3 read comes back DeploymentStatus=Error on a WhatsApp channel with MessagingChannelUsage.ErrorDetails containing NUMBER_NOT_VERIFIED or REVERIFICATION. Covers the phone-number OTP verification sub-flow: prompting for SMS/voice, requesting and validating the verification code via the Connect livemessage/whatsapp/verification endpoints (classified by the body's success field), and retrying activation once verification succeeds. DO NOT load this for any other ErrorDetails reason, for non-WhatsApp message types, or during the normal happy-path activation run."
|
|
4
4
|
metadata:
|
|
5
5
|
version: "1.0"
|
|
6
6
|
related-skills: service-de-channel-activate
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
# Stage 3.2: WhatsApp phone number verification (only if
|
|
9
|
+
# Stage 3.2: WhatsApp phone number verification (only if ErrorDetails contains NUMBER_NOT_VERIFIED or REVERIFICATION)
|
|
10
10
|
|
|
11
|
-
**This stage only runs for WhatsApp channels
|
|
11
|
+
**This stage only runs for WhatsApp channels whose activation failed because Meta hasn't verified the phone number.** The MCU shows `DeploymentStatus=Error`, `ErrorReason=ProvisioningError` (there is no dedicated `ErrorReason` for this), and `ErrorDetails` like:
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
WhatsAppNumberRegistrationError__WhatsApp number registration failed <phone-id>: NUMBER_NOT_VERIFIED (code 100, subcode 2593005) [fbtrace_id …]: Phone number is not verified through sms or voice, …
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Expect the string to be truncated: `ErrorDetails` is capped at 255 chars and Meta's message comes last, so it usually ends mid-word (as above). Don't treat the cut-off as an error or try to recover the rest — all the skill needs is the `NUMBER_NOT_VERIFIED (code 100, subcode 2593005)` part (or `REVERIFICATION (code 133006, …)`), which sits right after the phone id and always survives. Match on that, never on the Meta message text. We use the two Connect REST verification endpoints via `sf api request rest`, which manages OAuth internally — no token extraction needed.
|
|
18
|
+
|
|
19
|
+
**Both endpoints return the same body: `{"success": <bool>, "errorMessage": <string|null>}`** — nothing else. There is no `displayNumber` and no Meta error code in the Connect response (the Setup UI gets those over a different, Aura-only path). Meta-side failures come back as a **2xx with `success:false`**, not as a 4xx, so classify by `success` first and status second.
|
|
12
20
|
|
|
13
21
|
#### Step 1: Prompt for verification method
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
Go straight from the Stage 3 read into this prompt, in the same response — don't emit a `provisioning-error` first, and don't present the activation failure as the end of the run. This is a planned pause for user input, not a failure. Ask:
|
|
16
24
|
|
|
17
25
|
```text
|
|
18
|
-
WhatsApp phone number
|
|
26
|
+
Activation paused: Meta hasn't verified this WhatsApp phone number yet
|
|
27
|
+
(NUMBER_NOT_VERIFIED). We can verify it now with a one-time code sent to the number.
|
|
19
28
|
|
|
20
29
|
How should we send the verification code?
|
|
21
30
|
|
|
22
31
|
[1] SMS (text message)
|
|
23
32
|
[2] Voice call
|
|
33
|
+
[3] Cancel — leave the channel inactive for now
|
|
24
34
|
|
|
25
|
-
Choice [1/2]:
|
|
35
|
+
Choice [1/2/3]:
|
|
26
36
|
```
|
|
27
37
|
|
|
28
|
-
Record `{CODE_METHOD}` as `"SMS"` or `"VOICE"`
|
|
38
|
+
Record `{CODE_METHOD}` as `"SMS"` or `"VOICE"`. Show the reason token actually seen (`NUMBER_NOT_VERIFIED` or `REVERIFICATION`). On `3`, emit `{ok:false, kind:"verification-declined", mcuId, errorDetails, hint:"Phone number not verified. Re-run activation when ready to verify — the MCU stays in Error, which is a valid retry source."}` and stop.
|
|
29
39
|
|
|
30
40
|
#### Step 2: Request verification code
|
|
31
41
|
|
|
@@ -40,21 +50,30 @@ sf api request rest \
|
|
|
40
50
|
> /tmp/amc-verify-request.txt 2>&1
|
|
41
51
|
```
|
|
42
52
|
|
|
43
|
-
`{PHONE_NUMBER_ID}` is `{MESSAGING_PLATFORM_KEY}` from Stage 1. `--include` prints the HTTP status/headers block ahead of the body — read the status from
|
|
53
|
+
`{PHONE_NUMBER_ID}` is `{MESSAGING_PLATFORM_KEY}` from Stage 1. `--include` prints the HTTP status/headers block ahead of the body — read the status from the `HTTP/x.y NNN` line (as in Stage 2), not `head -1`. There's no blank line between headers and body, so take the body from the first line starting with `{`:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
HTTP_CODE=$(grep -m1 -oE '^HTTP/[0-9.]+ [0-9]{3}' /tmp/amc-verify-request.txt | awk '{print $2}')
|
|
57
|
+
SUCCESS=$(sed -n '/^{/,$p' /tmp/amc-verify-request.txt | jq -r '.success')
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Verified live on sdb6 (2026-10-20, `codeMethod=SMS`): `HTTP/1.1 201` with body `{"errorMessage": null, "success": true}`.
|
|
44
61
|
|
|
45
62
|
**Important:** The endpoint expects query parameters, not a JSON body. Pass `numberId` and `codeMethod` as URL parameters. Still send `--body '{}'` (not `--body ''`): `sf api request rest` treats an empty body string as no body and fails locally with `No 'mode' found in 'body' entry` before the request is issued, so an empty `{}` object is the way to make a body-less POST reach the endpoint.
|
|
46
63
|
|
|
47
64
|
| HTTP status | Body | Handling |
|
|
48
65
|
| --- | --- | --- |
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
66
|
+
| 2xx | `{"success": true, "errorMessage": null}` | Code sent. Continue to Step 3. |
|
|
67
|
+
| 2xx | `{"success": false, "errorMessage": "..."}` | Meta rejected the request (commonly: a code was requested too recently). Emit `{ok:false, kind:"verification-request-failed", message:"<errorMessage>", hint:"Meta may be rate-limiting code requests. Wait a few minutes, then retry activation."}`. Surface `errorMessage` verbatim — don't paraphrase or guess a Meta code. |
|
|
68
|
+
| 400 | `[{"errorCode":"INVALID_API_INPUT", ...}]` | A query param is missing (`numberId is required` / `Either codeMethod or verificationCode is required`) — a skill bug, not a user error. Emit `{ok:false, kind:"transport", status:400, message}`. |
|
|
69
|
+
| 401 | (empty) / `INVALID_SESSION_ID` | SF session invalid. Emit `{ok:false, kind:"auth"}`. |
|
|
52
70
|
| 404 | HTML | Endpoint unavailable. Emit `{ok:false, kind:"transport", status:404, hint:"Verification endpoint not available — check API version"}`. |
|
|
71
|
+
| 500 | `[{"errorCode":"UNKNOWN_EXCEPTION", "message":"Failed to process WhatsApp verification: ..."}]` | Server-side failure. Emit `{ok:false, kind:"transport", status:500, message}`. |
|
|
53
72
|
|
|
54
73
|
#### Step 3: Prompt for verification code
|
|
55
74
|
|
|
56
75
|
```text
|
|
57
|
-
A {CODE_METHOD} verification code has been sent to
|
|
76
|
+
A {CODE_METHOD} verification code has been sent to this channel's WhatsApp phone number.
|
|
58
77
|
Please check the device and enter the 6-digit code:
|
|
59
78
|
|
|
60
79
|
Code:
|
|
@@ -77,20 +96,25 @@ sf api request rest \
|
|
|
77
96
|
|
|
78
97
|
**Important:** The endpoint expects query parameters, not a JSON body. Pass `numberId` and `verificationCode` as URL parameters. Send `--body '{}'` rather than `--body ''` — an empty body string makes `sf api request rest` fail locally with `No 'mode' found in 'body' entry` before the POST is sent.
|
|
79
98
|
|
|
99
|
+
The response has the same shape as Step 2: a successful validate returns `HTTP/1.1 201` with exactly `{"errorMessage": null, "success": true}`. Parse it the same way and branch on `success`:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
HTTP_CODE=$(grep -m1 -oE '^HTTP/[0-9.]+ [0-9]{3}' /tmp/amc-verify-validate.txt | awk '{print $2}')
|
|
103
|
+
SUCCESS=$(sed -n '/^{/,$p' /tmp/amc-verify-validate.txt | jq -r '.success')
|
|
104
|
+
```
|
|
105
|
+
|
|
80
106
|
| HTTP status | Body | Handling |
|
|
81
107
|
| --- | --- | --- |
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
| 401 |
|
|
108
|
+
| 2xx (201 expected) | `{"errorMessage": null, "success": true}` | Number is verified — nothing else comes back (no confirmation text, no display number). Continue to Step 5 (retry activation). |
|
|
109
|
+
| 2xx | `{"success": false, "errorMessage": "..."}` | Meta rejected the code (wrong code, guessing too fast, or too many attempts — the response doesn't say which beyond `errorMessage`). Show `errorMessage` verbatim and ask: "Try another code? [y/n]". If `y`, repeat Step 3 — **don't** request a new code — up to 3 validate attempts total. If `n` or after 3 failures, emit `{ok:false, kind:"verification-failed", message:"<last errorMessage>", hint:"Verification code validation failed. If Meta reports too many attempts, wait before retrying activation."}`. |
|
|
110
|
+
| 400 / 401 / 404 / 500 | as in Step 2 | Same handling as Step 2. |
|
|
85
111
|
|
|
86
|
-
|
|
87
|
-
- `136024`: Too many recent attempts (rate limit). Emit `{ok:false, kind:"verification-failed", hint:"Too many verification attempts. Wait a few minutes and retry activation."}`.
|
|
88
|
-
- `136025`: Wrong code or guessing too fast. Allow retry (up to 3 attempts total).
|
|
112
|
+
> **Don't branch on Meta codes `136024` / `136025`.** The Setup UI distinguishes "too many attempts" from "wrong code" using those codes, but Connect returns only `errorMessage` — the codes never reach the skill.
|
|
89
113
|
|
|
90
114
|
#### Step 5: Retry activation after verification
|
|
91
115
|
|
|
92
116
|
The phone number is now verified. Return to Stage 2 (PATCH activation) with a retry counter to avoid infinite loops. Maximum 1 retry after verification.
|
|
93
117
|
|
|
94
|
-
If the second activation attempt
|
|
118
|
+
If the second activation attempt fails again with `ErrorDetails` containing `NUMBER_NOT_VERIFIED` or `REVERIFICATION`, emit `{ok:false, kind:"verification-failed", errorDetails:"<ErrorDetails>", hint:"Phone number verification succeeded but Meta still reports the number unverified — check the number in Meta Business Manager"}`. Any other `Error` on the retry → the normal `provisioning-error` envelope (Stage 3).
|
|
95
119
|
|
|
96
120
|
If the second activation succeeds (`Active`), proceed to Stage 4 as normal.
|