In creating an enhanced Einstein bot in Salesforce, you might notice that there is nowhere for you to simply "key in" a value to a variable. For instance, you might want to say "As soon as I start this dialog, I want to record its value in a variable called "CurrentDialog". You go and add your "Set a variable" element to the screen, but you then notice that you can only set variables to other variables, and cannot set net new variables with custom values. You head to the Variables tab to see if you can default your new variable to a value. Unfortunately, you run into the same problem.

The good news is, Flow lets you set these values super easily! The setup is very easy and can be used anywhere for setting values. Additionally, you can use just a single Flow over and over to set your custom variables. Here are the steps to set this up:

Step 1: Create a net-new Autolaunched Flow

a Flow of type "Autolaunched"

Step 2: Add a new variable called Einstein_Input, marked Available for input:

Einstein_Input variable

Step 3: Add a new variable called Einstein_Output, marked Available for output

Einstein_Output variable

Step 4: Assign the value of Einstein_Input to Einstein_Output

Step 5: Save (since this Flow's reusability is high, keep the name unspecific, like "Auto-Einstein-SetEinsteinVariables") and Activate

Step 6: In your Einstein bot, grab the Flow component from the Dialog Component Library

Step 7: Drag it on screen and select your Flow

Step 8: Toggle from "Variable" to "Value" in the Input section, and write the value you want to set. Create a new Custom variable to accept the value and put that in the Output section

Step 9: You're done! You can preview your variable by displaying it onscreen in a message component

This can also be done with Apex, but you carry some extra burden there with code coverage and documentation of the utility class.

I hope that helps answer the question of how to set custom values in variables in Einstein bots in Salesforce.

Setting Variables in Advanced Einstein Bots