In our previous blog post, we introduced the powerful new Einstein Bots Platform API. In this post, we’ll discuss how Einstein Bot transfers work and we’ll take a deep dive into how bot-to-bot transfers work and how to share data between bots.

What is an Einstein Bot chat transfer?

A bot chat transfer is an automated process by which the system transfers the user to either a different chatbot or to a human agent. Transfers can happen due to various reasons such as:

  • Due to a user request
    • During a chat session users can, for various reasons, request to be transferred to a human agent
  • Due to an error condition
    • When processing a chat request from a user, if there is an error/exception in the system (e.g., for a service call failed or timed out), the bot will initiate a transfer request
  • Due to a pre-defined configuration
    • The bot admin can configure the bot in such a way that if the user types a certain phrase/intent, or the dialog flow leads the chat to a certain condition, then a transfer is automatically initiated

You can read more about Einstein Bot chat transfers in the documentation.

How do chat transfers work?

As explained in our previous blog post, all non-API chat sessions are configured to work over Salesforce-managed channels. That is, the chat is initiated on behalf of the user and is terminated or transferred to a different bot or a human by a Salesforce-owned channel management system.

The following sequence diagram illustrates a typical bot-to-bot chat transfer scenario.

The context of the diagram above is that there is an ongoing chat session between the user and Einstein Bot 1. The sequence follows these steps:

  1. The user sends a chat message intended for Einstein Bot 1.
  2. The message is received by the Salesforce channel and then relayed to Einstein Bot 1.
  3. Einstein Bot 1 initiates a chat transfer request. The bot can do this for any of the three main reasons that we describe earlier in this post (see the “What is an Einstein Bot chat transfer” section).
  4. The target of the transfer can be a human agent, a Salesforce queue, or a different bot. In this scenario, the transfer target is Einstein Bot 2, which makes it a typical bot-to-bot transfer scenario.
  5. Once the corresponding Salesforce channel receives the transfer request from Einstein Bot 1, it then simply establishes a brand new chat session with the target (Einstein Bot 2) in the same way it did with Einstein Bot 1.
  6. Einstein Bot 2’s reply to the chat initiation is relayed to the user who then starts chatting with Einstein Bot 2.

Note that the transfer happened seamlessly without the user noticing it (unless the user explicitly asked for it)

Chat transfers with the Einstein Bot Platform API

With the new Einstein Bot Platform API, chat transfers work differently. There is no Salesforce channel to perform an automated chat transfer, the client’s system has to do the actual transfer.

Let’s explore this using our bot-to-bot transfer scenario. The diagram below illustrates a chat transfer using the Einstein Bot Platform API.

Again, the context of this sequence diagram is that there is an ongoing chat session between the user and Einstein Bot 1. The sequence follows these steps:

  1. The client sends a chat message to Einstein Bot 1. Note: here the client is actually a system (a web service/a chat client) written by the user and not by Salesforce. The end-user is actually interacting with this client.
  2. Einstein Bot 1 initiates a chat transfer request. This transfer initiation response is essentially a simple response object containing the target information of the transfer. You can read more about this response object in the Einstein Bots Platform API client guide.
  3. The transfer target in the above case is Einstein Bot 2.
  4. Once the customer’s client receives this response, it then simply establishes a brand new chat session with the target (Einstein Bot 2) in the same way it did with Einstein Bot 1.

As can be seen, the Einstein Bots Platform API provides only the relevant information to the client to make the transfer. The API by itself does not perform the actual transfer.

Chat transfers with the API are explained in detail with a bot-to-case transfer example in the Einstein Bots Platform API client guide.

Let’s now explore a specific use case: sharing data between bots during a bot-to-bot transfer.

Bot-to-bot transfers

When designing an automation system, such as a chatbot that interacts with customers, bot admins often break down the solution into multiple independent components/bots. For example, consider an eCommerce web application. The chatbot on such a website has a myriad of tasks that can be performed independently of each other. For example, one task can sell/place orders, another task can track an order, another one can collect feedback from customers, and so on. Each of these tasks can be performed independently, and there is no need to put all that logic in a single bot, which would end up being a maintenance nightmare. Essentially, the bot admin can define multiple smaller bots that perform each of the above tasks independently.

With a group of bots working together to achieve a certain goal, there is often a need to share some data that’s critical to their functionality. For example, in the eCommerce chatbot design, the order tracking bot would need to know the order number, and instead of asking for that information from the customer, this bot can get that from the bot that placed the order.

The following sections describe how we can effectively share information amongst bots with the new Einstein Bots API.

Share chat data between bots during a transfer

Data can be shared between two bots during a bot-to-bot transfer via bot variables. To understand this concept better, we’ll explore an example scenario.

First, let’s define two bots: “Variables Bot” and “VariablesReceiver Bot.” The following two screenshots show the two bot implementations:

For the Variables Bot, we’ve defined three custom variables:

  • name
  • email
  • company

Also, the last element in the Variables Bot is a Rules element that sets up the transfer response of the bot. You can read more about setting up this transfer response in the documentation.

Let’s initiate a chat session with the Variables Bot and collect the responses for the above three variables from the user.

Initiate a chat session with the Variables Bot:

Contents of the body.json should look like this:

A sample output of the above command would be something like the following:

Next, let’s answer all the questions the bot is asking to collect all the necessary variables.

Collect the Name variable:

Collect the email variable:

Collect the company variable. According to our bot definition, this is the last user input that the bot will request and then it will return a response message of type escalate. The escalate message contains the bot-id to which the ongoing chat should be transferred. Since this is the last expected user input for the Variables Bot, we can now include a parameter in the request that indicates to the Variables Bot that it has to include all variables of the Variables Bot in the response.

The parameter is as follows:

Therefore the request command would look something like the following:

The response to the above command should be as the following:

The response is of type escalate with a target property of type Salesforce:Core:Bot:Id and its value is the bot-id of the VariablesReceiver Bot. The response also includes a variables array that contains our three variables: name, email, and company. It also contains some extra variables among which is the VariableReceiver variable that we created in the Variables Bot to set up our bot-to-bot transfer.

NOTE: The transfer hasn’t happened yet. The Variables Bot just provided the client (us) with the information required to actually make the transfer. In this case, that information is the target property.

We will now do the actual transfer by simply initiating a new chat session with the bot-id (e.g., 0Xx5e000000TglaCAC, which is the VariablesReceiver Bot) that was provided in the last response from the Variables Bot.

The chat initiation command would be the same as before, only the bot-id would be different. Also, since we now want to share data from the Variables Bot with the VariablesReceiver Bot, we will also include the variables array in the request. You can read more about the variables array in the Einstein Bots Platform API client guide.

The command would be something like the following:

But this time, the contents of body.json would be as follows:

And the response from the VariablesReceiver Bot should be something like the following:

From the above response, we can see that the VariablesReceiver Bot has successfully received the three variables we passed to it in the chat initiation request.


In this post, we discussed how Einstein Bot transfers work at a high level. We then took a deep dive into a specific bot-to-bot transfer use case, exploring how that works with an example and showing how to share data between two completely independent bots. As of the 242 release, the data sharing between bots is possible only with the new Einstein Bots Platform API. Also, with the API, you can share data amongst bots deployed in two completely independent Salesforce orgs.


About the author

Makarand Bhonsle is a Principal Engineer at Salesforce. He is the lead developer for the Einstein Bots Platform API.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS