Create an IT Service Employee Agent (broad or specialized)
Create and activate an
IT Service Employee Agent as a
Next-Gen Authoring (NGA) native agent — Agent-Script-based (
/bundle), appearing natively in Agentforce Studio's Agents list with no external-link icon — entirely through the
Salesforce CLI ().
This skill does not call the legacy /connect/service-itsm/createAgent
; instead it reuses a shipped ITSM Employee template's
field and feeds it into the NGA bundle pipeline:
POST /nextgen-authoring/bundles
→
POST /nextgen-authoring/bundle-versions/{id}/publish
→
POST /nextgen-authoring/bundle-versions/{id}/activate
. Commands:
for Connect API GET/POST;
for the SOQL idempotency + verify reads.
GET /connect/service-itsm/agent-templates?agentType=AgentforceEmployeeAgent
returns the
broad template plus ~47
specialized Employee templates under the
namespace as siblings in
. Every specialized template ships the same
shape with the same
/
substitution points, so the same NGA sequence works for any of them —
only the that Phases 1 and 4 pin against changes. Full catalog + namespace filter + disambiguation rules live in
references/specialized-templates.md
.
Helper scripts (invoked via
) hold every JSON-parsing / decision rule so the model never eyeballs a response body (A9):
,
classify-agent-existence.mjs
,
(HTML-decodes + substitutes the template's
and writes the body to a JSON file so large content and free-text quotes never hit an inline shell string),
(deterministic report renderer).
Template selection (before Phase 1). Resolve the
this run pins: (1) no specialization named ⇒ pin
(id
svc_emp_intelligence__ItEmployeeAssistance
) — the backwards-compatible default; (2) user names a specialization ⇒ keyword-match against
references/specialized-templates.md
, single unambiguous match ⇒ pin that
and derive
from
after
(snake-cased); ambiguous ⇒
keyed on
; (3)
filter to only —
(Fulfiller) redirects to
service-itsm-agentic-setup-fulfiller-agent-configure
, other namespaces are out of scope. The resolved
is the single knob passed to
(Phase 1) and
(Phase 4).
Prerequisites. Creation assumes the org-level Agentforce for IT Service prerequisites are already satisfied (Agentforce Studio access +
service-cloud-requestor-agent
+
service-cloud-it-service-employee-agent
). If Phase 1 detects Studio is not accessible — or if any write returns
403 FUNCTIONALITY_NOT_ENABLED
— this skill
offers to delegate to
service-itsm-agentic-setup-agentforce-studio-validate
(employee path) then resume; on "no", stops. This skill never enables features itself — enablement is a Setup-UI/admin action.
Scope
- In scope: Reading ; extracting an Employee template's Agent Script (broad default or a user-named specialization from
references/specialized-templates.md
— all under ); creating the Employee agent as an NGA-native agent via → → ; SOQL-verifying live; idempotent skip on duplicate developer name — all via .
- Out of scope: The Fulfiller agent (
service-itsm-agentic-setup-fulfiller-agent-configure
); enabling org-level feature toggles (validated by service-itsm-agentic-setup-agentforce-studio-validate
); low-level topic/action authoring; perm-set assignment; content-bundle deployment; CMDB CRUD; Discovery / Service Graph; the legacy route; any entry outside .
Preconditions
If any of these are unmet,
surfaces an auth error or a
/
/
;
surface the raw error verbatim and stop — do not fabricate state.
- CLI authenticated to the target org (
sf org display -o <alias>
shows Connected). All calls use ; never extract the access token by hand.
- API v67.0+ — pinned in the URL path; do not hand-edit below the minimum.
- ITSM features + templates provisioned — resolved template must be present. If returns nothing or the routes 404, run
service-itsm-agentic-setup-agentforce-studio-validate
(agent path ).
- ≥ 18 on PATH.
Operations at a glance
| Concern | Command | Notes |
|---|
| Studio access (precondition read) | sf api request rest "/services/data/v67.0/agentforce-studio/access/Agents" --method GET -o <alias>
| ⇒ prereq hand-off |
| List agent templates + Agent Script (read) | sf api request rest "/services/data/v67.0/connect/service-itsm/agent-templates?agentType=AgentforceEmployeeAgent" --method GET -o <alias>
| agentType=AgentforceEmployeeAgent
required; confirms resolved template + non-empty |
| Enumerate existing agent + latest version status (read) | sf data query -q "SELECT Id,DeveloperName,MasterLabel,(SELECT Id,Status FROM BotVersions ORDER BY VersionNumber DESC LIMIT 1) FROM BotDefinition WHERE Id='<botDefinitionId>' OR DeveloperName='<developerName>'" -o <alias> --json
| Keyed PRIMARILY on the template's (Phase-1 row); the clause is both the null- fallback AND the guard for a dangling Id link (deleted target). Classified by scripts/classify-agent-existence.mjs
; Active latest ⇒ ALREADY-CREATED; Inactive latest ⇒ offer reactivation |
| Create the NGA bundle (write) | sf api request rest "/services/data/v67.0/nextgen-authoring/bundles" --method POST --body @<body-file> -o <alias>
| Body built by scripts/build-create-body.mjs
; response = the bundle version Id |
| Publish the bundle version (write) | sf api request rest "/services/data/v67.0/nextgen-authoring/bundle-versions/<bundleVersionId>/publish" --method POST --body '{}' -o <alias>
| Returns / — creates the underlying / |
| Activate the bundle version (write) | sf api request rest "/services/data/v67.0/nextgen-authoring/bundle-versions/<bundleVersionId>/activate" --method POST --body '{}' -o <alias>
| Empty response on success; agent is now live and NGA-native |
| Activate an existing inactive version (write) | sf api request rest "/services/data/v67.0/connect/bot-versions/<latestVersionId>/activation" --method POST --body '{"status":"Active"}' -o <alias>
| Reactivation path only (Phase 2b) — skips create/publish |
| Verify agent is live (read) | sf data query -q "SELECT ... FROM BotDefinition WHERE Id='<verifyId>'" -o <alias> --json
| = create path's (Phase-5) or the Phase-2 classifier's returned live matched Id (its /) on ALREADY-CREATED / reactivation — not the null Phase-1 template , never the collected developerName; confirm present + latest version Active |
Full command shapes and the ITSM Connect API reference live in
references/cli-invocation.md
; the reactivation-path call + idempotency verdict table live in
references/reactivation.md
; the response-body error codes and recurring gotchas live in
references/error-taxonomy.md
.
Never extract the access token. Use
/
directly — they use the CLI's stored session for the target org. Do
not pull the
out of
and hand-build an HTTP request with it; that bypasses the CLI session and leaks a bearer token into shell context.
rule. takes (results come back in a
envelope — that's what the classifier expects).
does
not — omit
there; its raw stdout body is already JSON.
Clarifying Questions
Collect from the user (ask only what is not already in conversation context):
| Field | Default |
|---|
| Target org | Default org () |
| Template () | (broad umbrella, id svc_emp_intelligence__ItEmployeeAssistance
). If the user hints at a specialization (password manager, certificate, onboarding, hardware request, etc.), resolve via references/specialized-templates.md
; ambiguous ⇒ keyed on |
| Developer name | Broad: IT_Service_Employee_Agent
. Specialized: substring after in the picked , snake-cased (e.g. PasswordManagerAssistance
→ Password_Manager_Assistance
) |
| Label | Broad: IT Service Employee Agent
. Specialized: the picked template's verbatim (e.g. Password Manager Assistance
) |
| Confirm the write | REQUIRED — present resolved template + developerName + label, then require "yes" via |
The collected
,
,
are threaded through every call —
selects the row in
(which also carries the
idempotency key);
/
are used in the
body (both outer
/
AND the substituted internal
/
). The
idempotency + verify reads key PRIMARILY on the template's (or, after a fresh create, the publish response's
) and
fall back to the collected when that is null. A hardcode/collect mismatch on the create body diverges the bundle's outer identity from the script's internal identity.
Idempotency: keyed PRIMARILY on the
template's (Phase-1
row — the platform's authoritative template→
link) and FALLING BACK to the collected
. The Phase-2 read is
BotDefinition WHERE Id='<botDefinitionId>' OR DeveloperName='<developerName>'
(the
half is both the null-
fallback AND the guard for a
dangling Id link — one whose target
was deleted — so a stale link can't slip through to create), + latest
. Outcomes: no match on either key ⇒ create;
⇒ ALREADY-CREATED (skip write);
⇒ Phase-2b reactivation offer.
Why both keys: the broad agent ships pre-provisioned as
≠ the guess
IT_Service_Employee_Agent
, so
catches it — but an agent this skill creates never back-fills
(the create path omits
), so its template row stays null and the
fallback is what catches a repeat run. The server does reject a duplicate
at publish (unique-constraint → bundle cleanup), but only this read turns a repeat into a graceful skip instead of a
.
Workflow
Substitute
with the collected target org and
/
with the collected values. Full command shapes + per-phase verdict-branch handling live in
references/workflow-detail.md
— the phase summary below names each step and its load-bearing rule; the reference file holds the exact
/
invocations to copy.
- Phase 0 — Establish . Before any phase writes a transient JSON file, invoke the deterministic helper (path is skill-root-qualified so it resolves regardless of the shell's CWD):
SCRATCH_DIR="$(node "<skill_dir>/scripts/create-scratch-dir.mjs" "${outputDir:-}")"
. The helper picks the base dir (, else , else the harness last-resort — scratch stays OUT of the scored tree) and emits the created dir's absolute path on stdout. Every subsequent phase writes its transient JSON under ; the durable stays under the harness dir.
- Phase 1 — Preflight. Capture the Studio-access read + read (with the required
agentType=AgentforceEmployeeAgent
query param), then classify via scripts/classify-preflight.mjs "<masterLabel>"
— pass the resolved ( for the broad path or the picked specialization's ). The classifier also emits from the matched row — capture it; it is the primary Phase-2 idempotency key (the collected is the fallback key). Branch on : ⇒ Phase 2; ⇒ prerequisite hand-off via (delegate to service-itsm-agentic-setup-agentforce-studio-validate
employee path on "yes"); ⇒ surface + stop; studio.signal="CANNOT-CONFIRM"
(confirmed 404) does not block.
- Phase 2 — Idempotency (primary key , fallback key ). Take from Phase 1. Present ⇒ SOQL
BotDefinition WHERE Id='<botDefinitionId>' OR DeveloperName='<developerName>'
(+ subquery — required, else is permanently false; the clause makes a dangling Id link — deleted target — fall back to the live same-name agent instead of a false → duplicate create). Empty/null ⇒ do NOT skip to create; fall back to WHERE DeveloperName='<developerName>'
(a self-created agent's template row is never back-filled, so its stays null even though the agent exists). Either way classify via scripts/classify-agent-existence.mjs ${SCRATCH_DIR}/bot-existing.json "<botDefinitionId-or-empty>" "<developerName>"
. Branch: ⇒ Phase 3 (create); + ⇒ ALREADY-CREATED (skip to Phase 7); + ⇒ Phase 2b. Non-zero exit ⇒ surface CLI error; never assume absent. Why both keys: catches the pre-provisioned (≠ the guess IT_Service_Employee_Agent
); the fallback catches self-created repeats — a miss on both re-creates and hits .
- Phase 2b — Reactivation offer. : "Employee agent exists but latest version is Inactive. Activate it?". On Yes:
POST /connect/bot-versions/<latestVersionId>/activation
with — skips Phases 3–6, straight to Phase 7. Aggregate verdict is ACTIVATED, not CREATED. On No: stop, no writes.
- Phase 3 — Confirm-to-Write (REQUIRED, create path only). If was provided, first render the checkpoint file via with
verdict:"PENDING CONFIRMATION"
(skip for interactive runs). THEN raise the gate presenting developerName + label + "NGA-native from the Employee template's Agent Script". Proceed only on explicit "yes"; on "no" (including "hold off on activation" / "not yet" / any decline of the atomic chain), re-render with and a one-line .
- Phase 4 — Create.
scripts/build-create-body.mjs ${SCRATCH_DIR}/agent-templates.json "<masterLabel>" "<developerName>" "<label>" ${SCRATCH_DIR}/create-bundle-body.json
(helper re-reads Phase-1 templates JSON, HTML-decodes the matched , substitutes internal /, writes body to file — pass the same used in Phase 1), then POST /nextgen-authoring/bundles --body @${SCRATCH_DIR}/create-bundle-body.json
. Capture response — that is the for Phases 5–6, not . 403 FUNCTIONALITY_NOT_ENABLED
/ ⇒ trigger the Phase-1 hand-off; build-script exit 3 ⇒ surface stderr.
- Phase 5 — Publish.
POST /nextgen-authoring/bundle-versions/<bundleVersionId>/publish --body '{}'
(empty body required). Success: { lastPublishedOn, publishedBotId, publishedBotVersionId }
— this call creates the underlying /. Any error ⇒ surface verbatim; never activate an unpublished version.
- Phase 6 — Activate.
POST /nextgen-authoring/bundle-versions/<bundleVersionId>/activate --body '{}'
. Success returns an empty body — check exit code, do not parse a payload.
- Phase 7 — Verify. SOQL
BotDefinition WHERE Id='<id>'
(+ subquery) and classify — is the create path's (captured from Phase 5) or, on the ALREADY-CREATED / reactivation path, the live matched Id the Phase-2 classifier returned (its / output — the actual of the matched record), not the Phase-1 template (which is null on a matchedBy:"developerName"
fallback hit → the verify would run and falsely report failure after a successful skip/activation). Confirm exists:true, count:1, latestVersionStatus:"Active"
. Any discrepancy ⇒ report verbatim, do not fabricate success.
- Phase 8 — Aggregate verdict. Emit CREATED / ALREADY-CREATED / ACTIVATED / FAILED (ACTIVATED on the Phase-2b path) + Id / bundle by re-invoking — the single source of report text. If was provided, overwrite ; otherwise emit stdout as the turn-side report.
Rules / Constraints
| Constraint | Rationale |
|---|
| All calls go through / ; never extract the access token | Leaks a bearer token into shell context; the CLI's stored session is the correct surface |
| Idempotency + verify reads key PRIMARILY on the template's (Phase-1 row) / the publish , falling back to the collected ; that same / also thread through the create body (outer / AND the substituted /) | catches the pre-provisioned (≠ the guessed IT_Service_Employee_Agent
, so a name-only read would false-negative → ); but self-created agents never back-fill it, so the fallback catches those. A create-body hardcode/collect mismatch diverges the bundle's outer identity from the script's internal identity |
| Preflight, idempotency, bundle-body construction, and report rendering all live in , not prose (A9) | JSON parsing + matching + reads + verdict emission are deterministic; the ~70KB Agent Script and free-text apostrophes cannot be safely interpolated into a shell string — in the helper escapes them |
| Three-call sequence: → → , in that order, on the SAME captured (response , not ) | Platform enforces DRAFT → published → active; response-body / empty-body / / / HTML-decode gotchas live in references/error-taxonomy.md
|
| Resolve BEFORE Phase 1; filter to only; disambiguate ambiguous keywords via keyed on | Label-similar pairs exist; other namespaces belong to other flows ( → Fulfiller skill) |
| Enumerate with the subquery; skip create when Active; offer Phase-2b reactivation when Inactive — never silent skip, never duplicate create | Subquery is what distinguishes Active/Inactive; the server rejects a duplicate at publish (unique-constraint → bundle cleanup) but not the pre-provisioned broad agent, so this read is what turns a repeat into a graceful skip instead of a hard error |
| REQUIRED confirm-to-write checkpoint before create sequence or reactivation call | Both change live org state — explicit user approval required |
On / 403 FUNCTIONALITY_NOT_ENABLED
, offer the readiness hand-off — never enable features here; never call legacy /connect/service-itsm/createAgent
| Enablement is a Setup-UI/admin action; produces a Setup-page bot with an external-link icon (wrong kind of agent for this skill) |
| Report exact CLI response text on any error | Enables support to diagnose failures |
Verification Checklist
Output Format
The report layout is generated deterministically by
scripts/render-report.mjs
— the single source of report text for both the chat turn and the harness's
. Never hand-compose the layout in prose (A9); always shell out to the helper. Full rendered shape, report-state JSON schema, and checkpoint-write rules live in
references/report-format.md
.
Terminal verdicts:
CREATED | ALREADY-CREATED | ACTIVATED | PENDING CONFIRMATION | DECLINED | FAILED
. When
is set, write at Phase 2, Phase 6 (or Phase 2b), and Phase 8 — each write overwrites the same file. Skip these writes in interactive/chat surfaces.
Reference File Index
references/specialized-templates.md
— catalog + namespace filter + -based disambiguation (before Phase 1 on any specialization).
references/workflow-detail.md
— exact / commands + full verdict-branch narrative per phase.
references/cli-invocation.md
— command shapes, never-extract-token rule, ITSM Connect API reference, helper-script contracts.
references/reactivation.md
— Phase-2b activation call + full idempotency verdict table.
references/report-format.md
— rendered shape, phase-state JSON schema, three-checkpoint write policy.
references/error-taxonomy.md
— response-body error codes + recurring foot-guns (any non-2xx / empty body / script non-zero exit).