BOTs (or robots) are used generally to answer prompt questions with some artificial intelligence, like directory assistance service - you ask the name, bot returns the phone number.

Developing a bot is easy. We need to get RTC Client API first which comes with RTCPresence sample application. In RTCPresenceCore.cs at RTCPresenceCore(IRTCPresenceUI presenceUI) you will find; 

// Set the event filter
this.client.EventFilter = RTCConst.RTCEF_REGISTRATION_STATE_CHANGE |
...

We need to add | RTCConst.RTCEF_MESSAGING to the above filter and also

this.client.IRTCClient2_ListenForIncomingSessions = RTC_LISTEN_MODE.RTCLM_BOTH;

before before the event handler registration, to let the application receive incoming IM messages. And OnRTCEvent is as follows;

void OnRTCEvent(RTC_EVENT rtcEventType, object rtcEvent)
{
   Trace.WriteLine(
"Entering RTCPresenceCore.OnRTCEvent " + rtcEventType);
   switch (rtcEventType)
   {
      case RTC_EVENT.RTCE_REGISTRATION_STATE_CHANGE:
         this.OnRTCRegistrationStateChangeEvent((IRTCRegistrationStateChangeEvent) rtcEvent);
         break;
      case RTC_EVENT.RTCE_CLIENT:
         this.OnRTCClientEvent((IRTCClientEvent)rtcEvent);
         break;

      case RTC_EVENT.RTCE_BUDDY:
         this.OnRTCBuddyEvent((IRTCBuddyEvent2)rtcEvent);
         break;

      case RTC_EVENT.RTCE_ROAMING:
         break;

      case RTC_EVENT.RTCE_PROFILE:
         this.OnRTCProfileEvent((IRTCProfileEvent2)rtcEvent);
         break;
      case RTC_EVENT.RTCE_PRESENCE_PROPERTY:
         break;

      case RTC_EVENT.RTCE_PRESENCE_DATA:
         break;

      default:
         break;
   }
}

We need to add the following to switch statement that will enable the application to answer to incoming IM messages.

case RTC_EVENT.RTCE_MESSAGING:
   this.OnRtcMessagingEvent((IRTCMessagingEvent)rtcEvent);
   break;

And answering them;

void OnRtcMessagingEvent(IRTCMessagingEvent rtcEvent)
{
   
string responseMessage;

   
try 
   {
      
if (rtcEvent.EventType == RTC_MESSAGING_EVENT_TYPE.RTCMSET_MESSAGE){
         
responseMessage = ProcessRTCMessage(rtcEvent.Message);
         rtcEvent.Session.SendMessage(
"text/plain", responseMessage, 0);
      } 
   }
   catch (Exception e) {
      
Trace.WriteLine("Exception: "+ e.Message);
   }
}

At ProcessRTCMessage the application reads, interperets and implements the message. For example it can return the first 5 search responses returned from MSN Search (using MSN Search API), or do a desktop search on file server (MSN Desktop Search API), or do a SQL search to return latest revenue details, etc. (up to your imagination).