function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kevin 13Kevin 13 

Set variables in Einstein bot Builder

Hi Salesforce enthousiasts,

We are currently working on a Einstein bot, but we are facing difficulties tackling potential performance issues. Based on the dialog that the customer has with the bot, we know the Type of question the customer has. We want to save this information to the Case object, on the Type field. We want to run this flow when the chat is transferred to an agent - and not in each dialog - because it queries the Case object. 

Ideally we thus set variables during the chat, and finally push those values to the Case object at the end of the bot conversation. For example, custom had a question about Store and Opening Hours.

However we found that we cannot store values to a variable, using "Set Variable" in a Rule. Source Variable can only be Context Variables, and Destination variable not a value like you can when calling a flow.

User-added image

The current work around we have in place is that we call a flow with the custom value. This flow then just assigns the value and outputs back to the Einstein bot. The output is saved in the custom variable. When we transfer the chat to an agent, we then have a seperate flow that updates the fields on the Case object. This is not ideal - although we are not quering objects - because we are still calling many flows throughout the bot conversation.

User-added image

But this leads to running flows in almost all dialogs, which does not seem optimal. There must be a better way that I'm currently missing out on. Any idea how we can best tackle this problem? Thanks!
Best Answer chosen by Kevin 13
Kevin 13Kevin 13
We solved this issue by using Questions shown as a menu, instead of showing regular menu's. We capture the values within the questions, and then pass those values to a flow at the end of the bot conversation. 

All Answers

Kevin 13Kevin 13
We solved this issue by using Questions shown as a menu, instead of showing regular menu's. We capture the values within the questions, and then pass those values to a flow at the end of the bot conversation. 
This was selected as the best answer
Bhuvaneswary RadhakrishnanBhuvaneswary Radhakrishnan
Hi Kevin,
May I know how are you setting the value using Question?
Ranjith Kumar 162Ranjith Kumar 162
Bhuvaneswary, you can present a question with different options to the user. Then you can store the user's response into a variable. Please refer to the below article for more information on how to set up question step.
https://help.salesforce.com/s/articleView?id=sf.bots_service_setup_dialog_question.htm&type=5