Contact Us

May 7, 2025

May 13, 2026 4:37 pm

Using custom variables in Agentforce instructions

Share with

Understanding Custom Variables in Agentforce

Custom variables in Agentforce allow you to store and reuse values throughout your instructions. To use a custom variable in an instruction, you first need to create the variable and set its value. You can do this through the output of an action or by manually setting the value.

Once you have created and set the value of your custom variable, you can reference it by name in your instructions. For example, if you have a custom variable named “customerName”, you can reference it in your instruction like this: “Hello, $customerName”.

Configuring Custom Variables

To use custom variables in your instructions, you need to configure them correctly. This includes checking the checkbox “Allow LLM to use value” and setting the variable’s description.

The root cause of the issue is that the custom variable is not being referenced correctly in the instruction, and the variable’s description is not set.

To fix this issue, you need to reference the custom variable by name and set the variable’s description. You also need to make sure that the variable is being set correctly through the output of an action or by manually setting the value.

Step-by-Step Solution

Here are the steps to use custom variables in Agentforce instructions:

instruction.txt

customerName = "John Doe"
instruction = "Hello, $customerName"

Checklist

  • Reference custom variables by name in instructions
  • Set the variable’s description
  • Check the checkbox “Allow LLM to use value”
  • Set the variable’s value through the output of an action or manually
  • Test the instruction to make sure it is working correctly

Frequently Asked Questions

What is the format for referencing custom variables in instructions?

You can reference custom variables by name, without the need for the {!VariableAPIName} format.

How do I set the value of a custom variable?

You can set the value of a custom variable through the output of an action or by manually setting the value.

What is the purpose of the “Allow LLM to use value” checkbox?

The “Allow LLM to use value” checkbox allows the LLM to use the value of the custom variable in the instruction.

How do I test my instruction to make sure it is working correctly?

You can test your instruction by running it and verifying that the custom variable is being referenced correctly.

Genetrix Technology · Salesforce Marketing Cloud Partner

Need help shipping this in production?

Genetrix builds and untangles Salesforce Marketing Cloud and Agentforce setups for teams that want it done right the first time. If anything in this post sounds familiar, talk to us before it ships.

Get in Touch with Genetrix →

Blogs for the

Business-Savvy!​

Let’s Connect

A 30 min no cost strategy session
with cloud support expert

Let’s Connect

A 30 min no cost strategy session
with cloud support expert