We're using the service cloud console and live agent chat. We have chosen not to automatically create a new case for every inbound chat request (So Deployment API and pre-chat API are probably not in play here).
We would like to automatically populate the account and case lookups on the chat transcript based on what the agent is doing/looking at.
We already have APEX code that executes when agents view an account and when they create a new case, so we can add additional code that performs the association. The code can be straight APEX, Javascript using the console integration toolkit, or a combination of both.
Ideally, the method would allow the association to be picked up by the normal "Attach" feature of the live chat window (the paperclip).
Thanks. All ideas are appreciated.
Best Answer
When manually creating the Case in a console component instead of letting Salesforce create the Case automatically via pre-chat or deployment API then you will need to use an apex trigger on the
LiveChatTranscript
object and add a custom text field Chat Key to your Case object to correlate the records in the trigger.Custom Console Component
Here is sample javascript that listens for a new chat session to start and creates a new Case record, populating the Case record with the Chat Key.
LiveChatTranscript Trigger
The
LiveChatTranscript
record will have the ChatKey populated on it but the CaseId will be blank (in this scenario). So we look up the related Case indirectly by the chat key custom field we setup earlier.Unit Test
Simple unit test for code coverage of above trigger.