You can work off of the following code. This will send a message to the contact and will reply each time they send a message.
Javascript code:
var objChatWnds = {};
var objMessages = { 0 : 'First Message',
1 : 'Send Message',
2 : 'Third Message'
};
function OnEvent_ChatWndSendMessage ( oChatWnd , sMessage ) {
if ( typeof objChatWnds [ oChatWnd.Handle ] === 'undefined' ) {
// initialize the counter
objChatWnds [ oChatWnd.Handle ] = {};
objChatWnds [ oChatWnd.Handle ].Counter = 0;
objChatWnds [ oChatWnd.Handle ].Message = sMessage;
}
}
function OnEvent_ChatWndReceiveMessage ( oChatWnd , sOrigin , sMessage , nMessageKind ) {
OnEvent_ChatWndSendMessage ( oChatWnd , '' );
if ( objChatWnds [ oChatWnd.Handle ] !== 3 && Messenger.MyStatus === STATUS_BUSY && objChatWnds [ oChatWnd.Handle ].Message !== sMessage ) {
oChatWnd.SendMessage ( objMessages [ objChatWnds [ oChatWnd.Handle ] ] );
++objChatWnds [ oChatWnd.Handle ];
}
}
function OnEvent_ChatWndDestroyed ( oChatWnd ) {
if ( typeof objChatWnds [ oChatWnd.Handle ] === 'object' ) {
delete objChatWnds [ oChatWnd.Handle ];
}
}