2

I'd like to be able to have a customer start a new chat from the post chat page. The challenge here is that since they've already gone through the pre chat form once, I don't want to just give them another start chat button. I'd like to jump them right into a chat, preferably using the direct to agent routing so they can try to get back to the original agent they talked to.

Is there a way to have a button that uses the same chat button but skips the pre-chat page? Maybe I should have a new button without a pre-chat page configured?

3

It isn't possible to skip the pre-chat page. The solution here is to create a second chat button that mirrors the first, but doesn't have a pre-chat page configured. You can use the deployment API to set chat details.

As a bonus, you can even use direct-to-agent routing to first attempt to get back to the original agent.

Code to get the agent Id from the previous chat:

public String agentId {
    get {
        Map<String, Object> chatMap = (Map<String, Object>) JSON.deserializeUntyped(ApexPages.currentPage().getParameters().get('chatDetails');
        if (chatMap.containsKey('agent')) {
            Map<String, Object> agentMap = (Map<String, Object>) chatMap.get('agent');
            if (agentMap.containsKey('userId')) {
                return (String)agentMap.get('userId');
            }
        }
        return null;
    }
}

You can then use this for your button:

onclick="liveagent.startChatWithWindow('<chat button id>', '_self', '{!agentId}', true);"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.