By Urminder Singh


Salesforce Live Agent allows you to connect with customers in real time through a web-based, text-only live chat. To initiate text-only live chat, a pre-chat form is a useful feature.

A pre-chat form is used to gather basic information from customers, like name, email, phone number, and reason for contacting the agent — all of which will help in redirecting the customer to the right agent in minimal time. To gather more information, if required, you can customize the pre-chat form using a VisualForce page.

You can create custom fields in the Standard Live Agent object, which can then be mapped using the pre-chat form and will be visible to the agent on the hover pop-up during the incoming chat. The format to map custom fields is: name=”liveagent.pre chat:.

If you don’t want to show any custom detail on the page, you can hide it using this statement:

<input type=”hidden” name=”” value=”Custom_Field__c”/>

Once you have completed the setup, you will need to map those details to Salesforce. You can create only single mapping for each object. In each mapping, you need to specify the Salesforce object’s field name and custom detail name, and you can separate each pair with a semicolon.

This is how you can show a textbox for input email:

<input type=”text” name=”liveagent.prechat:contactFirstName” />

<input type=”text” name=”liveagent.prechat:contactLastName” />

<input type=”text” name=”liveagent.prechat:contactEmail” />

<input type=”hidden” name=”liveagent.prechat:SessionId” id=”prechat_field_session_id” value=”” />

This is how you can map this detail to Salesforce:

<input type=”hidden” name=”” value=”FirstName,contactFirstName;LastName,contactLastName;Email,contactEmail;Session_Id__c,SessionId” />

The next step is to determine whether you want to perform a search on the existing records in Salesforce. You can do this by using doFind. You can also specify if you want an exact match or a partial match for the search string.

This will search on Contact records using input Email for exact match on Contact records.

<input type=”hidden” name=”” value=”Email,true;” />

<input type=”hidden” name=”” value=”Email,true;” />

To use another object, you need to specify one more mapping similarly.

If a matched record is found, Salesforce will open its detail page in a new subtab. If more than one record matches, it will display a list of those matched records. If you want to create a new field (in case there is no match found) then you need to use doCreate input.

<input type=”hidden” name=”” value=”FirstName,true;LastName,true;Email,true;Session_Id__c,true” />

The fields specified in the value attribute will be mapped from the pre-chat form to a new Contact record. If you don’t specify doFind, it will always create a new Contact record. So if you want to search, use doFind, and if you want to create a new record, use doCreate. If you want to search and create, use both.

If you want to show a newly created/searched record you can also control that using showOnCreate.

<input type=”hidden” name=”liveagent.prechat.findorcreate.showOnCreate:Contact” value=”true” />

The Live Chat Transcript Object is related to the Contact field via a standard lookup field, so if you want to relate the live chat transcript to the Contact field, you can use saveToTranscript to populate that lookup field on the chat transcript.

<input type=”hidden” name=”liveagent.prechat.findorcreate.saveToTranscript:Contact” value=”Contact” />

Here is a sample of a fully customized pre-chat form:

Join the Conversation

Your email address will not be published. Required fields are marked *

  1. Any info on making Live Agent web NOT a POPUP separate window but stay as a nice slider UI or may be some hover message for the web site?

    1. Hi Igor,

      I am currently also looking for some tweak/hack to do so. It generates an internal session Id which is used to connect with salesforce. As soon I will find some way to do the same in slider UI I will get back to you.


  2. Hello Urminder,
    Thank you for this wonderful blog post. I just want to understand, how to setup the pre chat form(html version) from outside so that the details are sent to salesforce when person clicks on Start Chat(like deployment api). I am able to setup form for Deployment apis but not for pre chat apis. It would be helpful if you can share the details of your implementation

    1. Hi Jayesh,

      Apologies for the late response. Setting up a pre-chat form is quite an easy step. You just need to create an HTML page where you need to add scripts from Live Agent Deployment (Goto-setup–>Live Agent–> Deployment–> Click on deployment you created). You will see a script at the bottom of the page. SThe same steps you need to do for Chat Button.

      In the chat Button, you will see an anchor tag for online image/text having id something like “liveagent_button_online_57328000000Cgle” and for offline text image a div has id something like “liveagent_button_offline_57328000000Cgle”.

      Now next thing you might need is to send details of the user, for this you can bind the input fields as mention in the blog or you can also use javascript to send some specific details that agent will see as he hover-over the incoming chat.
      This is the sample js code that you can use to send custom details:

      liveagent.addCustomDetail(‘Email Address’,’’);
      liveagent.addCustomDetail(‘Home Address’,’123 St, Sample Address, Sample State, Pincode’);

      Sample Code you can also view here:

      Please feel free to ask if you still need more info. I will be happy to help and this time with quick reply 😉


Subscribe to our blogs

Subscribe to our blogs