The problem is he wants it to reply to the first message they send ONLY if the window wasn't open before.
js code:
// Create an object container to store the chat window object
var oChatWnds = {};
// Store the chat window object in our object container when it is opened
function OnEvent_ChatWndCreated(oChatWnd) {
oChatWnds[oChatWnd.Handle] = {};
}
// Remove the variable from the object if the window is closed
function OnEvent_ChatWndDestroyed(oChatWnd) {
delete oChatWnds[oChatWnd.Handle];
}
// If we send a message remove the chat window from the object container
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
delete oChatWnds[oChatWnd.Handle];
}
// If we receive a message and the chat window exists in the object container
function OnEvent_ChatWndReceiveMessage(oChatWnd, sOrigin, sMessage, nMessageKind) {
if (typeof oChatWnds[oChatWnd.Handle] === 'object') {
// Send the message
oChatWnd.SendMessage('hai');
// Remove the chat window from the object container
delete oChatWnds[oChatWnd.Handle];
}
}
Untested code but give it a shot.