You are here:
Grounding with Context Variables
Learn how Service Assistant uses context variables to pass the active record into plan steps and actions, and review the configuration guidelines.
Required Editions
| View supported editions. | |
This article applies to: |
Service Assistant for Case and Messaging. |
Context Variables in Service Assistant
Context variables are predefined values that Service Assistant reads automatically at the start of a session to generate more relevant plan steps. They let actions work with the current record without the service rep entering that information manually.
Service Assistant uses these context variables.
- SeedPlanWithGuidance: Lets Service Assistant pull in context from the current record, such as case grounding fields and the messaging session transcript, to generate plan steps and assign a subagent when the record meets your eligibility criteria. This variable is provided automatically and is listed on the Context tab in Agentforce Builder. No setup is required, and you don't modify the variable.
- currentRecordId: Passes the ID of the record on the rep's screen into plan steps and actions. Service Assistant doesn't automatically read the record's field values or related data. You create this variable manually.
The behavior of currentRecordId depends on the object.
- For cases, currentRecordId is the case record ID, the 18-character Salesforce ID of the case that the rep has open.
- For messaging sessions, currentRecordId is the messaging session ID, not the contact ID. Service Assistant draws conversation and customer context only from the transcript and the currentRecordId context variable. It doesn't receive additional context from the record itself or related records such as Contact or Case.
To make record context available to actions and plan steps, create the currentRecordId context variable and assign it to your action inputs. See Set Up Context Variables for Service Assistant.
You assign currentRecordId to an action's input so the action can perform work such as looking up order history or updating related records, without the rep entering the ID or contact information manually.
Service Assistant for Messaging doesn't directly support grounding on related records, including any previous messaging sessions. To include related record data in the service plan, build an agent action that takes currentRecordId as input and queries the fields you need. For messaging sessions, use EndUserContactId to retrieve the associated Contact for customers already in your CRM, or MessagingEndUserId for customers identified through a messaging channel. This action returns the relevant fields for Service Assistant to produce more context-based plan steps.
Use Context Variables with Action Inputs
To use context variables with actions, add them to the action's input field. When you assign currentRecordId to an action input, Service Assistant automatically passes the current record ID into the action at session start. The rep doesn't enter a record ID manually, such as when an action closes or escalates a case.
For steps to create and add the context variable, see Set Up Context Variables for Service Assistant. If you use a flow-based action, complete additional steps in Flow Builder to add the context variable as an input to the flow.
Considerations
- Context variables are session-scoped. They're set when the session starts and don't update mid-session. If the rep navigates to a different record during a session, the context variable still reflects the record that was open when the session began.
- Specify the expected ID format in the action input instructions. If an action input expects an 18-character Salesforce record ID, state that explicitly. For example: The 18-character Salesforce record ID of the case. Don't use the case number. This reduces the risk of the agent passing the wrong value.

