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
Sonal ShrivastavaSonal Shrivastava 

Live Agent liveagent.prechat.buttons not working in pre-chat page

I am creating a pre-chat page for live agent, I have copied the same code from Pre-Chat Form Code Sample mentioned in live agent developer guide, just replaced the button Ids.
I placed one chat button (ID : 573g00000008Ofd) on a VF page for testing with this pre-chat page. On clicking that, the pre-chat form opens. But when the form is submitted it always redirect to this button's custom chat page, regardless of which button I select from the drop down.

<select name="liveagent.prechat.buttons">
<option value="573g00000008Ofd">Chat Button 1 </option>
<option value="573g00000008OfY">Chat Button 2 </option>

Please let me know if I am missing something or some other code needs to be incorporated to get redirected to respective custom chat pages of the buttons.
hi, can you paste/share the whole html source code? maybe you are also missing the deployment.js thanks.
Sonal ShrivastavaSonal Shrivastava
Here is my code for deployment page and prechat page.

Deployment Page:

<apex:page showHeader="false">
    <!-- Code Copied from Button Configuration -->
    <img id="liveagent_button_online_573g00000008OfY" 
        style="display: none; border: 0px none; cursor: pointer" 
        src="" />
    <img id="liveagent_button_offline_573g00000008OfY" 
        style="display: none; border: 0px none; " 
        src="" />

    <script type="text/javascript">
        if (!window._laq) { window._laq = []; }
            liveagent.showWhenOnline('573g00000008OfY', document.getElementById('liveagent_button_online_573g00000008OfY'));
            liveagent.showWhenOffline('573g00000008OfY', document.getElementById('liveagent_button_offline_573g00000008OfY'));

    <!-- Code Copied from Deployment -->
    <script type='text/javascript' 
    <script type='text/javascript'>
        liveagent.init('', '572g00000008OWR', '00Dg0000006U9Yi');

Pre-Chat Page:

<apex:page showHeader="false" docType="html-5.0">
    <script type="text/javascript">
        (function() {
            function handlePageLoad() {
                var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)");
            if (window.addEventListener) {
                window.addEventListener('load', handlePageLoad, false);
            } else {
                window.attachEvent('onload', handlePageLoad, false);

    <form id='prechatForm' method='post' >
        <apex:pageBlock title="Enter your details">
            <apex:pageblockSection columns="1"  >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="First Name" />
                    <input type='text' name='liveagent.prechat:FirstNameDetail' />
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Last Name" />
                    <input type='text' name='liveagent.prechat:LastNameDetail' />
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Email Address" />
                    <input type='text' name='liveagent.prechat:EmailDetail' />
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Department" />
                    <select name="liveagent.prechat.buttons">                        
                        <option value="573g00000008OfY">Chat Button 1 </option>
                        <option value="573g00000008Ofd">Chat Button 2 </option>
        <input type="hidden" name="liveagent.prechat:RecordTypeIdDetail" value="012600000005NJJAA2"/>
        <input type="hidden" name="" value="FirstName,FirstNameDetail;LastName,LastNameDetail;Email,EmailDetail;RecordTypeId,RecordTypeIdDetail" />
        <input type="hidden" name="" value="Email,true" />
        <input type="hidden" name="" value="Email,true" />
        <input type="hidden" name=""
               value="FirstName,true;LastName,true;Email,true;RecordTypeId,true" />
        <input type="hidden" name="liveagent.prechat.findOrCreate.showOnCreate:Contact" value="true" />
        <input type="hidden" name="liveagent.prechat.findOrCreate.saveToTranscript:Contact" value="ContactId" />
        <input type='submit' value='Request Chat' id='prechat_submit'/>


did you try to create/open this as an independent html?
as i understand it you are trying to do this?

Sonal ShrivastavaSonal Shrivastava
I have tested with deployment HTML page, it is working in the same way. However, I did not try with prechat HTML page, since we are using site. So I have given Pre-Chat Form Page as this prechat VF page. 
As I understand, I will have to give the prechat URL in chat button if I create an independent HTML page for pre chat form. But I am not getting where will I host this prechat HTML page so that I can give its url in the chat button setting.

And yes, my requirement is to route the chat to appropriate agent after collecting the information from prechat form. Can you suggest on the same.

john harvey 2john harvey 2
Hi Sonal,

Di you find solution on how or where to host pre chat form to transfer the info to the agent? I am having hard time figuring out that.