You are here:
Set Up Context Variables for Service Assistant
Give Service Assistant the ID of the active record so that it can complete actions such as closing a case or updating a record without the service rep entering the ID manually.
Required Editions
| View supported editions. | |
This article applies to: |
All Service Assistant experiences. |
| User Permissions Needed | |
|---|---|
| To set up context variables in Service Assistant: | Service Planner Builder permission set AND System Admin OR Customize Application |
First, create the currentRecordId context variable. Then assign it as an input to each action that needs the record ID, including flows, prompt template, and Apex actions.
We include steps for adding currentRecordId to a flow because the setup is specific to flow-based actions. For other action types, such as prompt template and Apex actions, assign currentRecordId to the action's input.
Set Up the Context Variable
Create the currentRecordId context variable and add a description so that Service Assistant knows when to use it.
- In Agentforce Builder, deactivate your agent.
- Select the Context tab and click New Variable.
-
Enter these values.
- Name: currentRecordId
- API Name: currentRecordId
- Data Type: Text
- Description: The ID of the record on the user's screen. It might not relate to the user's input. Use this only if the user input mentions "this," "current," or "the record." If in doubt, don't use it.
- Select both Allow value to be set by API and Allow LLM to use value.
- Click Save.
- Reactivate your agent.
Assign the Context Variable to Flows
If you use a flow-based action, add currentRecordId as an input variable and update the Get Records element to filter by it.
- In Flow Builder, open your flow.
- Click New Resource and select Variable.
-
Enter these values.
- API Name: currentRecordId
- Data Type: Text
- Select Available for Input.
- Click Done.
- Click New Resource again and select Variable.
-
Enter these values.
- API Name: a name for your record variable, such as caseRecord or messagingRecord
- Data Type: Record
- Object: the object that your flow retrieves, Case or Messaging Session
- Click Done.
- Open the Get Records element.
-
Under Filter Records, set these values.
- Field: Case ID or Messaging Session ID
- Operator: Equals
- Value: currentRecordId
- Under How to Store Record Data, select Choose fields and assign variables (advanced).
- Under Where to Store Field Values, select Together in a record variable.
- Under Select Variable to Store Record, select your record variable, caseRecord or messagingRecord.
- Save your flow.
Return to Agentforce Builder and assign the context variable to your actions.
Assign the Context Variable to an Action Input
Assign currentRecordId to an action input so that Service Assistant automatically passes the current record ID into the action at session start.
- In Agentforce Builder, open an action.
- From the input field, select Assign a Variable and choose currentRecordId.
- Make sure that Available for Input is selected on the input field.
- Save and reactivate your agent.
- Start a new session. Context variables are populated at session start and don't update mid-session.
Keep in mind that the behavior of currentRecordId depends on whether Require User Confirmation is selected on the action.
- If Require User Confirmation isn't selected, Service Assistant automatically passes the record ID into the action without prompting the rep.
- If Require User Confirmation is selected, Service Assistant pauses and displays a confirmation prompt to the rep with the record ID prefilled.


