---
schema_version: "1"
id: 820ab9f9c1de0940e2f662cc0510399c4f464936ee480b38ef4f10c0906b036c
title: Use Pre-Chat with an Enhanced Bot
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/service/264-0-0/bots_service_enhanced_prechat.md
canonical_url: https://help.salesforce.com/s/articleView?id=service.bots_service_enhanced_prechat.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: c7108afd236ff6b68160dd2f1da2ebdb18712848dfbedcefa0a40c1ffc7836cd
description: Use an enhanced bot to gather important customer information and customize a conversation with a bot or service rep on Enhanced In-App Chat or Enhanced Web Chat channels. After you set up pre-chat for Enhanced Chat, create and map custom bot context variables to the Messaging Session object.
products:
  - Service Cloud
  - Service Intelligence
release: "264"
---
# Use Pre-Chat with an Enhanced Bot

Use an enhanced bot to gather important customer information and customize a conversation with a bot or service rep on Enhanced In-App Chat or Enhanced Web Chat channels. After you set up pre-chat for Enhanced Chat, create and map custom bot context variables to the Messaging Session object.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=service.einstein_service_intro.htm&amp;language=en_US" target="_blank">View supported editions</a> for Einstein Bots.</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=service.messaging_editions.htm&amp;language=en_US" target="_blank">View supported editions</a> for Messaging.</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
          <colgroup>
            <col style="width:50%">
            <col style="width:50%">
          </colgroup>
          <thead class="slds-text-title_caps ">
            <tr class="">
              <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d39195e68">User Permissions Needed</th>
            </tr>
          </thead>
          <tbody>
            <tr class="">
              <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d39195e68 ">To build and manage Einstein Bots:</td>

              <td class="slds-cell-wrap" style="vertical-align:top;" headers="d39195e68 ">
                <p>Customize Application</p>
                <p>OR</p>
                <p>Modify Metadata</p>
                <p>OR</p>
                <p style="margin-bottom:0;">Manage Bots</p>
              </td>

            </tr>
          </tbody>
        </table>

Before you begin, set up pre-chat for Enhanced Chat.

1. [Create and customize your Enhanced Chat pre-chat form](https://help.salesforce.com/s/articleView?id=service.miaw_custom_prechat_3.htm&language=en_US). You can add standard and custom fields.
2. [Map your pre-chat values to your Messaging Channel, then update your Omni-Channel flow](https://help.salesforce.com/s/articleView?id=service.miaw_map_messaging_2.htm&type=5&language=en_US). Create an Update Records element before the Route Work element in the flow that you use to route to your enhanced bot.

## Create Custom Context Variables

When you set up pre-chat for Enhanced Chat channels, you created a custom field on the Messaging Session object for each of your pre-chat fields. Now to use pre-chat with your bot, for each custom field that you created on the Messaging Session object, create a custom bot context variable.

1. Navigate to the enhanced bot that you want to use to collect pre-chat data. From Setup, in the Quick Find box, enter Einstein Bots, and then select **Einstein Bots**. From the Einstein Bots Setup page, click the name of your bot to launch the Bot Builder.
2. From the Bot Builder menu, select **Variables**.
3. In the Variables list view, click **New**.
4. In the Type field, select **Context**.
5. Enter a variable label and API name. Choose a name that makes it easy to remember the corresponding Messaging Session field but isn’t identical.
6. Select a data type. The data type of your context variable must match the data type of the corresponding Messaging Session field.
7. Save your changes.

## Map Your Context Variables

Map your new custom context bot variables to the corresponding fields on the Messaging Session object. Mapping lets your bot use an Omni-Channel flow to load pre-chat data from the context variables into the fields on the Messaging Session object. Then the bot or service rep has access to the information within the Messaging Session record during a conversation.

1. To open the variable detail page, in the Variables list view, click the name of your new variable.
2. To create a variable mapping, from Context Variable Mappings, click **New**.
3. In the Connection Type field, select **Embedded Messaging**.
4. In the Field Name field, select the corresponding Messaging Session field.
5. Save your changes.

## Add Context Variables to Your Bot

To collect customer responses with your bot, add each custom context variable to a dialog Question step.

For more information, see [Using a Dialog Question Step](https://help.salesforce.com/s/articleView?id=service.bots_service_using_dialog_question.htm&release=264.0.0&type=5 "Question steps allow bots to ask the customer questions, receive data from the customer, and inform the bot about what action to take next.").

#### See Also

- [Route Conversations to an Enhanced Bot](https://help.salesforce.com/s/articleView?id=service.bots_service_enhanced_route_to.htm&release=264.0.0&type=5 "Create an Omni-Channel flow to route conversations to your bot over enhanced Messaging channels, including Enhanced Chat and enhanced third-party channels. You can add powerful business rules to a flow to send a conversation to a bot or a service rep based on your criteria.")
- [Understand Context and System Variables](https://help.salesforce.com/s/articleView?id=service.bots_service_context_system_variables.htm&release=264.0.0&type=5 "Access important information during bot conversations with context and system variables. Context variables let your bot gather customer information regardless of channel. System variables store back-end information about conversations.")