I'm Keyvan Nayyeri, a 25 years old Ph.D. student at
the Computer Science department of
the University of Texas at San Antonio.
I'm also
a Software Architect and Developer and previously held a B.Sc.
degree in Applied Mathematics.
This is my blog where I publish content about various topics specifically Programming Languages and Compilers, Software
Engineering and Programming.
I haven't used Trillian for more than two weeks. One of features that I like in Trillian but isn't available in other instant messengers such as Windows Live Messenger or Yahoo Messenger is Auto-Responder. I'm usually in front of my PC or laptop but there are sometimes that I'm away or am working on a machine which doesn't have Live Messenger installed. So this add-in could be useful for my Live Messenger. I searched for this add-in but couldn't find any result.
Today I found time to try to write an add-in for my Live Messenger for this purpose. Fortunately there was a post here which helped me to have a good initial point. Windows Live products have excellent support for .NET to let developers write add-ins for them. Can you remember my post about writing a plugin for Windows Live Writer?
Ok, the process was very simple. If you're interested to know how did I write this add-in, just follow this post.
First step is to enable add-ins for Windows Live Messenger because they're not enabled by default. To do this, save following code in a text file and run it to register Live Messenger Add-ins in registry:
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger]
"AddInFeatureEnabled"=dword:00000001
Now you'll have a new tab in your Live Messenger options to add, remove and configure Add-ins:

