Chat Room Add-in

[This is preliminary documentation and is subject to change.]

A persistent chat room add-in is a Microsoft Silverlight browser application that is hosted in an HTML page. The HTML page is hosted in an extension pane that is located on the right side of the persistent chat window message area. An add-in can intercept the message text that the local user usually posts directly to the chat room message area. You can use it to create your own message display experience.

The add-in is used for the following chat room messaging related tasks:

  • Filter messages that are created by the locally joined user before the messages are sent to the chat room.

  • Apply formatting to the local user’s message text before the message is sent to the chat room. The formatting process can check the spelling and grammar, but you must write your own logic.

  • Replace the text of a pending message post with different text.

  • Format and display bot-generated messages in the add-in.

The chat room add-in is used by a brokerage firm whose traders need current information about currency exchange rates or stock prices. As this information changes quickly, an employee must be able to see and react to the changes as they occur. A persistent chat room is a good venue for this because it lets employees take action on changes by messaging other people in the chat room when a currency trade is optimal. To make this work, the brokerage programmer creates a bot that monitors changes to stock prices or currency exchange rates from an outside source.

The bot is joined to the chat room and messages the room when a value changes. To reduce bandwidth use, the bot is programmed to send messages that are composed of coded headers and data and packaged as a story. These coded bot messages are not ordinarily human-readable and would make little sense to the chat room users. To convert these coded messages into readable text, the programmer creates a persistent chat room add-in and associates it with a chat room. When a user joins the chat room, the add-in is hosted in the chat room add-in pane. As the bot sends trading messages to the room, the add-in catches the messages, reformats them into human readable text, and displays the results in the add-in pane.

The add-in can also be used to act on a price or exchange rate change. In this scenario, the add-in has an input area that the trader uses to create a trading bid which is formatted into a message sent to the room for other users to see and act on. If a trader makes an entry error and tries to send a trade message whose parameters are out of a pre-defined range, the add-in intercepts the message and cancels it before it is sent into the chat room.

Although the scope of your add-in should be limited to the messaging features previously described, you can add lightweight features that let a user interact with non-Lync applications. To stay with the securities brokerage scenario, a developer can create an add-in that accepts a broker’s trade order and transmits it directly to the trade order processing application. In this case, the trader reacts to current market information that is sent by a middle-tier bot and displayed in the add-in. The trader can generate a trade order in the add-in or post a message to the chat room by calling the Room.BeginSendMessage method in the context of the new market information.

The following table lists the classes and enumerations in the Microsoft.Lync.Model.Room namespace that make the previously described scenario possible. An add-in uses the classes in this table to catch incoming messages, intercept locally created messages before they are posted to a room, and obtains all previously posted messages.

API type

Add-in feature


Available in the Silverlight version of Microsoft.Lync.Model.dll, this method gets the hosting Microsoft.Lync.Model.Room.Room object.


Represents the chat room that hosts your add-in. Use this class to register for chat room message events, get chat room message history, and see all chat room participants.


Represents one message that was sent to a chat room. Properties of the class include the URI of the chat room, URI of the message sender, message ID, and the message text.


This is the actual message text in multiple formats including plain-text and rich text format (rtf). The RoomMessageDictionary class has many of the features of the IDictionary interface and encapsulates message text and formatting enumerators. Read the RoomMessage.MessageDictionary property to get the RoomMessageDictionary for one message.


This class encapsulates a single message composed by the local user. It is the event state of the Room.IsSendingMessage event that is raised when the local user has typed a message in the message posting area and pressed the Enter key on the keyboard. The event is raised before the message is posted to the chat room. This gives your add-in an opportunity to format or filter the message.


This enumerates the actions that an add-in can take with an outgoing message whose post to the chat room is pending. An add-in can cancel a posting, replace the message by using a formatted version of the message and then post, or post the message unchanged.


This class encapsulates the messages that were sent to a chat room. The set includes both message sent by the local user and other users joined to the chat room. Your add-in gets an instance of this class from the Room.MessagesReceived event that is raised when one or more messages are received. When a bot created in the previous scenario sends a message to the chat room, your add-in catches this event.

Community Additions

© 2014 Microsoft