Loading
Upcoming Mandatory Changes to Public Key Infrastructure (PKI)Read More
Salesforce Enforces New Security Requirements in Summer 2026Read More
Agentforce and Einstein Generative AI
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Use Custom Variables for Agentforce Service Email

          Use Custom Variables for Agentforce Service Email

          Agentforce Service Agent now passes inbound email context, such as the Case ID, into custom variables instead of bundling it with the user message. You can reference these variables in your topics and action inputs for more reliable automation.

          Required Editions

          Available in: Lightning Experience
          Available in: Enterprise, Performance, Unlimited, and Developer Editions. Required add-on licenses vary by agent type.

          Check markThis article applies to: Agentforce Service agents

          Cross markThis article doesn't apply to: Agentforce Employee agents

          To learn about channel support for other agent types, see the documentation for that type.

          User Permissions Needed
          To create email templates: Lightning Experience User
          To edit public email templates: Modify All Data, Manage Public Lightning Email Templates, or template ownership
          To create Agentforce Service Agent email configurations: Manage Agentforce Service Agents AND Manage AI Agents OR Customize Application
          To edit routing addresses: Customize Application
          To create Omni-Channel flows: Customize Application

          Your agent must have the Service Email Connection enabled to receive inputs to these variables.

          • New Agents: Agentforce Service Agents have these variables predefined.
          • Existing Agents: You must manually add these variables to your agent configuration.
          Note
          Note If your topics or actions rely on instructions like "find the case ID in the transcript," update your instructions to reference the specific variable names, such as emailCaseId.

          Manually Add Custom Variables

          If you have an existing agent, follow these steps to ensure it can process email context correctly:

          1. In Setup, search for Agentforce Agents. Select your agent and click Open in Builder.
          2. Deactivate your Agent. You cannot modify custom variables while the agent is active.
          3. Click on the Context tab in the Builder.
          4. Click New Variable and create a new variable for each email context.
          5. Once all variables are added, click Save and then Activate.
          Required Email Custom Variables
          Name & API name DescriptION Data Type set by Api allow llm to use
          emailCaseId Stores the Salesforce Case ID created by an inbound email. Text True True/False*
          endUserEmail Stores the email address of the person who sent the email. Text True True/False*
          endUserContactId Stores the Salesforce Contact ID assocaited with the sender. Text True True/False*

          Set "Allow LLM to use value" to True if you want the agent to reason with its data in its instructions, or False if it is only needed as an input for actions.

          Best Practices for Topic Instructions

          Update your Topic and Action configurations:

          • Direct Mapping: In your Action inputs, map the input directly to the custom variable (e.g., map a "Close Case" action input to emailCaseId).
          • Explicit Instructions: Update Topic instructions to say: "Use the emailCaseId variable to identify the current record," rather than searching the conversation history.
           
          Loading
          Salesforce Help | Article