[SalesForce] How to Create a Case and contact automatically from Prechat form using LiveAgent through API

I've a requirement is,When the Visitor fills in the prechat form with some basic stuff like First Name, Last Name, Email, Case Number,then "I'm trying to find that Case if not found create a new Case or display the existing Case and Search Contact,if not found create new Contact or display the existing Contact.

I followed one link http://peterknolle.com/live-agent-pre-chat-api/ ,but here explained about Create a Case every time,but I do search for existing case or create new one if not exist then link to contact.

Please help me in this regards

Best Answer

Use the doFind method, see the usage in the Live Agent Developer Guide

http://www.salesforce.com/us/developer/docs/live_agent_dev/index.htm