@salesforce/afv-skills 1.52.0 → 1.54.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 (24) hide show
  1. package/package.json +3 -3
  2. package/skills/service-agentforce-contact-center-coordinate/SKILL.md +170 -0
  3. package/skills/service-agentforce-contact-center-coordinate/assets/escalation-flow.flow-meta.xml +72 -0
  4. package/skills/service-agentforce-contact-center-coordinate/assets/omni-flow.flow-meta.xml +85 -0
  5. package/skills/service-agentforce-contact-center-coordinate/assets/report-template.md +52 -0
  6. package/skills/service-agentforce-contact-center-coordinate/references/agentforce-prerequisite.md +31 -0
  7. package/skills/service-agentforce-contact-center-coordinate/references/messaging_channel.md +76 -0
  8. package/skills/service-agentforce-contact-center-coordinate/references/number_management_api.md +78 -0
  9. package/skills/service-agentforce-contact-center-coordinate/references/omni-flow-routing.md +74 -0
  10. package/skills/service-agentforce-contact-center-coordinate/references/setup_summary.md +36 -0
  11. package/skills/service-agentforce-contact-center-coordinate/references/verification_and_errors.md +42 -0
  12. package/skills/service-agentforce-contact-center-coordinate/scripts/check-agentforce-prereq.sh +54 -0
  13. package/skills/service-agentforce-contact-center-coordinate/scripts/create-routing-flows.sh +49 -0
  14. package/skills/service-agentforce-contact-center-coordinate/scripts/create-voice-agent.sh +73 -0
  15. package/skills/service-agentforce-contact-center-coordinate/scripts/create-voice-channel.sh +66 -0
  16. package/skills/service-agentforce-contact-center-coordinate/scripts/fetch-numbers.sh +21 -0
  17. package/skills/service-agentforce-contact-center-coordinate/scripts/lib.sh +46 -0
  18. package/skills/service-agentforce-contact-center-coordinate/scripts/prepare-agent-workdir.sh +21 -0
  19. package/skills/service-agentforce-contact-center-coordinate/scripts/procure-number.sh +24 -0
  20. package/skills/service-agentforce-contact-center-coordinate/scripts/resolve-acc-queue.sh +27 -0
  21. package/skills/service-agentforce-contact-center-coordinate/scripts/resolve-channel-line.sh +37 -0
  22. package/skills/service-agentforce-contact-center-coordinate/scripts/resolve-flow-definition.sh +33 -0
  23. package/skills/service-agentforce-contact-center-coordinate/scripts/verify-number-live.sh +63 -0
  24. package/skills/experience-content-media-search/SKILL.md +0 -353
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/afv-skills",
3
- "version": "1.52.0",
3
+ "version": "1.54.0",
4
4
  "description": "Salesforce skills for Agentforce Vibes",
5
5
  "license": "CC-BY-NC-4.0",
6
6
  "files": [
@@ -11,8 +11,8 @@
11
11
  "registry": "https://registry.npmjs.org"
12
12
  },
13
13
  "devDependencies": {
14
- "@salesforce/ui-bundle-template-app-react-sample-b2e": "^11.57.2",
15
- "@salesforce/ui-bundle-template-app-react-sample-b2x": "^11.57.2",
14
+ "@salesforce/ui-bundle-template-app-react-sample-b2e": "^12.4.4",
15
+ "@salesforce/ui-bundle-template-app-react-sample-b2x": "^12.4.4",
16
16
  "@salesforce/webapp-template-app-react-sample-b2e-experimental": "^1.117.1",
17
17
  "@salesforce/webapp-template-app-react-sample-b2x-experimental": "^1.117.1"
18
18
  },
