Salesforce.com’s LiveAgent Chat

After being a long time customer of LivePerson, we have switched to Salesforce.com Live Agent as we now have this included in our edition. After reading through the I felt confident we could set this all up quickly. Implementing Live Agent and being able to chat, was super easy…almost too easy.
What took a bit of time was working through creating the pre-chat form and setting up the process to create a lead if a contact record was not found.
After attempting to figure this out myself and not successfully getting the lead record to create, I went to a developer’s best friend, Google.
Between these three blogs: Live Agent Pre-Chat API , Salesforce Live Agent Review & Customization & Extending the Salesforce LiveAgent pre-chat form through javascript and VF Remoting;the developer guide, and some additional searches on javascript, I’ve created a beautiful pre-chat survey, it searches for contacts, and if not found creates a lead record and displays the new record to the agent.

The visualforce page: (replace the XXXXXXXXXXX in the apex:variable with your record id’s)

Need to launch the window in a certain size? Set that option in your deployment code by adding:
liveagent.setChatWindowHeight(xxx);
liveagent.setChatWindowWidth(xxx);
So you’d end up with something like:

Very nice work Stephen, this was well written! I was wondering if you could lend a quick hand, I am the Salesforce Admin for my company and have less experience on the development end. I rolled our live agent to our company a few months back, however I fumbled through it and the logic is not solid like yours. I am working to add the conditional functionality so that I can search contacts/leads by email and if not exist create the lead. This is my first attempt at using an Apex Class in Sandbox and trying to push into live. I have never done a Test Class and was wondering if you could lend a hand and provide a sample Test Class for the above so that my code can pass the inbound changeset 75% code requirement. I am getting stuck here and was hoping to get the function to work.

Sorry for the delay in reply Patrick. Been working hard on projects that went live last week. Anyhow, I’m happy to help out. So if you used the article’s visual force and apex class, then you will not need a test class. as classes are used when triggered by something else such as a trigger, another class, or visualforce pages. Did you set up the controller class as a trigger perhaps? Feel free to email me with details. stephenfdavis3@gmail.com