Skip to content

forcedotcom/sf-skills / plugins/builder/service-engagement/skills/service-email-to-case-configure

service-email-to-case-configure

Verified

Use to configure Salesforce Email-to-Case headlessly via the Metadata API. Reads CaseSettings, applies the emailToCase config with updateMetadata, and verifies by re-reading. Also the entry point for attaching an Agentforce agent to Email-to-Case: configures the E2C base, then delegates agent creation and channel wiring. TRIGGER on set up/configure Email-to-Case, enable E2C routing addresses, add a routing address, or E2C with an Agentforce agent. DO NOT TRIGGER for the interactive Easy Setup wizard, On-Demand E2C only, general Case/web-to-case setup, or an agent with no E2C involved.

scripts/tests/_run.py

View on GitHub
"""Helpers to drive apply-casesettings.py main() in tests: write a temp
CaseSettings input file and invoke main() with an argv, capturing the JSON
summary it prints. main() calls fail()->sys.exit(1) on error, and argparse may
sys.exit(2); both surface as SystemExit for the test to assert on.
"""
from __future__ import annotations

import io
import json
import tempfile
from contextlib import redirect_stdout
from pathlib import Path
from unittest import mock


def write_input(tmpdir: str, xml: str) -> str:
    path = Path(tmpdir) / "Case.settings-meta.xml"
    path.write_text(xml, encoding="utf-8")
    return str(path)


def run_main(apply_mod, argv):
    """Run main() with the given argv (excluding program name). Returns the
    parsed JSON summary dict printed to stdout. Raises SystemExit as-is."""
    buf = io.StringIO()
    with mock.patch("sys.argv", ["apply-casesettings.py", *argv]):
        with redirect_stdout(buf):
            apply_mod.main()
    out = buf.getvalue().strip()
    return json.loads(out) if out else {}


class Input:
    """Fluent builder for a CaseSettings source XML string."""

    def __init__(self):
        self._top = {}
        self._e2c = {"enableEmailToCase": "true",
                     "enableOnDemandEmailToCase": "true"}
        self._addrs = []

    def top(self, **kv):
        self._top.update(kv)
        return self

    def e2c(self, **kv):
        self._e2c.update(kv)
        return self

    def no_e2c_defaults(self):
        self._e2c = {"enableEmailToCase": "true",
                     "enableOnDemandEmailToCase": "true"}
        return self

    def with_default_toggles(self):
        self._e2c.update({
            "enableHtmlEmail": "true",
            "notifyOwnerOnNewCaseEmail": "true",
            "enableE2CDeduplicateAttachments": "true",
            "showWordCountInComposer": "true",
        })
        self._top["enableDraftEmails"] = "true"
        return self

    def address(self, **kv):
        self._addrs.append(kv)
        return self

    def build(self) -> str:
        lines = ['<?xml version="1.0" encoding="UTF-8"?>',
                 '<CaseSettings xmlns="http://soap.sforce.com/2006/04/metadata">']
        for k, v in self._top.items():
            lines.append(f"    <{k}>{v}</{k}>")
        lines.append("    <emailToCase>")
        for k, v in self._e2c.items():
            lines.append(f"        <{k}>{v}</{k}>")
        for addr in self._addrs:
            lines.append("        <routingAddresses>")
            for k, v in addr.items():
                lines.append(f"            <{k}>{v}</{k}>")
            lines.append("        </routingAddresses>")
        lines.append("    </emailToCase>")
        lines.append("</CaseSettings>")
        return "\n".join(lines) + "\n"
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall