Loading
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 Context Variables in Messaging Conversations

          Use Context Variables in Messaging Conversations

          Personalize agent conversations over messaging channels with context variables. Context variables let your agent use Messaging Session record fields as action inputs.

          Required Editions

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

          CheckmarkThis article applies to: Agentforce Service agents and Agentforce Employee agents

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

          User Permissions Needed  
          To build and manage Service agents:

          Manage Agentforce Service Agents AND Manage AI Agents

          OR

          Customize Application

          To build and manage Employee agents:

          Manage AI Agents and Manage Agentforce Employee Agents

          OR

          Customize Application

          Note
          Note These steps are required for Agentforce Employee agents connected to Enhanced Chat. These steps aren't required for Agentforce Employee agents connected to the Agentforce panel in Lightning Experience, the Salesforce mobile app, or Slack.

          Before you begin, connect your agent to a messaging channel.

          Context variables let you map Messaging Session object fields to messaging channels. For example, to save your agent from having to ask for common information conversationally, you can configure your agent to reference any Messaging Session object field, including the ones populated via a pre-chat form. This data can even be used as an input for actions. We don't recommend using context variables for authentication.

          Before updating context variables, deactivate your agent.

          1. Choose variable fields.
            1. On the Agentforce Agents Setup page, click the name of your agent to open its Details page.
            2. Click Open in Builder and then select the Context tab.
            3. In the Session Variables section, select a variable.
            4. To add variable fields to your agent, click Update Included Fields. Select the fields that you want the agent to use, and then save your changes.

              By default, agents include a Messaging Session variable that’s mapped to a MessagingSession record. Agents can use the information stored in the Messaging Session ID, Messaging User ID, and other included fields. They can also automatically update the Messaging Session record as they chat with customers.

              You can create custom context variable fields that appear in your agent’s Messaging Session context variable. To create custom variable fields, add custom fields to the Messaging Session object.

          2. Add field values to the Messaging Session record by using a pre-chat form, your inbound Omni-Channel flow, or Pre-Chat API.
            1. To use the Pre-Chat form, create and customize an Enhanced Chat pre-chat form. You can add standard and custom fields to the pre-chat form. Then map your pre-chat values to your messaging channel and update your inbound Omni-Channel flow.
            2. To use your inbound Omni-Channel flow, customize your inbound Omni-Channel flow so that it passes information from previous messaging sessions to your agent. See Persist Pre-Chat Inputs Across Messaging Sessions.
            3. To use Pre-Chat API, send user data that isn’t visible in the pre-chat form, known as hidden pre-chat fields, to your agent. See Enhanced Web Chat Hidden Pre-Chat API, iOS Hidden Pre-Chat API, and Android Hidden Pre-Chat API.
          3. To use a context variable field during agent conversations, add the field API name to instructions and use the fields in action inputs.

          You can’t test context variable use cases in Agentforce Builder because using variables requires a Messaging Session record. To test context variables, create a messaging session as a channel experience.

           
          Loading
          Salesforce Help | Article