Configures Salesforce Email-to-Case headlessly via Metadata API. Handles CaseSettings, routing addresses, and toggles (HTML email, drafts, word count). Also serves as entry point for attaching an Agentforce agent to Email-to-Case.
Ships in sf-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Configure Salesforce Email-to-Case entirely through the project-codey dispatch / dispatch_readonly tools (no Setup UI, no sf CLI for org calls, except the optional Agentforce probe, whose sf alias must point at the org the server is bound to). The skill builds a CaseSettings source file for the desired emailToCase state, applies it in two phases (the full emailToCase block + Support Settings, then routing addresses; a single write fails on a fresh org), and verifies by re-reading. scripts/apply-casesettings.py makes no org calls: it prints each request for you to dispatch, validates the response you save, and builds the next write (see Dispatch protocol).
Entry modes. A direct user and an orchestrator (delegationFrom set, with an intent) run the same Workflow; what the intent or first message already states is not asked again. Pre-scan, the single confirmation, wording by discoveryMode, and the hand-back are in references/onboarding-delegated-run.md: read it at step 1.
When delegationFrom is set to service-onboarding, fetch and follow
the Service-Onboarding delegation guidelines before acting — it is the single
source of truth, identical across every service-onboarding delegate. When it is absent, ignore this
and run as a normal standalone conversation.
EmailToCase, Outlook, and GmailOAuth routing addresses; applying the change to the org the dispatch server is bound to; verifying by re-reading.E2cEasy routing addresses — created only through the Service Easy Setup wizard, not the Metadata API; route the user there.When the user wants an Agentforce Service Agent to answer these emails, configure the Email-to-Case base (the Workflow below), then delegate; this skill never creates or modifies agents. Before delegating, run scripts/check-agent-email-capability.sh <target-org-alias>. Exit 3 means the org is not entitled: stop, tell the user, and configure the plain base only. Any other non-zero means the org is unreachable. On exit 0, delegate agent creation to agentforce-generate and wiring to service-agentforce-channel-configure Branch C. Details: references/agent-delegation.md.
Every org call is a project-codey tool call that you make; scripts/apply-casesettings.py never touches the org. The loop is always the same:
python3 scripts/apply-casesettings.py requests <kind> ... (or a phase-a / phase-b command). It prints {"requests": [...]} or {"request": {...}}. Each request names the tool (dispatch_readonly for GET, dispatch for the PUT), method, path, and query_params or body.path, query_params, and body verbatim, never edit the xmlRep, and use dispatch only when the request says so.{status_code, body} JSON, or the path the tool saved it to) and pass it to the next subcommand.| Subcommand | Use |
|---|---|
requests org → gate --org F [--confirm-production] | Production-org verdict; non-zero on production without confirmation and always when the org type is unreadable. |
requests settings → read --response F | The current CaseSettings. |
requests lookups --input F --current F ... | User/queue validation queries; pass the results on as --users F / --queues F. |
phase-a, phase-b | Build the PUT request. phase-b may print {"skip": true} when there is nothing new to add. |
check-write --response F | Validates a PUT result. Run it after every write. |
verify --initial F --after F | Preservation guard + verified summary; pass the same flags and lookup files as phase-a. |
requests cases / messages → cases | Act 3 proof. |
Gather or infer before applying. Ask only when a wrong assumption would produce a broken or incorrect result:
sf CLI alias.routingName (unique label), addressType (EmailToCase default, or Outlook / GmailOAuth), caseOrigin, and casePriority. The platform rejects the address if caseOrigin or casePriority is missing, so treat all four as required in the source file.intent or the user's message when stated, otherwise ask explicitly for each, in address order; never guess, default, or reuse from earlier context. Not stored in the source file — passed at apply time via --routing-email (one per address that takes an email — Outlook addresses take none; the script fails closed on a count mismatch).--overwrite-support-settings). Ask only for the field(s) unset.intent or ask (never assume a default user): Default Case Owner type (User/Queue) + value (active Username or Queue DeveloperName) → --owner-type/--owner-value; Automated Case User type (User/System) — User needs a username, System needs no value → --automated-type/--automated-value (+ optional --system-user-email for System when the org's automated user doesn't exist yet).createTask, saveEmailHeaders, and the opt-in per-address Default Case Owner (caseOwner + caseOwnerType, both or neither; see step 6). Omitted by default so cases fall to the org Default Case Owner / assignment rules.emailToCase section (enableHtmlEmail, notifyOwnerOnNewCaseEmail, enableE2CDeduplicateAttachments, showWordCountInComposer, enableE2CSourceTracking, overEmailLimitAction, unauthorizedSenderAction) or at the top level (enableDraftEmails).Defaults: enableEmailToCase and enableOnDemandEmailToCase default to true (both required — On-Demand before routing addresses); addressType defaults to EmailToCase. Support Settings have no default — preserved if set, otherwise elicited (never assumed).
All steps are sequential.
Confirm the org, pre-scan it, and confirm once — run requests org and dispatch it (a failure usually means the server is not connected or bound to the intended org: tell the user and stop). Then run gate --org <file>; on production it exits non-zero until confirmed, so pre-scan anyway and re-run it with the flag after the yes. The gate refuses to mutate a production org (non-sandbox, non-trial) unless --confirm-production is passed, and refuses an org whose type it cannot read even with the flag — enabling Email-to-Case is permanent and org-wide. Send no write before gate succeeds. Pre-scan (read-only): requests settings, dispatch, save as the initial read (keep it unchanged until verify), read --response <file>, and classify it with references/onboarding-delegated-run.md §1 (nothing set up / no change / add / override / ask once). Before the first write, ask one confirmation for every org type, naming the org and its type, and adding that enabling is permanent only when Email-to-Case is not yet on (§2); on production the same yes covers --confirm-production, which you never add before it. No change needed: report, run verify, hand back, with no write.
Elicit the routing email(s) — take the exact customer-facing email for each routing address except Outlook ones from the intent or the user's message when stated, otherwise ask (never assume or reuse a value). Pass them to every phase-a / phase-b / verify command via --routing-email, in source-file order.
Load the template — read assets/CaseSettings.settings-meta.xml for structure and field placement. Its comments are guidance for you; never copy them. Emit only the elements you set, comment-free, as in examples/CaseSettings-two-addresses.settings-meta.xml.
Enable the E2C switches, then confirm the optional toggles — set both enableEmailToCase and enableOnDemandEmailToCase to true (both required; On-Demand must be on before routing addresses can be created — the script enables it in Phase A before Phase B). Then handle the non-required convenience settings, which the template turns on by default:
Enable HTML email (enableHtmlEmail), Eliminate duplicate email attachments (enableE2CDeduplicateAttachments), Show word count in composer (showWordCountInComposer) and Notify case owners on new emails (notifyOwnerOnNewCaseEmail) all go inside <emailToCase>. Enable Email Drafts (enableDraftEmails) is a top-level Support Settings field at the CaseSettings root.
On a fresh setup, tell the user exactly which will be turned on (in the guided wording of references/onboarding-delegated-run.md §3 when discoveryMode is "guided") and let them opt out; an opt-out already in the intent is not asked again. Remove any they decline; keep the rest in place (four inside <emailToCase>, enableDraftEmails at the root). Never enable an optional flag the user didn't agree to. On an org that already has Email-to-Case, do not apply these defaults: include only the toggles the user chose to change. Confirmed toggles apply in Phase A.
Pick the correct surface per routing address — for each address, decide by addressType using references/routing_address_reference.md. If any requested address is E2cEasy, stop and route the user to the Service Easy Setup wizard instead of emitting Metadata for it.
Populate routing-address fields — for each EmailToCase / Outlook / GmailOAuth address, set addressType, routingName, caseOrigin, and casePriority (all required; the platform rejects the write without caseOrigin or casePriority), plus any optional case defaults. An Outlook address must also set caseOwner + caseOwnerType (the platform rejects it with "Missing caseOwner") and takes no email — the platform rejects emailAddress on it. Do not put emailAddress in the source file (it comes from --routing-email), and do not set the read-only emailServicesAddress or isVerified. See examples/CaseSettings-two-addresses.settings-meta.xml for a multi-address example.
Per-address Default Case Owner is opt-in. Ask one address at a time whether its cases go to a specific owner or fall to the org Default Case Owner / assignment rules (the default). If the user declines, leave caseOwner/caseOwnerType out of the source file; if they opt in, set both.
Determine Support Settings (Default Case Owner + Automated Case User) — from the step 1 read, inspect defaultCaseOwner / defaultCaseUser / useSystemUserAsDefaultCaseUser. When the user names a value, write it into the source file (defaultCaseOwner + defaultCaseOwnerType; defaultCaseUser, or useSystemUserAsDefaultCaseUser + optional systemUserEmail); the script also accepts these as flags. Leave each field the org already has as-is (override only if the user asks, with --overwrite-support-settings). For a field unset and not named in the intent or by the user, ask; never assume a user.
Validate the source file — run python3 scripts/validate-casesettings.py [--no-addresses-ok] <source-file> (the flag for a toggle-only file) and fix any errors.
Apply to the org — with <flags> = --input <source-file> --routing-email <email-1> [--routing-email <email-2> ...] (exactly one per non-Outlook routing address, in document order) plus, only when Support Settings are not already configured (step 7), [--owner-type User|Queue --owner-value <username-or-queue-devname>] [--automated-type User --automated-value <username> | --automated-type System [--system-user-email <email>]] (add --overwrite-support-settings only if the user asked to change a configured field):
requests lookups --current <initial-read> <flags>; dispatch each printed request (it is empty when there is nothing to validate) and keep the results as --users / --queues.phase-a --current <initial-read> <flags> [--users F] [--queues F] → dispatch its request (a PUT), then check-write. Keep its summary.requests settings, dispatch, save as the fresh read → phase-b --current <fresh-read> <flags> [--users F] [--queues F] → if it prints a request, dispatch it and check-write; if it prints skip, there is nothing to add. Keep its phaseB list.requests settings, dispatch, save as the final read → verify --initial <initial-read> --after <final-read> <flags> [--users F] [--queues F] (the same lookup files as phase-a; verify re-resolves Support Settings against them).If a script command rejects a value, relay it, get a valid one, and re-run from that command. Add --confirm-production only after the user's yes (step 1). A failed check-write stops the run: report the platform message verbatim (see references/troubleshooting.md) and do not re-send an edited payload.
Confirm the result — check the verify output and the kept summaries: verified.enableEmailToCase / verified.enableOnDemandEmailToCase are true, verified.routingAddressCount matches the expected count, each phaseB entry is status: created (or already_exists), and supportSettings.action is preserved-existing / set-from-input / overwrote-existing. Use requests settings + read to re-read without writing. When called by an orchestrator, report what was set, what was left as it was, and what remains for the user, then hand control back (references/onboarding-delegated-run.md §5).
The items below are not workflow steps — present them to the user once setup is confirmed.
Always give the user this guidance; it is how inbound mail actually reaches Salesforce:
Your routing address now has a Salesforce-generated email services address. To receive inbound mail, forward mail sent to your customer-facing address (e.g.
[email protected]) to that address.
Offer once, on a direct run only, to prove that inbound email creates Cases (a live round-trip; skip it if declined); on a delegated run, only if asked. The skill never sends email: the user verifies the address and sends a test email, then a read-only check looks for the Case. Follow references/end-to-end-proof.md.
| Constraint | Rationale |
|---|---|
Apply in two phases built by apply-casesettings.py (PUT to /headless/metadata), never a single combined write or a minimal emailToCase patch | A single write fails on a fresh org, and only the full emailToCase block provisions On-Demand before addresses bind. See references/apply-mechanics.md. |
All org reads and writes go through dispatch_readonly / dispatch; the only sf use is the Agentforce capability probe | The MCP server owns auth and org binding. Do not fall back to the sf CLI, SOAP, or a hand-built token if dispatch is unavailable — stop and tell the user. |
Make each dispatch call exactly as the script printed it, and send no write before gate succeeds | The payloads encode the validated two-phase mechanism and the production safety check; an edited xmlRep or a skipped gate defeats both. |
Write only the top-level fields the skill owns; never echo the whole CaseSettings record | The platform re-validates every top-level field sent (e.g. Case Feed needs Chatter). Omitted fields keep their values. See references/apply-mechanics.md. |
The customer-facing email must be explicit input (--routing-email, from the user or the intent), never in the source file and never assumed | Prevents a guessed or stale address from being provisioned. The script fails closed if --routing-email count ≠ address count. |
| Support Settings are preserved per field if configured; never assumed if not | Each configured field is left untouched (unless --overwrite-support-settings); an unset field needs an explicit, org-validated value, or the script fails closed. |
Automated Case User "System" and a named defaultCaseUser are mutually exclusive | --automated-type System sets useSystemUserAsDefaultCaseUser and must not carry a user value; the platform rejects both. |
| The script reads → patches → updates (append-only for addresses) | Existing routing addresses are preserved; a duplicate routingName/emailAddress is reported as already_exists. New addresses are emitted before existing ones, and a runtime guard fails the run if any existing address is dropped. See references/apply-mechanics.md. |
EmailToCaseSettings is never applied directly; enableEmailToCase cannot be turned off once on | It is written only as the emailToCase child of CaseSettings. The platform permanently enables the feature after the first true apply; never rely on setting it back to false. |
Production orgs require explicit --confirm-production; never add the flag unprompted, and never before the single confirmation of step 1 | Enabling Email-to-Case is permanent and org-wide. The script fails closed on a non-sandbox, non-trial org (and one whose type it can't read) until the user confirms. Sandboxes and trials are exempt. |
E2cEasy addresses must use the Service Easy Setup wizard | The prebuilt service_case queue binding and isVerified flip are not reproducible through the Metadata API. |
For the full symptom → resolution table (Phase B errors, Case Feed/Chatter, owner half-fills, GmailOAuth, the cases proof, toggle placement), read references/troubleshooting.md.
A comment-free CaseSettings source file, the applied org state, and the script's JSON summaries.
| File | When to read / run |
|---|---|
references/onboarding-delegated-run.md | Step 1 — pre-scan, single confirmation, guided wording, permission message, hand-back |
references/apply-mechanics.md | Before changing how the script builds or sequences writes |
references/troubleshooting.md | An apply or verify error, or a setting that doesn't behave |
references/agent-delegation.md | Attaching an Agentforce service agent |
references/end-to-end-proof.md | After setup, the optional inbound-email proof |
references/routing_address_reference.md | Steps 5–6 — address fields and addressType surface |
assets/CaseSettings.settings-meta.xml | Step 3 — the source-file template |
examples/CaseSettings-two-addresses.settings-meta.xml | Step 6 — multi-address structure |
scripts/check-agent-email-capability.sh | The pre-delegation capability gate |
scripts/validate-casesettings.py | Step 8 |
scripts/apply-casesettings.py | Steps 1, 7, 9, 10 |
assets/CaseSettings.settings-meta.xml (opens in a new tab)examples/CaseSettings-two-addresses.settings-meta.xml (opens in a new tab)references/_vendored/service-onboarding-delegation-guidelines.md (opens in a new tab)references/agent-delegation.md (opens in a new tab)references/apply-mechanics.md (opens in a new tab)references/end-to-end-proof.md (opens in a new tab)references/onboarding-delegated-run.md (opens in a new tab)references/routing_address_reference.md (opens in a new tab)references/troubleshooting.md (opens in a new tab)scripts/apply-casesettings.py (opens in a new tab)scripts/check-agent-email-capability.sh (opens in a new tab)scripts/tests/__init__.py (opens in a new tab)scripts/tests/_agent.py (opens in a new tab)scripts/tests/_bootstrap.py (opens in a new tab)scripts/tests/_fakeorg.py (opens in a new tab)scripts/tests/_run.py (opens in a new tab)scripts/tests/test_apply_org_scenarios.py (opens in a new tab)scripts/tests/test_dispatch_contract.py (opens in a new tab)scripts/tests/test_new_capabilities.py (opens in a new tab)scripts/tests/test_validate_casesettings.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/sf-skills:service-email-to-case-configurefrom sf-skills
sf-skills@sf-skills-plugin is listed by ccmalcom/sf-skills-plugin — review the source before installing
npx claudepluginhub ccmalcom/sf-skills-plugin --plugin sf-skills266 skills in this plugin
/afcc-setup-coordinateOrchestrates end-to-end headless setup of Agentforce Contact Center (AFCC) on a Salesforce org. Scans the org first, presents a delta plan for approval, then sequentially provisions demo users, Omni-Channel base settings, a human queue with routing config and members, presence statuses, permission sets, a PSTN voice number, and an active PstnVoice MessagingChannel wired to the queue. Interactive at key decision points — never assumes country, number type, queue names, or user counts. TRIGGER: set up AFCC, configure Agentforce Contact Center, stand up voice contact center, AFCC migration setup, provision AFCC org headlessly./agentforce-architecture-analyzeDeclared architecture snapshot for one Agentforce agent: planner, topics, actions, flows, Apex, prompt templates, and NGA plugins. Renders a human-readable architecture document and Mermaid invocation graph from design-time metadata (not runtime audit rows). TRIGGER when user asks to describe, diagram, inventory, audit, document, or diff (e.g. v3 vs v5) the architecture / action tree / topic structure / tool inventory of a specific agent by agent API name in a specific org. DO NOT TRIGGER for runtime session traces, conversation transcripts, generation timings, or gateway audit chains — this skill reads design-time metadata only (use agentforce-d360-analyze for session traces).Other plugins' skills for the same job