You are here:
Gather Customer Information Using Pre-Chat
Add custom fields to your pre-chat form to store your chatting customer’s local and time zone information. Then you can auto-fill these hidden pre-chat fields when the conversation begins.
Required Editions
| Available in: Lightning Experience |
| Available with Sales in Performance and Unlimited Editions |
| Available with Sales Engagement, which is available in Performance and Unlimited Editions, and for an extra cost in Professional and Enterprise Editions |
| User Permissions Needed | |
|---|---|
| To customize pre-chat: | Customize Application AND Modify Metadata Through Metadata API Functions |
-
Create custom parameters for your pre-chat form.
- From Setup, in the Quick Find box, enter Messaging Settings, and then select Messaging Settings. Then click Buyer Assistant Messaging Channel.
- Create a custom parameter that stores your customer’s locale. Save your changes and then create another custom parameter that stores your customer’s time zone. Save your changes. For both parameters, be sure to match the parameter name and channel variable name.
-
Add hidden fields to your pre-chat form.
- From Setup, in the Quick Find box, enter Embedded Service Deployments, and then select Embedded Service Deployments.
- Open the Buyer Assistant embedded service deployment, and then click Edit Pre-Chat.
- Under Hidden Pre-Chat Fields, select the custom parameters you created. Then save and publish your changes.
-
Add custom fields to your messaging session object.
- From Setup, in Object Manager, select the Messaging Session object.
- From the Fields & Relationships tab, create a custom field for your customer’s locale. Then create another custom field for your customer’s time zone.
-
Map the hidden pre-chat fields to flow variables in the Buyer Assistant - Route to Bot
flow.
- From the Buyer Assistant Messaging Channel settings, create a parameter-mapping variable for your customer’s locale. Save your changes, and then create another variable for your customer’s time zone. For both variables, add a flow variable name that describes the action. Save your changes.
- From Setup, in the Quick Find box, enter Flows, and then select Flows. Find and select Buyer Assistant - Route to Bot from the list.
- Add an input variable for each pre-chat field. The API Name must be identical to the Flow Variable Name from Parameter Mappings. The Data Type must be set to Text. And the variable must be available for input.
- Create an Update Records element in the flow after the Route Work element. Name the element Update Messaging Session. Make sure that the element identifies records based on conditions and set fields individually. For the object type, select Messaging Session, filter based on the recordId value, and enter each pre-chat field and its corresponding flow variable name. Then click Done.
- Save your changes and activate the flow.
-
Create and map bot context variables to the custom object fields.
- Navigate to your Buyer Assistant bot. From the Bot Builder menu, select Variables.
- Create context variables that match the custom Messaging Session fields you created. For the data type, select Text. Save your changes.
- To map your custom context bot variables to the custom fields on the Messaging Session object, in the Variables list view, click your customer locale context variable.
- Create a context variable mapping. For the connection type, select Embedded Messaging. And for the field name, select Messaging Session.
- Save your changes and repeat the mapping steps for the time zone context variable. Then activate your bot.
Next, create a messaging channel and connect it to your website. Then embed your bot on your website and add code that collects data for your pre-chat fields.
Did this article solve your issue?
Let us know so we can improve!

