powered by Jive Software

Question Metadata in Chat room and Timestamps

Hello all,

Two features that I’m looking to deploy sooner than later to webchat.

  1. Timestamps on responses, in the webchat display customer facing (helps customers keep track of when the agent responded)

  2. Also Embeddeding the question metadata in the initial welcome to chat message.

Was hoping for any ideas on accomplishing these two features. I know that the proper way to do this is going to be to extend the fastpath plugin server side, however time crunch means hacking the JSP for now.

Does anyone know if the timestamp issue has been added or commited? I will need this very soon.

A quick hack to get the time in there is to add it to the “from” argument.

Add this to chatmain.jsp inside the insertMessages function (around line 500):

var currentTime = new Date();

var hours = currentTime.getHours();

var minutes = currentTime.getMinutes();

var timeString;

if (minutes < 10){

minutes = “0” + minutes;

}

timeString = ("("+hours + “:” + minutes + " ");

if(hours > 11){

timeString = timeString + “PM)”;

} else {

timeString = timeString + “AM)”;

}

Then search for a similar line to this in that function and change it to look like:

addChatText(window.frames[‘yak’], messages[i].from + " " + timeString, messages[i].body);

The result will look something like the attached image.

Oh, and for the OP, the metadata are saved as session variables in JSP, so just search other pages like start.jsp and queue.jsp for the code “session.setAttribute” to see all the different data you have to work with. Then search chatmain.jsp for “getChatRoomWelcomeMessage” and add this on the line after it:

var Question = “<%=session.getAttribute(“Question”)%>”;

<% if(session.getAttribute(“Question”) != null) { %> addChatText(window.frames[‘yak’], ‘’, 'You asked: ’ + Question); <% } %>

Jeff

I followed your instruction for timestamp and question issue. That works fine and I remove AM/PM since the time display is 24 hours format. I also put that timestamp code in the SubmitMessage function to include the timestamp when client submits message like below.

addChatText(window.frames[‘yak’],’<%= StringUtils.escapeHTMLTags(userNickname)%>’ + " " + timeString, val);

However, with that, the font color of both messages are the same in blue, they should be different colors. Do you have idea why?

I found the solution. common.js must be modified as well else it uses the wrong text style. On the line ~310, change line as below.

from :

fromIsCurrentUser = (nickname == from);

to :

var fromString = new Array();

fromString = from.split(" ");

fromIsCurrentUser = (nickname == fromString[0]);

I tested and it’s ok. I hope the I’m right.