@@ -0,0 +1,170 @@
1
+ ---
2
+ name: service-agentforce-contact-center-coordinate
3
+ description: "Coordinates end-to-end setup of an Agentforce Contact Center voice channel: gathers country and phone-number-type selections, procures a chosen number, resolves its CommunicationChannelLine, verifies the number is live, and creates an active PstnVoice MessagingChannel. The user picks the routing model: Omni Queue (route to the contact center queue) or Omni Flow (route to an Agentforce agent, creating or reusing the agent plus its routing flows). Use when the user asks to set up an Agentforce Contact Center, provision a contact center phone number and voice channel together, or put an Agentforce agent on native voice. TRIGGER when the user says set up agentforce contact center, configure contact center voice, or create a voice channel with omni flow and an agentforce agent. DO NOT TRIGGER when only wiring an existing channel to an existing agent with no number to procure, or creating a non-voice messaging channel."
4
+ allowed-tools: Bash(sf org display:*) Bash(sf org create agent-user:*) Bash(sf data query:*) Bash(sf api request rest:*) Bash(sf agent:*) Bash(sf project deploy start:*) Bash(jq:*) Bash(scripts/*) Bash(./scripts/*) Bash(bash scripts/*) Read AskUserQuestion
5
+ metadata:
6
+ version: "1.1"
7
+ minApiVersion: "68.0"
8
+ domains: ["Service", "Agentforce"]
9
+ cliTools:
10
+ - tool: ["jq"]
11
+ semver: ">=1.6"
12
+ - tool: ["sf"]
13
+ semver: ">=2.0.0"
14
+ ---
15
+
16
+ # service-agentforce-contact-center-coordinate: Set up an Agentforce Contact Center voice channel
17
+
18
+ Coordinates the full path from an authenticated org to a live inbound voice channel: procure a phone number, confirm it is provisioned, and create an active `PstnVoice` `MessagingChannel`. The user picks the **routing model** — **Omni Queue** (route calls straight to the Agentforce Contact Center queue) or **Omni Flow** (route to an Agentforce agent via an inbound routing flow, with the queue as fallback). The Omni Queue path only orchestrates the Number Management and MessagingChannel REST APIs. The Omni Flow path can additionally author/publish/activate an Agentforce agent and deploy its inbound (`Copilot`) and escalation (`QueueBased`) `RoutingFlow` flows before wiring the channel.
19
+
20
+ ## Scope
21
+
22
+ - **In scope**: fetching available numbers, procuring a number, resolving its `CommunicationChannelLine`, verifying/reconciling live status, choosing the routing model, creating and activating a `PstnVoice` `MessagingChannel` (queue- or flow-routed), and — for the Omni Flow path — authoring/publishing/activating an Agentforce agent and deploying its inbound and escalation `RoutingFlow` flows. Ends with a setup summary.
23
+ - **Out of scope**: authenticating or provisioning the org (the target org must already be authenticated), enabling the Agentforce/Einstein Service Agent toggle (an org preference the operator flips — see `references/agentforce-prerequisite.md`), outbound/voice-tuning or wiring a *pre-existing* channel to an agent, and creating non-voice channels.
24
+
25
+ ---
26
+
27
+ ## Prerequisites
28
+
29
+ - **Authenticated org** — required for every path (this skill never runs an interactive login).
30
+ - **Omni Flow path only — Einstein and Agentforce Agents must be enabled in the org.** Before a voice channel can route to an Agentforce agent, an org admin must turn on **Einstein** (Setup → **Einstein Setup**) and then **Agentforce Agents** (Setup → Einstein → **Agentforce / Agents**) in the Setup UI. The skill then resolves or provisions the canonical **Einstein Agent User** (`Profile.Name = 'Einstein Agent User'`) that agent authoring and publish depend on. Do **not** use generic users whose username/profile merely contains `Agent` or `Bot`; those can generate/validate but fail publish. The **Omni Queue** path has **no** such prerequisite. Full steps: `references/agentforce-prerequisite.md`.
31
+
32
+ ---
33
+
34
+ ## Required Inputs
35
+
36
+ Gather or confirm before proceeding:
37
+
38
+ - **Target org**: an already-authenticated org. If the user names an alias, use it. If the user refers to their **default org** (or gives no alias), resolve it with `sf org display --json` and read `result.alias` (falling back to `result.username`); use that value as `<alias>` for every script. Do not run an interactive login.
39
+ - **Country**: `US` or `CA`.
40
+ - **Phone number type**: `10DLC` or `Toll Free`.
41
+ - **Selected number**: chosen by the user from the fetched list.
42
+ - **Routing model**: `Omni Queue` (default) or `Omni Flow`. Asked in Step 7.
43
+ - **(Omni Flow only) Agent source**: create a new Agentforce agent + routing flows, or reuse an existing published agent and its inbound routing flow.
44
+ - **(Omni Flow, new agent only) Agent business context**: agent name, agent description (the agent's role/purpose), and company name — passed to `sf agent generate agent-spec`. The agent name is used as the `<label>`, and the `<apiName>` is derived from it (normalization + uniqueness rule in Step 9 sub-step 3); do not prompt for role, website, or API name.
45
+
46
+ Do not proceed without an authenticated org and both the country and number-type selections. Collect the routing model and any Omni Flow inputs only if/when that path is chosen.
47
+
48
+ ---
49
+
50
+ ## Workflow
51
+
52
+ All steps are sequential. If a step fails, stop and report the error rather than continuing.
53
+
54
+ 1. **Confirm the org connection** — run `sf org display --target-org <alias> --json` and read `result.instanceUrl`. If it fails, ask the user to authenticate the org first, then stop. Do not run an interactive login from this skill.
55
+
56
+ 2. **Gather configuration** — use `AskUserQuestion` to collect **Country** (`US`/`CA`) and **Phone Number Type** (`10DLC`/`Toll Free`). Do not mark any option as recommended or default — present the choices neutrally. Wait for both before continuing.
57
+
58
+ 3. **Fetch available numbers** — read `references/number_management_api.md` for the endpoint contract, then run `scripts/fetch-numbers.sh <alias> <country> <phoneType>`. Present the returned numbers as a numbered list and ask the user to select one — do not mark any number as recommended or default.
59
+
60
+ 4. **Procure the selected number** — run `scripts/procure-number.sh <alias> <country> <phoneType> <number>`. On a non-2xx response, map the status via `references/number_management_api.md` and stop with a clear message.
61
+
62
+ 5. **Resolve the ChannelLine** — run `scripts/resolve-channel-line.sh <alias> <number>`. It queries `CommunicationChannelLine` by `Code`, retrying on empty results. Capture the `ChannelLine` Id and `CodeStatus`.
63
+
64
+ 6. **Verify the number is live** — run `scripts/verify-number-live.sh <alias> <number>`. It checks `CodeStatus` via the Tooling API, calls `numberStateReconcile` when not live, and polls per the strategy in `references/verification_and_errors.md`. Branch on the exit code: **exit 3** (still not `Live` after polling) → surface the warning and ask whether to wait or proceed; **exit 4** (`numberStateReconcile` returned a non-2xx) → **stop and report** per the stop-on-non-2xx rule — do not create a channel on top of a failed reconciliation.
65
+
66
+ 7. **Choose the routing model** — use `AskUserQuestion` to ask how calls should route, then branch in Step 9:
67
+ - **Omni Queue** (default) — route directly to the Agentforce Contact Center queue.
68
+ - **Omni Flow** — route to an Agentforce agent via an inbound routing flow, with the queue as fallback.
69
+
70
+ 8. **Resolve the contact center queue** — run `scripts/resolve-acc-queue.sh <alias>` to look up the Agentforce Contact Center default queue Id. Never hardcode a queue Id — it is org-specific. Both models need it: Omni Queue uses it as the channel's `SessionHandlerId`; Omni Flow uses it as the `FallbackQueueId` and the escalation-flow target.
71
+
72
+ 9. **Create the active voice channel** — read `references/messaging_channel.md`, then follow the branch for the chosen routing model.
73
+
74
+ **Omni Queue** — run `scripts/create-voice-channel.sh <alias> <number> <channelLineId> <queueId>`. This POSTs a `PstnVoice` `MessagingChannel` with `SessionHandlerId` set to the queue, `ChannelLineId` set to the resolved `CommunicationChannelLine` Id, and `IsActive: true`. Handle the field/status errors documented in that reference.
75
+
76
+ **Omni Flow** — read `references/omni-flow-routing.md`, then:
77
+ 1. **Prerequisite gate** — run `scripts/check-agentforce-prereq.sh <alias>` (see `references/agentforce-prerequisite.md`). **Exit 0** → capture the printed canonical Einstein Agent User for `--agent-user`; the script reuses an existing `Einstein Agent User` or provisions one with `sf org create agent-user`. **Exit 3** → no canonical user could be found/provisioned, often because the toggle is off or no Agentforce Service Agent User license is available; prompt the user to fix the org and re-run. If the user allows a queue-only fallback, use the Omni Queue create above and note the fallback in the report.
78
+ 2. **New or existing agent** — use `AskUserQuestion`:
79
+ - **Use existing** — ask for the published agent's API name/label and its inbound `RoutingFlow` DeveloperName, then run `scripts/resolve-flow-definition.sh <alias> <flowDeveloperName>` to get the inbound `FlowDefinition` Id (`300…`). `resolve-flow-definition.sh` verifies only that the *flow* has an active version, not that the agent is published and Active — confirm the agent's latest `BotVersion.Status = 'Active'` (`SELECT Status FROM BotVersion WHERE BotDefinition.DeveloperName = '<apiName>' ORDER BY VersionNumber DESC LIMIT 1`), or tell the user they are responsible for that, before continuing; otherwise the channel is created but calls won't route. Continue at sub-step 5.
80
+ - **Create new** — continue at sub-step 3.
81
+ 3. **Author the agent** — collect the agent's business context via `AskUserQuestion`: only **agent name**, **agent description** (the agent's role/purpose — this becomes the spec's `--role`), and **company name** (do not prompt for role, website, or API name). Use the agent name as the `<label>`. Derive the `<apiName>` (it becomes the `BotDefinition.DeveloperName` and the routing-flow name base) from the agent name: PascalCase the words, keep only alphanumerics, start with a letter (prefix `A` if needed), cap at 60 chars. Confirm uniqueness via `sf data query --query "SELECT DeveloperName FROM BotDefinition WHERE DeveloperName = '<apiName>'" --target-org <alias>`; append a numeric suffix on a collision. First prepare the SFDX work dir with `scripts/prepare-agent-workdir.sh acc-voice-build`; `sf agent generate agent-spec` requires project context before the authoring-bundle script runs. From inside `acc-voice-build`, generate the spec: `sf agent generate agent-spec --type customer --tone neutral --max-topics 5 --agent-user <einsteinAgentUser> --role "<agent description>" --company-name "<company name>" --output-file specs/<apiName>.yaml --target-org <alias> --json`. Then, from the parent/original work dir, run `scripts/create-voice-agent.sh <alias> <apiName> <label> acc-voice-build/specs/<apiName>.yaml acc-voice-build`, which generates the authoring bundle, fixes the generated `default_agent_user`, deploys the `AiAuthoringBundle`, validates, publishes, and activates the agent. **Do not switch the planner to `Atlas__VoiceAgent`** — keep the publish-generated `Atlas__ConcurrentMultiAgentOrchestration` (deviation note in `references/omni-flow-routing.md`).
82
+ 4. **Deploy the routing flows** — run `scripts/create-routing-flows.sh <alias> <apiName> <label> <queueId> <queueName> acc-voice-build`. It renders and deploys the inbound (`<apiName>_Voice_Omni_Flow`, `Copilot`) and escalation (`<apiName>_Voice_Escalation`, `QueueBased`) flows from inside the prepared SFDX work dir, then prints the inbound `FlowDefinition` Id (`300…`) on stdout — capture it. Reuse the **same** `acc-voice-build` work dir as sub-step 3.
83
+ 5. **Create the channel** — run `scripts/create-voice-channel.sh <alias> <number> <channelLineId> <flowDefinitionId> <queueId>`. The 5th arg switches the POST to Omni Flow: `SessionHandlerId` = the inbound `FlowDefinition` Id, `FallbackQueueId` = the queue.
84
+
85
+ 10. **Confirm setup and write the report** — read the created `MessagingChannel` back. Then write a report using **exactly** the structure in `assets/report-template.md`: fill every field with the real value produced during this run (org alias, country, phone-number type, routing model, the commands actually run, the procured number, the resolved `CommunicationChannelLine` Id and status, the queue resolved **by name** with its Id, and the created `PstnVoice` `MessagingChannel` Id, DeveloperName, ChannelLineId, IsActive, SessionHandlerId, and FallbackQueueId; for Omni Flow also the agent api-name/label and inbound `FlowDefinition` Id), and end with the one-line Outcome. Include the Omni Flow rows only when that path was taken. One line per item — no extra narrative, and do not omit a field that applies. If a step failed, still fill the fields reached and state the exact error and the step it failed at in Outcome.
86
+
87
+ ---
88
+
89
+ ## Rules / Constraints
90
+
91
+ | Constraint | Rationale |
92
+ |-----------|-----------|
93
+ | Never run an interactive login; require a pre-authenticated org alias | Auth and org lifecycle are out of scope; keeps the skill portable across surfaces |
94
+ | Call APIs via `sf api request rest`; never extract the access token | Uses the CLI's stored session for `--target-org` — no raw token handling |
95
+ | Never hardcode a queue Id / `SessionHandlerId` / `FlowDefinition` Id | These are org-specific; always resolve them (queue in Step 8, flow via `resolve-flow-definition.sh`) |
96
+ | Attach routing via `SessionHandlerId` (+ `FallbackQueueId` for Omni Flow) — not `TargetQueueId` or `RoutingType` | Omni Queue: `SessionHandlerId` = queue Id. Omni Flow: `SessionHandlerId` = inbound `FlowDefinition` Id (`300…`), `FallbackQueueId` = queue Id |
97
+ | Omni Flow: publish **and** activate the agent and deploy the inbound flow (Active, `300`-prefix) before creating the channel | The channel's `SessionHandlerId` points at a live inbound `FlowDefinition` that references a published, active agent |
98
+ | Do not switch the agent's `plannerType` to `Atlas__VoiceAgent` | This org rejects it with an opaque error; keep the publish-generated `Atlas__ConcurrentMultiAgentOrchestration` — voice still routes via the `Copilot` flow (deviation) |
99
+ | If the Agentforce prerequisite is unmet or agent/flow creation fails, stop and report unless the user explicitly accepts the Omni Queue fallback | Some runs require a new Agentforce agent and Omni Flow channel; do not silently downgrade the routing model |
100
+ | Use `ChannelLineId` (not scalar `ChannelLine`) to link the CommunicationChannelLine | `ChannelLine` is the relationship name; the writable create field is `ChannelLineId` |
101
+ | `MessageType` must be `PstnVoice` and `IsActive: true` | Required for an active inbound voice channel |
102
+ | Do not set `IsoCountryCode` on `PstnVoice` channels | Not valid for this channel type |
103
+ | Stop and report on any non-2xx API response | Partial setup left silent is worse than a clear failure |
104
+
105
+ ---
106
+
107
+ ## Gotchas
108
+
109
+ | Issue | Resolution |
110
+ |-------|------------|
111
+ | `ChannelLine` not found immediately after procurement | Records propagate asynchronously — retry with backoff (Step 5 script handles this) |
112
+ | Number `CodeStatus` not `Live` | Call `numberStateReconcile` and poll (Step 6 script); warn if it stays provisioning |
113
+ | `INVALID_FIELD: The value provided for foreign key reference ChannelLine is not a nested SObject` on channel create | The relationship name `ChannelLine` was sent as a scalar field — send the Id in `ChannelLineId` |
114
+ | `FIELD_INTEGRITY_EXCEPTION` blocking a non-live number | Expected when validation is enforced — wait for the number to become live, then retry |
115
+ | Duplicate `DeveloperName` | A channel with that name exists — derive a unique name or reuse the existing channel |
116
+ | Spaces in `phoneNumberType` (`Toll Free`) | URL-encode when building query strings (scripts handle this) |
117
+ | `sf agent generate agent-spec` fails with `RequiresProjectError` | Run `scripts/prepare-agent-workdir.sh acc-voice-build`, then invoke `sf agent generate agent-spec` from inside `acc-voice-build` with `--output-file specs/<apiName>.yaml` |
118
+ | `sf agent publish` says `default agent user NEW AGENT USER` | The generator left a placeholder in the `.agent` file — `create-voice-agent.sh` patches `default_agent_user` from the spec's `agentUser` before deploy/publish |
119
+ | `sf agent publish` says `Unable to access the Salesforce Agent APIs` or `User doesn't have access to use agent` | Usually the spec/bundle used a generic Agent/Bot-profile user. Run `scripts/check-agentforce-prereq.sh`; it must return a user whose profile is exactly `Einstein Agent User` |
120
+ | Opaque server error (e.g. `-1103525358`) when publishing/validating the agent | Caused by setting `plannerType: Atlas__VoiceAgent` — remove it and keep `Atlas__ConcurrentMultiAgentOrchestration` (deviation; `create-voice-agent.sh` never touches the planner) |
121
+ | Routing flow deploy fails with `does not contain a valid Salesforce DX project` | Use the same prepared `acc-voice-build` work dir; `create-routing-flows.sh` now runs `sf project deploy start` from inside that directory |
122
+ | `sf agent generate agent-spec` / publish fails on licensing or "default agent user" | Agentforce toggle is off or no Agentforce Service Agent User license is available. Enable it or free/provision a license (`references/agentforce-prerequisite.md`) |
123
+ | Using a `Flow` Id (`301…`) as `SessionHandlerId` | Wrong handle — `SessionHandlerId` needs the stable `FlowDefinition` Id (`300…`); `resolve-flow-definition.sh` returns it |
124
+ | Inbound flow deployed but the channel won't route to the agent | The agent must be **activated**, not just published, and the inbound flow must have an active version — `create-voice-agent.sh` verifies `BotVersion` is `Active`; `resolve-flow-definition.sh` exits 3 if there is no active version |
125
+
126
+ ---
127
+
128
+ ## Output Expectations
129
+
130
+ This skill primarily creates records in the target org:
131
+
132
+ - A procured phone number (Number Management).
133
+ - An active `PstnVoice` `MessagingChannel` — routed to the contact center queue (Omni Queue) or to an Agentforce agent via an inbound routing flow with the queue as fallback (Omni Flow).
134
+ - **Omni Flow only**: a published, active Agentforce agent plus two `RoutingFlow` flows (inbound `Copilot` + escalation `QueueBased`).
135
+ - A report written per `assets/report-template.md`, plus a final summary table (`references/setup_summary.md`).
136
+
137
+ The Omni Flow path also scaffolds a throwaway SFDX project under `acc-voice-build/` (spec, authoring bundle, flow metadata) to run the deploy — local build artifacts, not skill output.
138
+
139
+ ---
140
+
141
+ ## Cross-Skill Integration
142
+
143
+ The Omni Flow path wires inbound voice itself (agent → inbound `Copilot` flow → channel, plus an escalation flow), so it does **not** hand that wiring off to a separate channel-configuration skill. Deeper agent authoring beyond the voice service agent this skill generates (custom topics, actions, knowledge) is out of scope.
144
+
145
+ ---
146
+
147
+ ## Reference File Index
148
+
149
+ | File | When to read |
150
+ |------|-------------|
151
+ | `references/number_management_api.md` | Steps 3–4 — Number Management endpoints, params, and status-code mapping |
152
+ | `references/verification_and_errors.md` | Step 6 — live-verification polling strategy and error handling |
153
+ | `references/messaging_channel.md` | Step 9 — MessagingChannel field contract (both routing models) and create-time error handling |
154
+ | `references/omni-flow-routing.md` | Step 9 (Omni Flow) — routing-model contract, agent→flow→channel wiring order, new-vs-existing fork, planner deviation, fallback rule |
155
+ | `references/agentforce-prerequisite.md` | Step 9 (Omni Flow) — Agentforce toggle prerequisite, preflight check, and Omni-Queue fallback |
156
+ | `references/setup_summary.md` | Step 10 — user-facing summary table and next steps |
157
+ | `assets/report-template.md` | Step 10 — exact structure for the written `report.md` |
158
+ | `assets/omni-flow.flow-meta.xml` | Step 9 (Omni Flow) — inbound `Copilot` RoutingFlow template (rendered by `create-routing-flows.sh`) |
159
+ | `assets/escalation-flow.flow-meta.xml` | Step 9 (Omni Flow) — escalation `QueueBased` RoutingFlow template (rendered by `create-routing-flows.sh`) |
160
+ | `scripts/prepare-agent-workdir.sh` | Step 9 (Omni Flow) — prepare the SFDX project context required before generating an agent spec |
161
+ | `scripts/fetch-numbers.sh` | Step 3 — fetch available default numbers |
162
+ | `scripts/procure-number.sh` | Step 4 — procure the selected number |
163
+ | `scripts/resolve-channel-line.sh` | Step 5 — resolve the CommunicationChannelLine with retry |
164
+ | `scripts/verify-number-live.sh` | Step 6 — verify/reconcile live status |
165
+ | `scripts/resolve-acc-queue.sh` | Step 8 — resolve the ACC default queue Id |
166
+ | `scripts/create-voice-channel.sh` | Step 9 — create the active PstnVoice channel (4-arg Omni Queue / 5-arg Omni Flow) |
167
+ | `scripts/check-agentforce-prereq.sh` | Step 9 (Omni Flow) — prerequisite gate; resolves the Einstein Agent User for `--agent-user` |
168
+ | `scripts/create-voice-agent.sh` | Step 9 (Omni Flow) — generate/validate/publish/activate the Agentforce voice agent |
169
+ | `scripts/create-routing-flows.sh` | Step 9 (Omni Flow) — deploy inbound + escalation flows; print the inbound `FlowDefinition` Id |
170
+ | `scripts/resolve-flow-definition.sh` | Step 9 (Omni Flow) — resolve an inbound flow's `FlowDefinition` Id (`300…`), incl. reusing an existing flow |
@@ -0,0 +1,72 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Escalation voice flow (RoutingFlow, routingType=QueueBased). Routes a call from the agent
3
+ to the fallback queue when the caller asks for a human. Rendered by
4
+ scripts/create-routing-flows.sh (which fills the FLOW_LABEL, QUEUE_ID, and QUEUE_LABEL tokens). -->
5
+ <Flow xmlns="http://soap.sforce.com/2006/04/metadata">
6
+ <actionCalls>
7
+ <name>Route_to_Voice_Queue</name>
8
+ <label>Route to Voice Queue</label>
9
+ <locationX>176</locationX>
10
+ <locationY>158</locationY>
11
+ <actionName>routeWork</actionName>
12
+ <actionType>routeWork</actionType>
13
+ <flowTransactionModel>CurrentTransaction</flowTransactionModel>
14
+ <inputParameters>
15
+ <name>recordId</name>
16
+ <value><elementReference>recordId</elementReference></value>
17
+ </inputParameters>
18
+ <inputParameters>
19
+ <name>serviceChannelLabel</name>
20
+ <value><stringValue>Phone</stringValue></value>
21
+ </inputParameters>
22
+ <inputParameters>
23
+ <name>serviceChannelDevName</name>
24
+ <value><stringValue>sfdc_phone</stringValue></value>
25
+ </inputParameters>
26
+ <inputParameters>
27
+ <name>serviceChannelId</name>
28
+ <value>
29
+ <setupReference>sfdc_phone</setupReference>
30
+ <setupReferenceType>ServiceChannel</setupReferenceType>
31
+ </value>
32
+ </inputParameters>
33
+ <inputParameters>
34
+ <name>routingType</name>
35
+ <value><stringValue>QueueBased</stringValue></value>
36
+ </inputParameters>
37
+ <inputParameters>
38
+ <name>queueLabel</name>
39
+ <value><stringValue>{{QUEUE_LABEL}}</stringValue></value>
40
+ </inputParameters>
41
+ <inputParameters>
42
+ <name>queueId</name>
43
+ <value><stringValue>{{QUEUE_ID}}</stringValue></value>
44
+ </inputParameters>
45
+ <inputParameters>
46
+ <name>isQueueVariable</name>
47
+ <value><booleanValue>false</booleanValue></value>
48
+ </inputParameters>
49
+ </actionCalls>
50
+ <apiVersion>68.0</apiVersion>
51
+ <environments>Default</environments>
52
+ <interviewLabel>{{FLOW_LABEL}} {!$Flow.CurrentDateTime}</interviewLabel>
53
+ <label>{{FLOW_LABEL}}</label>
54
+ <processMetadataValues>
55
+ <name>BuilderType</name>
56
+ <value><stringValue>LightningFlowBuilder</stringValue></value>
57
+ </processMetadataValues>
58
+ <processType>RoutingFlow</processType>
59
+ <start>
60
+ <locationX>50</locationX>
61
+ <locationY>0</locationY>
62
+ <connector><targetReference>Route_to_Voice_Queue</targetReference></connector>
63
+ </start>
64
+ <status>Active</status>
65
+ <variables>
66
+ <name>recordId</name>
67
+ <dataType>String</dataType>
68
+ <isCollection>false</isCollection>
69
+ <isInput>true</isInput>
70
+ <isOutput>false</isOutput>
71
+ </variables>
72
+ </Flow>
@@ -0,0 +1,85 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- Inbound voice Omni Flow (RoutingFlow, routingType=Copilot). Routes arriving calls to the
3
+ Agentforce agent, with the queue as fallback when the agent is unavailable. Rendered by
4
+ scripts/create-routing-flows.sh (which fills the FLOW_LABEL, AGENT_API_NAME, AGENT_LABEL,
5
+ QUEUE_ID, and QUEUE_LABEL tokens); the channel's SessionHandlerId points at this flow's
6
+ FlowDefinition Id. -->
7
+ <Flow xmlns="http://soap.sforce.com/2006/04/metadata">
8
+ <actionCalls>
9
+ <name>Route_to_Agent</name>
10
+ <label>Route to Agent</label>
11
+ <locationX>176</locationX>
12
+ <locationY>158</locationY>
13
+ <actionName>routeWork</actionName>
14
+ <actionType>routeWork</actionType>
15
+ <flowTransactionModel>CurrentTransaction</flowTransactionModel>
16
+ <inputParameters>
17
+ <name>recordId</name>
18
+ <value><elementReference>recordId</elementReference></value>
19
+ </inputParameters>
20
+ <inputParameters>
21
+ <name>serviceChannelLabel</name>
22
+ <value><stringValue>Phone</stringValue></value>
23
+ </inputParameters>
24
+ <inputParameters>
25
+ <name>serviceChannelDevName</name>
26
+ <value><stringValue>sfdc_phone</stringValue></value>
27
+ </inputParameters>
28
+ <inputParameters>
29
+ <name>serviceChannelId</name>
30
+ <value>
31
+ <setupReference>sfdc_phone</setupReference>
32
+ <setupReferenceType>ServiceChannel</setupReferenceType>
33
+ </value>
34
+ </inputParameters>
35
+ <inputParameters>
36
+ <name>routingType</name>
37
+ <value><stringValue>Copilot</stringValue></value>
38
+ </inputParameters>
39
+ <inputParameters>
40
+ <name>copilotLabel</name>
41
+ <value><stringValue>{{AGENT_LABEL}}</stringValue></value>
42
+ </inputParameters>
43
+ <inputParameters>
44
+ <name>copilotId</name>
45
+ <value>
46
+ <setupReference>{{AGENT_API_NAME}}</setupReference>
47
+ <setupReferenceType>BotDefinition</setupReferenceType>
48
+ </value>
49
+ </inputParameters>
50
+ <inputParameters>
51
+ <name>queueLabel</name>
52
+ <value><stringValue>{{QUEUE_LABEL}}</stringValue></value>
53
+ </inputParameters>
54
+ <inputParameters>
55
+ <name>queueId</name>
56
+ <value><stringValue>{{QUEUE_ID}}</stringValue></value>
57
+ </inputParameters>
58
+ <inputParameters>
59
+ <name>isQueueVariable</name>
60
+ <value><booleanValue>false</booleanValue></value>
61
+ </inputParameters>
62
+ </actionCalls>
63
+ <apiVersion>68.0</apiVersion>
64
+ <environments>Default</environments>
65
+ <interviewLabel>{{FLOW_LABEL}} {!$Flow.CurrentDateTime}</interviewLabel>
66
+ <label>{{FLOW_LABEL}}</label>
67
+ <processMetadataValues>
68
+ <name>BuilderType</name>
69
+ <value><stringValue>LightningFlowBuilder</stringValue></value>
70
+ </processMetadataValues>
71
+ <processType>RoutingFlow</processType>
72
+ <start>
73
+ <locationX>50</locationX>
74
+ <locationY>0</locationY>
75
+ <connector><targetReference>Route_to_Agent</targetReference></connector>
76
+ </start>
77
+ <status>Active</status>
78
+ <variables>
79
+ <name>recordId</name>
80
+ <dataType>String</dataType>
81
+ <isCollection>false</isCollection>
82
+ <isInput>true</isInput>
83
+ <isOutput>false</isOutput>
84
+ </variables>
85
+ </Flow>
@@ -0,0 +1,52 @@
1
+ # Agentforce Contact Center Setup Report
2
+
3
+ ## Setup
4
+
5
+ | Item | Value |
6
+ |------|-------|
7
+ | Org alias | `<alias>` |
8
+ | Org confirmed | `sf org display --target-org <alias>` → `<instanceUrl>` |
9
+ | Country | `<US\|CA>` |
10
+ | Phone number type | `<10DLC\|Toll Free>` |
11
+ | Routing model | `<Omni Queue \| Omni Flow>` |
12
+
13
+ ## Commands run
14
+
15
+ Each API call went through `sf api request rest` (no raw access token was extracted).
16
+
17
+ 1. Fetch numbers — `GET /services/data/v68.0/connect/number-management/v1/numbers?countryCode=<country>&phoneNumberType=<type>`
18
+ 2. Procure number — `POST /services/data/v68.0/connect/number-management/v1/number` with `country=<country>`, `phoneNumberType=<type>`
19
+ 3. Resolve ChannelLine — SOQL: `<query used>`
20
+ 4. Verify live status — Tooling API `CodeStatus`<, numberStateReconcile if not live>
21
+ 5. Resolve queue by name — SOQL: `SELECT Id FROM Group WHERE Type='Queue' AND Name='<queue-name>'`
22
+ 6. Create channel — `POST` MessagingChannel (`PstnVoice`, `ChannelLineId=<channel-line-id>`, `IsActive=true`)
23
+
24
+ **Omni Flow only** — additional steps (omit for Omni Queue):
25
+
26
+ 7. Agentforce prerequisite — `scripts/check-agentforce-prereq.sh` → canonical Einstein Agent User `<agent-user>` <reused/provisioned>
27
+ 8. Agent — created/reused `<agent-api-name>` (`<agent-label>`), status Active
28
+ 9. RoutingFlows — deployed `<agent-api-name>_Voice_Omni_Flow` (Copilot) + `<agent-api-name>_Voice_Escalation` (QueueBased)
29
+
30
+ ## Result
31
+
32
+ | Field | Value |
33
+ |-------|-------|
34
+ | Routing model | `<Omni Queue \| Omni Flow>` |
35
+ | Procured phone number | `<number>` |
36
+ | CommunicationChannelLine Id | `<channel-line-id>` |
37
+ | CommunicationChannelLine status | `<code-status>` |
38
+ | Queue resolved by name | `<queue-name>` → `<queue-id>` |
39
+ | Agentforce agent (Omni Flow) | `<agent-api-name>` (`<agent-label>`) — Active |
40
+ | Inbound FlowDefinition (Omni Flow) | `<flow-dev-name>` → `<300-id>` |
41
+ | MessagingChannel Id | `<channel-id>` |
42
+ | MessagingChannel DeveloperName | `<dev-name>` |
43
+ | MessagingChannel ChannelLineId | `<channel-line-id>` |
44
+ | MessagingChannel IsActive | `true` |
45
+ | MessagingChannel SessionHandlerId | `<queue-id \| 300-flowdefinition-id>` |
46
+ | MessagingChannel FallbackQueueId | `<queue-id (Omni Flow) \| null>` |
47
+
48
+ Fill the Omni Flow rows only when that path was taken; leave them out for Omni Queue.
49
+
50
+ ## Outcome
51
+
52
+ <One line: SUCCESS — active PstnVoice channel `<channel-id>` routed to `<queue `<queue-name>` (Omni Queue) | agent `<agent-label>` via Omni Flow, fallback queue `<queue-name>`>`; OR the exact error encountered and the step it failed at.>
@@ -0,0 +1,31 @@
1
+ # Prerequisite — Einstein Setup + Agentforce Agents toggle
2
+
3
+ The **Omni Flow** path (routing a voice channel to an Agentforce agent) requires **Einstein** and **Agentforce / Einstein Service Agents to be enabled** in the org. When they're on, the org can provide an **Einstein Agent User** — the `--agent-user` that `sf agent generate agent-spec` and publish require. When they're off, or when no Agentforce Service Agent User license is available, agent authoring/publish fails with a licensing, Agent API access, or "couldn't find the default agent user" error.
4
+
5
+ This prerequisite does **not** apply to the Omni Queue path.
6
+
7
+ ## Enable it (org admin, one time)
8
+
9
+ In the target org, in the Setup UI:
10
+
11
+ 1. **Setup → Einstein Setup** → turn **Einstein** **On** (this must be enabled before the Agentforce toggle appears/works).
12
+ 2. **Setup → Einstein → Agentforce (Agents)** (a.k.a. *Einstein Agent* / *Agentforce Service Agents*) → turn the setting **On**.
13
+ 3. Confirm an **Einstein Agent User** exists (Setup → Users), or let `scripts/check-agentforce-prereq.sh` provision one with `sf org create agent-user`.
14
+
15
+ Enablement is an org preference, not part of this skill's scope — the operator flips it in Setup.
16
+
17
+ ## Preflight check
18
+
19
+ ```bash
20
+ scripts/check-agentforce-prereq.sh <alias>
21
+ ```
22
+
23
+ - **Exit 0** — prints a user whose profile is exactly `Einstein Agent User`. Use it as `--agent-user` for `sf agent generate agent-spec`. The script reuses an existing user, or provisions one with `sf org create agent-user`.
24
+ - **Exit 3** — no canonical Einstein Agent User could be found or provisioned; the toggle is likely off or the org has no available Agentforce Service Agent User license.
25
+
26
+ The profile-name check is intentionally strict. Do not use a broad fallback such as `Profile.Name LIKE '%Agent%'` or `Profile.Name LIKE '%Bot%'`: those users can make spec generation/validation appear healthy, then fail `sf agent publish authoring-bundle` with Agent API access or default-agent-user errors.
27
+
28
+ ## When the toggle is off
29
+
30
+ 1. **Prompt the user** to enable it or free/provision an Agentforce Service Agent User license, then re-run the check.
31
+ 2. If it still can't be confirmed — or agent/flow creation later fails on licensing — stop and report unless the user explicitly accepts the Omni Queue fallback.
@@ -0,0 +1,76 @@
1
+ # PstnVoice MessagingChannel
2
+
3
+ **`POST /services/data/v68.0/sobjects/MessagingChannel/`**
4
+
5
+ All calls go through `sf api request rest` — never extract the access token.
6
+
7
+ `SessionHandlerId` is the routing target: the **ACC queue Id** for Omni Queue, or the inbound
8
+ **FlowDefinition Id** (`300…`) for Omni Flow (with `FallbackQueueId` set to the queue). Both are
9
+ produced by `scripts/create-voice-channel.sh` — its optional 5th `fallback-queue-id` arg switches
10
+ it to Omni Flow. See `references/omni-flow-routing.md` for the Omni Flow contract.
11
+
12
+ ## Request — Omni Queue (default)
13
+
14
+ ```bash
15
+ sf api request rest \
16
+ "/services/data/v68.0/sobjects/MessagingChannel/" \
17
+ --method POST \
18
+ --body '{
19
+ "DeveloperName": "Voice_Channel_14155551234",
20
+ "MasterLabel": "Voice Channel +14155551234",
21
+ "MessageType": "PstnVoice",
22
+ "MessagingPlatformKey": "+14155551234",
23
+ "ChannelLineId": "<communication-channel-line-id>",
24
+ "IsActive": true,
25
+ "SessionHandlerId": "<acc-queue-id>"
26
+ }' \
27
+ --target-org <alias>
28
+ ```
29
+
30
+ ## Request — Omni Flow
31
+
32
+ Same call, but `SessionHandlerId` is the inbound FlowDefinition Id and `FallbackQueueId` is added:
33
+
34
+ ```json
35
+ {
36
+ "...": "same fields as above",
37
+ "SessionHandlerId": "<inbound-flowdefinition-id-300>",
38
+ "FallbackQueueId": "<acc-queue-id>"
39
+ }
40
+ ```
41
+
42
+ ## Field rules
43
+
44
+ | Field | Rule |
45
+ |-------|------|
46
+ | `MessageType` | Must be `PstnVoice` |
47
+ | `MessagingPlatformKey` | The E.164 phone number (with leading `+`) |
48
+ | `SessionHandlerId` | Omni Queue: the ACC queue Id (`00G…`). Omni Flow: the inbound RoutingFlow's `FlowDefinition` Id (`300…`). Resolve both — never hardcode |
49
+ | `FallbackQueueId` | Omni Flow only: the queue the agent overflows/escalates to (`00G…`). Omit for Omni Queue |
50
+ | `ChannelLineId` | The Id from `CommunicationChannelLine`; this is the writable create field that populates the `ChannelLine` relationship |
51
+ | `IsActive` | `true` activates the channel immediately |
52
+ | `IsoCountryCode` | Do NOT set on `PstnVoice` channels |
53
+ | Routing | Use `SessionHandlerId` (+ `FallbackQueueId` for Omni Flow) — not `TargetQueueId` or `RoutingType` |
54
+
55
+ ## Success response
56
+
57
+ ```json
58
+ { "id": "0Mj...", "success": true, "errors": [] }
59
+ ```
60
+
61
+ ## Create-time errors
62
+
63
+ | Error | Meaning | Action |
64
+ |-------|---------|--------|
65
+ | `INVALID_FIELD: The value provided for foreign key reference ChannelLine is not a nested SObject` | The relationship name `ChannelLine` was used as a scalar Id field | Send the `CommunicationChannelLine` Id in `ChannelLineId` instead |
66
+ | `FIELD_INTEGRITY_EXCEPTION: ... status 'Provisioning'` | Number not yet live and validation is enforced | Wait for the number to become live (Step 6), then retry |
67
+ | Duplicate `DeveloperName` | A channel with that name exists | Derive a unique `DeveloperName` or reuse the existing channel |
68
+
69
+ ## Verify
70
+
71
+ ```sql
72
+ SELECT Id, DeveloperName, MasterLabel, MessageType, MessagingPlatformKey, ChannelLineId, IsActive, SessionHandlerId, FallbackQueueId
73
+ FROM MessagingChannel WHERE Id = '<channel-id>'
74
+ ```
75
+
76
+ For Omni Flow, `SessionHandlerId` must start with `300` (inbound FlowDefinition) and `FallbackQueueId` with `00G` (queue). For Omni Queue, `SessionHandlerId` starts with `00G` and `FallbackQueueId` is null.
@@ -0,0 +1,78 @@
1
+ # Number Management API
2
+
3
+ All endpoints share the base path `/services/data/v68.0/connect/number-management/v1`.
4
+
5
+ **Never extract the access token.** All calls go through `sf api request rest`, which uses
6
+ the CLI's stored session for `--target-org`. Do not pull `accessToken` out of `sf org display`
7
+ and hand-build an HTTP request with it.
8
+
9
+ **Never pass `--json` to `sf api request rest`.** This beta command has no `--json` flag —
10
+ passing it fails with `Error: Nonexistent flag: --json`. The raw stdout body is already JSON
11
+ (unlike `sf data query`, which does support and need `--json` for its `.result.records[]`
12
+ envelope).
13
+
14
+ ## Fetch available default numbers
15
+
16
+ **`GET /numbers`**
17
+
18
+ Query parameters:
19
+
20
+ | Param | Values | Notes |
21
+ |-------|--------|-------|
22
+ | `countryCode` | `US`, `CA` | |
23
+ | `phoneNumberType` | `10DLC`, `Toll Free` | URL-encode the space in `Toll Free` as `%20` |
24
+
25
+ ```bash
26
+ sf api request rest \
27
+ "/services/data/v68.0/connect/number-management/v1/numbers?countryCode=US&phoneNumberType=Toll%20Free" \
28
+ --target-org <alias>
29
+ ```
30
+
31
+ Response:
32
+
33
+ ```json
34
+ { "phoneNumbers": ["+14155551234", "+14155551235", "+14155551236"] }
35
+ ```
36
+
37
+ ## Procure a number
38
+
39
+ **`POST /number`**
40
+
41
+ ```bash
42
+ sf api request rest \
43
+ "/services/data/v68.0/connect/number-management/v1/number" \
44
+ --method POST \
45
+ --body '{"phoneNumberType":"Toll Free","country":"US","phoneNumber":"+14155551234"}' \
46
+ --target-org <alias>
47
+ ```
48
+
49
+ Success (`201`):
50
+
51
+ ```json
52
+ { "phoneNumber": "+14155551234" }
53
+ ```
54
+
55
+ ## Reconcile number state
56
+
57
+ **`POST /numberStateReconcile`**
58
+
59
+ ```bash
60
+ sf api request rest \
61
+ "/services/data/v68.0/connect/number-management/v1/numberStateReconcile" \
62
+ --method POST \
63
+ --body '{"phoneNumber":"+14155551234"}' \
64
+ --target-org <alias>
65
+ ```
66
+
67
+ Success (`200`): empty body. Used to force the platform to reconcile a procured
68
+ number's downstream `CommunicationChannelLine` state.
69
+
70
+ ## Status-code mapping
71
+
72
+ | Status | Meaning | Action |
73
+ |--------|---------|--------|
74
+ | `400 BAD_REQUEST` | Invalid country / number type / field | Fix the input and retry |
75
+ | `403 RESOURCE_NOT_AVAILABLE` | Max number limit reached | Stop; user must free capacity or request more |
76
+ | `404 NOT_FOUND` | Number does not exist (procurement likely failed) | Re-run procurement |
77
+ | `409 CONFLICT` | Number already procured | Ask the user to select a different number |
78
+ | `500 INTERNAL_SERVER_ERROR` | Backend failure | Retry after a few seconds; escalate if persistent |