Writing a Windows Live Messenger add-in is very simple. You can write your add-ins using Visual Basic or C#.
First you need to set up a Class Library project and add a reference to MessengerClient.DLL assembly which is located at your Live Messenger folder (it's still in MSN Messenger folder).
Important point is to have same name for your assembly and class. It means you need to set your assembly name to your class full qualified name. You can set your assembly name via your project properties. As I chose AutoResponder both for my project and class names, must choose AutoResponder.AutoResponder for my assembly name. Next step is to add a reference to Microsoft.Messenger namespace in my class.
Now you can start your development for your add-in. It's as simple as implementing IMessengerAddin interface. This interface has one method to implement: Initialize(). This method will be called every time your add-in is loaded by Live Messenger. It has a MessengerClient object as its parameter which is the main object that you will use to develop your add-in.
I define a client and history private members to keep an instance of my MessengerClient and history of auto-responds to each user. I keep this history because I want to put an interval between every two auto-responds that will be send to each user (5 minutes for my add-in). history is a Dictionary<String, DateTime> which keeps the list of all user unique identifiers that have gotten an auto-respond message so far plus the last date and time they got a message.
In Initialize() method, I set my client private member to the passed MessengerClient object. MessengerClient.AddinProperties contains some properties about the add-in and I set them to appropriate values in initialization as well.
There are five event handlers for MessengerClient object that will be called when on appropriate events and you can use them to write an add-in for several purposes:
I use IncomingTextMessage event handler and add a handler for it to check user's status and send appropriate auto-respond messages to sender. Messages will be send if the time difference between the last auto-respond text that is sent to a user and current time is more than five minutes.
Here is full code for my add-in (auto-respond texts are cut for representation on blog):
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Messenger;
namespace AutoResponder
{
public class AutoResponder : IMessengerAddIn
{
#region Private members
MessengerClient client;
Dictionary<String, DateTime> history;
#endregion
#region IMessengerAddIn Members
public void Initialize(MessengerClient messenger)
{
this.client = messenger;
this.history = new Dictionary<String, DateTime>();
this.client.AddInProperties.FriendlyName =
"Auto-Responder";
this.client.AddInProperties.Creator =
"Keyvan Nayyeri";
this.client.AddInProperties.Description =
"Sends auto-respond texts to senders based on user status";
this.client.AddInProperties.Url =
new Uri("http://nayyeri.net");
this.client.IncomingTextMessage +=
new EventHandler<IncomingTextMessageEventArgs>
(client_IncomingTextMessage);
}
#endregion
#region Private methods
void client_IncomingTextMessage(object sender, IncomingTextMessageEventArgs e)
{
if (ShouldSend(e.UserFrom.UniqueId))
{
String outgoingText = String.Empty;
switch (this.client.LocalUser.Status)
{
case UserStatus.Away:
outgoingText +=
"I'm currently away from computer and ...";
break;
case UserStatus.BeRightBack:
outgoingText +=
"I'll be back very soon ...";
break;
case UserStatus.Busy:
outgoingText +=
"I'm currently busy ...";
break;
case UserStatus.OnThePhone:
outgoingText +=
"I'm on the phone ...";
break;
case UserStatus.OutToLunch:
outgoingText +=
"I'm out to lunch ...";
break;
}
if (!String.IsNullOrEmpty(outgoingText))
{
outgoingText = String.Format("Dear {0}, "
+ outgoingText, e.UserFrom.FriendlyName);
if (this.history.ContainsKey(e.UserFrom.UniqueId))
this.history[e.UserFrom.UniqueId] = DateTime.Now;
else
this.history.Add(e.UserFrom.UniqueId, DateTime.Now);
this.client.SendTextMessage(outgoingText, e.UserFrom);
}
}
}
private bool ShouldSend(String UserID)
{
if (this.history.ContainsKey(UserID))
if (DateTime.Now.Subtract(new TimeSpan(0, 5, 0))
< this.history[UserID])
return false;
return true;
}
#endregion
}
}
After compiling your Class Library, you'll have a DLL file. In order to enable this in your Live Messenger, you have to open Add-ins tab in Options dialog and click on Add to Messenger ... Button. Now choose your DLL file and add it to your add-ins:

After this, you can manually enable your add-in:

Now it's time to test an enjoy (thank to Rick for helping me to test my add-in and taking these snaps):


You can download the first version of my Auto-Responder Add-in from my file gallery. Like my Technorati Tags plugin for Windows Live Writer, this add-in is for my personal use but I shared its source code to let others extend it and learn the process of development. It can be better with some configuration options for intervals and auto-respond messages. Feel free to extend it if you have any time.
Rick Reszler
Oct 16, 2006 1:04 PM
#
vikram
Oct 16, 2006 10:48 PM
#
Scott Allen
Oct 18, 2006 11:25 AM
#
Keyvan Nayyeri
Oct 18, 2006 11:31 AM
#
Rubal Jain
Oct 19, 2006 1:43 PM
#
Rajesh
Dec 12, 2006 2:17 AM
#
gestibar
Feb 13, 2007 5:03 AM
#
Chris
May 23, 2007 9:34 PM
#
sakshi
Jul 02, 2007 9:19 AM
#
ahmed
Jul 07, 2007 7:51 PM
#
moulay
Jul 17, 2007 3:03 PM
#
Xavier
Sep 23, 2007 6:37 PM
#
jAMIE
Oct 24, 2007 1:40 PM
#
raz
Oct 30, 2007 5:49 AM
#
Mr Dee
Nov 17, 2007 11:09 AM
#
Patrick
Nov 24, 2007 7:16 AM
#
hotty_cutie_hockeychic@ezlink.ca
Dec 03, 2007 2:39 PM
#
Krazee
Jun 15, 2008 11:51 AM
#
Everytime I try to install it, I get an unexpected error, then I have to send en error report and it closes, leaving the installation incomplete. Any suggestions ?
Eric Javier
Sep 26, 2008 8:31 PM
#
Very nice piece of code and a very usful utility.
I suggest (if possible) give the command line procedure for compiling the source for those of us that don't have Visual Studio o can't download the Visual Studio Express Edition.
:)
Eric Javier
Sep 26, 2008 8:38 PM
#
Hi, it works fine when receiving messages form MSN's users but it doesn't work when the messages come from a Yahoo!'s user. Any suggestion on how to solve this?
Eric.
J.Batchelor
Nov 24, 2008 5:58 PM
#
Hi, To do this all I have found out is that you must go to start>then Run in the box type in "regedit" then on the list follow the link of this with the files [HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger]" then >as you reach the file there are key files as reg files, on this right click and click on new> string value or key I don't know but i got this far.
bob
Dec 03, 2008 9:16 PM
#
what u mean send code in text message to msn for auto response?
Vneit
Dec 28, 2008 8:39 AM
#
Easy,create a new text document,paste the following code:
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger]
"AddInFeatureEnabled"=dword:00000001
-then click save as<dont press ok yet>
-del the " .txt " replace with " .reg "
-press "ok " then double click the reg file you created.
-----------------------------------------------------
I just reach this so far,problems come when I went Logging in messenger,and choosed "Add-ins" in my WLM options,it says that I need a net framewrok 2.0 =.="
igor
Dec 30, 2008 1:34 PM
#
Send it pls
fyk
Mar 16, 2009 11:19 AM
#
really nice post.
Ariel Ferro
Apr 05, 2009 11:41 PM
#
I´m trying to add a few lines of text which are gatered from the internet, and I´m stuck with this error: "Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed." --- how can I get rid of this, if such thing is possible???
st
Apr 17, 2009 4:41 PM
#
I seem to have done everything correctly - create a new DWord and set its value to 1 and resarted messenger but the add-ins tab still doesn't show :/ Using version 14 of the live messenger... could something have changed since this blog was created?
jay
May 07, 2009 2:48 PM
#
how do u download it ?
John Smith
May 07, 2009 8:38 PM
#
Hi, I have been trying to add the addin option but it doesnt work. I use Vista and WLM 14.8064.206 and no option is added. Does anyone have any patch to add it automatically, as well as the auto-responder? I would appreciate receiving these files. thanks.
Claton
May 09, 2009 2:48 PM
#
the registry key does not work on 2009 ver of MSN... any other hacks.. ????????????????
Colin v. Loef
Oct 09, 2009 3:48 PM
#
Can you maybe build a Auto Responder like:
When somebody says HELP to you
that you atomaticly respond with: HI,
say 1 to ask Me something
say 2 to ....
etc.
can you make something like this?
and when he says like 1, you automaticly respond with: Please wait...
Greets Colin
Bengin
Oct 31, 2009 11:43 PM
#
Bla bla ._.
Nov 22, 2009 7:41 AM
#
Diuti
Nov 23, 2009 11:22 PM
#
Help
Jan 06, 2010 10:43 AM
#
WHEN EDITING THE REGISTRY THE ADD-IN TAB IS NOT THERE!
PLEASE HELP ME!
I have the latest version of the messenger
NEED MORE HELP
Jan 23, 2010 10:59 PM
#
WOT DO U SAVE THE .REG FILE AS
HOW DO U ADD IT
NEED MORE HELP
Jan 23, 2010 11:01 PM
#
glasgow-2k9@live.co.uk
Leave a Comment