I try to create a case as soon as I accept the chat. The case record type should be picked from the guest user profile which I mentioned only one, but in console the case gets created with the default type. I have mentioned the case record type tag as well, but still it is not working.
Best Answer
Method One : PreChat API Only (Record Type by ID)
Create a hidden input field that will host the Record Type by Id, because RecordType Name is not supported in live agent:
Then in your findorcreate.map, make sure you are mapping caseRecordType to RecordTypeId in Salesforce, like this (you will likely have other items in your map too, but I removed mine for simplicity in this answer and only left RecordType:
Then, lastly, in your findorcreate.map:DoCreate, make sure you include RecordTypeId,true:
As noted by another answerer, the downside to this implementation is that you will need to change the hard coded RecordTypeId in the preChat VF page when deploying it to a production org, since the RecordTypeId will be different.
Method Two : PreChat API and Workflow Rule (Record Type by Name)
Using the PreChat API, we have the ability to set any field on the case object, similarly to the way that we are setting record type in Method One. StackExchange user PepeFloyd suggests that if you are setting any of your values to a unique value that is only used during a live agent chat, then you can also add a workflow rule that fires off of meeting that criteria that sets the record type for you.
First we set our unique value on the case object. In this example, we set the case origin to "Chat" and assume that "Chat" is never used as the origin in any other scenario. We then add it to the map, and the doCreate:
Then our Workflow Rule would look something like this:
And our Field Update:
You would of course set it to your appropriate Record Type.