function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Arindam Chakraborty 13Arindam Chakraborty 13 

Chat Transcript


On live agent chat window I need to show the chat transcript on postchat page, after client or agent ends the chat. 
pconpcon
This is the code we use to do it.  It may be outdated, but it still works for us.
 
public with sharing class Chat_Controller {
    public static String TRANSCRIPT_KEY = 'transcript';
    public static String NICK_SEPERATOR = ':';
    public static String LINE_SEPERATOR = '\n';
    public static String LINE_TEMPLATE = '<p>__LINE__</p>';
    public static String NICK_TEMPLATE = '<b>__NICK__' + NICK_SEPERATOR + '</b>__LINE__';

    public String getFormattedTranscript() {
        String transcript = '';

        PageReference pageRef = ApexPages.currentPage();

        if (!pageRef.getParameters().containsKey(TRANSCRIPT_KEY)) {
            return transcript;
        }

        String transcriptPre = pageRef.getParameters().get(TRANSCRIPT_KEY);

        List<String> lines = transcriptPre.split(LINE_SEPERATOR, -1);

        for (String line : lines) {
            String result = '';

            List<String> splitNick = line.split(NICK_SEPERATOR, 2);

            if (splitNick.size() == 2) {
                result = NICK_TEMPLATE.replace('__NICK__', splitNick.get(0)).replace('__LINE__', splitNick.get(1));
            } else {
                result = line;
            }

            transcript += LINE_TEMPLATE.replace('__LINE__', result);
        }

        return transcript;
    }
}

where the page uses the Chat_Controller and has the following to output the transcript
 
<apex:outputText escape="false" value="{!formattedTranscript}" />