You need to sign in to do that
Don't have an account?
How can I get a Live Agent Pre-Chat to Auto-Submit?
We have a Live Agent chat button in our Customer Portal because only customers paying for our support can use Live Agent chat. We can get the customer portal user's Name, Email & Account and pre-populate a Pre-chat window but this hits the user with an unnecessary screen pop where they click a button to chat again. How can I set up the pre-chat window to just auto-submit? I have tried to programmatically click the submit button using javascript in window and body onloads and it does not work. I thought that I could maybe do this all in apex if I could use httprequest setmethod(‘POST’) but I couldn’t figure out how to do this or if it is even possible.
Does anyone know of a way that I can do this?
Pre-chat vf code:
<apex:page showHeader="false" standardController="User" extensions="NICP_Functions"> <script> function clickBtn() { var btnSubmit = document.getElementById('prechat_submit'); btnSubmit.click(); } </script> <!-- This script takes the endpoint URL parameter passed from the deployment page and makes it the action for the form --> <script type="text/javascript"> (function() { function handlePageLoad() { var endpointMatcher = new RegExp("[\\?\\&]endpoint=([^&#]*)"); document.getElementById('prechatForm').setAttribute('action', decodeURIComponent(endpointMatcher.exec(document.location.search)[1])); } if (window.addEventListener) { window.addEventListener('load', handlePageLoad, false); } else { window.attachEvent('onload', handlePageLoad, false); } })(); </script> <h1>Pre-chat Form</h1> <form method='post' id='prechatForm'> <style type="text/css"> body { margin: 0 auto; padding: 0; font-family: 'Trebuchet MS', Helvetica, sans-serif; font-size: 12px; color: #737373; line-height: 16px; } p { font-weight: bolder } td { font-family: 'Trebuchet MS', Helvetica, sans-serif; } h1 { font-family: 'Trebuchet MS', Helvetica, sans-serif; } .btnClass { font-family: 'Trebuchet MS', Helvetica, sans-serif; } </style> <!-- Creates an auto-query for a matching Contact record’s Email field based on the value of the liveagent.prechat:Email field --> <table border="0" width="400px"> <tr> <td> <b>Name: </b> </td> <td> <input type='text' size="40" name='liveagent.prechat:Name' id='prechat_field' value='{!$User.FirstName} {!$User.LastName}' /> </td> </tr> <tr> <td> <b>Email Address: </b> </td> <td> <input type='text' size="40" name='liveagent.prechat:Email' width="500" value='{!$User.Email}' /> </td> </tr> <tr> <td> <b>Property Name: </b> </td> <td> <input type='text' size="40" name='liveagent.prechat:Account' value='{!getAccountName}' /> </td> </tr> <tr> <td> </td> <td align="center"> <input type='submit' value='Request Chat' id='prechat_submit' class="btnClass" /> </td> </tr> </table> <input type="hidden" name="liveagent.prechat.query:Email" value="Contact,Contact.Email" /> </form> </apex:page>
Pre-chat extension code
public with sharing class NICP_Functions { public String getAccountName{get; set;} public User u; public NICP_Functions(ApexPages.StandardController controller) { try { User u = [SELECT Id, AccountId FROM User WHERE Id =: UserInfo.getUserId()]; Account a = [SELECT Id, Name FROM Account WHERE Id =: u.AccountId]; getAccountName = a.Name; } catch (Exception e){getAccountName = 'Please Specify';} }
I figured out how to get the pre-chat form to auto-submit. I added the following body tag and javascript right after the page tag.
All Answers
I figured out how to get the pre-chat form to auto-submit. I added the following body tag and javascript right after the page tag.
Hi Expert ,
I am also trying to prepopulate the email id and and name of portal user but not working ........
It seems, however, that the (!$User} is returning the guest user of the Force.com Site. Specifically, {!$User.FirstName} and {!$User.ContactId} is being used. The code below shows their usage in context. The first merge field ends up displaying the Force.com Site name rather than the logged in portal user.
Is there a way to get the portal's logged in user information into the pre-chat form? HOw this works for you.
I would much appreciate your suggestions and Help..
Thanks
Hi MrBungle , need your urgent help. Please look into this
Appreciate that...
One important note is that we have the button on a page in our customer portal. This means that users are logged into Salesforce that initiate chats. If you are just getting the guest user info in your pre-chat form perhaps it is because you are accessing it anonymously.
Hope this helps.
It will be helpful. Yes , I am using the button code on the Customer portal page from where clients can initiate the chate. Everything yous said as designed however the only the button part which I am not sure what needs to be modified. If you can recall the updates from Salesforce , which you changed in the button code, would be helpful for me. Please share the button code if possible OR the updates required for this.
I will appreciate that.
And thanks so much for paying attention to this.
.
@MrBungle,
Please reply this. Its a pain for us and your help will be highly appreciated in this situation.
Thanks alot ......