Add Office Communicator Presence and Communication to Any App

From my post yesterday on the Office Communicator Automation API, I can use the API to add presence and communication features to my apps, including:

  1. Embed Presence with Application Specific Contact Lists – use the API to build contact lists specific to my application and show Office Communicator presence for those contacts.
  2. Launch Communications – add IM, voice and video communications directly in my application to allow users to communicate and collaborate directly from the application.
  3. Application Context Specific Communication – use the API to integrate data from the application into conversations the application launches to provide application specific context for the conversation.

An Example: Office Communicator Integration into Outlook 2007

The integration of Office Communicator 2007 R2 into Outlook 2007 provides a great example of how the OC API can be used to build compelling presence and communication features into an app. 

If you look an an email in Outlook 2007 after Office Communicator 2007 R2 has been installed, you can see two interesting new features.  First, the From:, To: and Cc: lines now show the contact presence and a context menu similar to what you see in Office Communicator for everyone on the email thread. 

 

EmailWithPresAndRespondMenus

 

Second, in the email Ribbon you can see that the Respond area of the Message tab now has options for responding with both IM and voice.

 

EmailWithShowingRespondMenu

 

I can use these options to start a conversation with the sender of the mail or the entire email thread.  For example, if I select the “Call all” menu item the API will use Office Communicator to start a conference call with everyone on the thread.

 

LaunchedConCall

 

When each recipient accepts the concall invitation, they get a link back to the email that was used to start the conversation.  This is often called the context of the conversation (why Chris is calling).  For example, Adam would see the following.

 

ConcallOnAdamsComputer

When Adam, or anyone on the concall, clicks that link the email that was used to launch the call is opened so each participant can start the conversation with the same context.

 

EmailOnAdamsComputer

 

The Outlook 2007 example above provides a concrete example of the features you can build using the Office Communicator Automation API, including:

  1. Embed Presence with Application Specific Contact Lists – the contacts shown in the email on the From:, To: and Cc: lines are an example of an application specific contact list.  Note these contacts aren’t necessarily contacts in the local user’s Office Communicator contact list.
  2. Launch Communications – the presence context menus and the IM and Call menus in the ribbon allow Outlook 2007 users to start conversations directly from Outlook 2007.
  3. Application Context Specific Communication – the link to the IM conversation and the opening of the email from that link are examples of using application data as context for a conversation and building a feature for interpreting that context (such as opening the email).

The WPF Presence Controls Sample

I talk to a lot of developers who want to embed Office Communicator presence and communications into their apps.  While you can build a solution from scratch using the Office Communicator Automation API, there’s a great WPF control sample to help you build these features into your apps quickly.

The WPF Presence Controls for Office Communicator 2007 sample provides WPF controls with full source code to allow you to build these features into your apps quickly.  The sample provides a number of interesting controls, including:

  • MyPersona – used to show the presence of the local user signed in to Office Communicator.
  • Persona – used to show the presence icon and context menu for a given contact based on their SIP URI.
  • PersonaList – a list of Persona controls used to display application specific contact lists.

For example, after downloading and installing the sample, I can build a simple application to show the presence of the local user and a custom contact list.

 

SimpleWPFPresApp

 

The Persona control shows a context menu similar to what you see in Office Communicator.  Note the custom menu item titled “Inventory Request” at the bottom of the context menu.  Custom menu items allow you to extend the control with custom communication features.

 

The XAML for this Window is pretty straightforward:

 

<Window x:Class="WpfPresenceControls.Window1"

   xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"

   xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"

   xmlns:presence="clr-namespace:Microsoft.Samples.Office.UnifiedCommunications.PresenceControls;assembly=WPFMOCPresenceControls"

   Title="WPF Presence Controls" Height="187" Width="300">

    <Grid ShowGridLines="False">

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="*" />

        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>

            <RowDefinition Height="50" />

            <RowDefinition Height="100" />

        </Grid.RowDefinitions>

 

        <presence:MyPersona x:Name="myPersona" Grid.Column="0" Grid.Row="0"/>

        <presence:PersonaList x:Name="personaList1" Grid.Column="0" Grid.Row="1"

                         ShowContextMenu="True"

                         ShowDisplayName="True"

                         ShowAvailability="True"

                         ShowToolTip="True"

                         ShowDetailedToolTipText="True"/>

    </Grid>

</Window>

 

The MyPersona control uses the API to get the presence information for the local user.  The Persona and PersonaList controls need the SIP URIs for a contact to display that same presence information.  For example, the following code was used to populate the PersonaList control and create the custom context menu item:

 

using System;

using Microsoft.Samples.Office.UnifiedCommunications.PresenceBase;

 

namespace WpfPresenceControls

{

    /// <summary>

    /// Interaction logic for Window1.xaml

    /// </summary>

    public partial class Window1 : Window

    {

        public Window1()

        {

            InitializeComponent();

 

      // Create a list of contacts specific to your application.

            // Note: They don't have to be contacts in the

            // local user's contact list.

            List<string> sipUris = new List<String>()

            {

                "adamb@uc.contoso.com",

                "rl@uc.contoso.com",

                "jamesa@uc.contoso.com"

            };

 

            // Add the list of contacts to the SipUris property

            // to populate the control.

            personaList1.SipUris = sipUris;

 

            // Create a new menu item for your application specific

            // communication feature.

            List<MenuItem> customItems = new List<MenuItem>();

 

            MenuItem customMenuItem1 = new MenuItem();

            customMenuItem1.Header = "Inventory Request";

            customMenuItem1.Name = "inventoryRequest";

 

            customItems.Add(customMenuItem1);

 

            personaList1.CustomMenuItemList = customItems;

 

            personaList1.CustomMenuItemClicked +=

                new EventHandler<CustomMenuItemClickedEventArgs>

                    (personaList1_CustomMenuItemClicked);

 

        }

 

        void personaList1_CustomMenuItemClicked(object sender, CustomMenuItemClickedEventArgs e)

        {

 

        }

    }

}

 

If I clicked on the “Communicator Call” menu item in the image above, the API would use Office Communicator to place the call between Rebecca and Chris.

 

SimpleWPFAppCall

 

In the image above, the sample application and Chris’s conversation window are on the left.  On the right, you can see running Rebecca’s desktop including her conversation window from Chris. 

Embedding application data into the conversation as context and interpreting that context in your application deserves it’s own post, so I’ll come back to that subject. 

 

There are also sample controls for WinForms and Win32 shipping in the Microsoft Office Communicator 2007 Presence Controls.

Comments

  • Anonymous
    January 09, 2009
    PingBack from http://www.codedstyle.com/add-office-communicator-presence-and-communication-to-any-app/

  • Anonymous
    January 10, 2009
    Link Listing - January 10, 2009

  • Anonymous
    January 10, 2009
    Code Camps First New Hampshire Code Camp on February 28th [Via: cbowen ] Link Collections Interesting...

  • Anonymous
    January 11, 2009
    Povesteam aici despre bulina de prezență din Outlook (la Unified Communications). E vorba de asta: Vă

  • Anonymous
    January 15, 2009
    Ran across this blog, Chris Mayo&#39;s Blog - Unified Communications Development , although most of my

  • Anonymous
    February 02, 2009
    Hi Chris, Do you know of a way that I can feed presence data from an external presence source into the outlook jelly beans presence icon? Thanks, Art

  • Anonymous
    February 13, 2009
    You can set the user state of a contact using the OC Automation API, this includes custom presence states.   You can also set presence using UCMA 2.0 in the form of a client application endpoint. Can you ping me via the contact page to help me understand your scenario better? Thanks, Chris

  • Anonymous
    April 14, 2009
    I've found that when creating an application specific contact list that includes contacts that are not in the Communicator contact list, I get stale presence status.  Indeed, even Outlook shows stale presence for contacts that are not in my Communicator contact list.  This seems to be a problem with the Communicator Automation API.  Any plans for a fix?

  • Anonymous
    May 01, 2009
    This is by design.  Remember that presence is information owned by the contact.  If the contact is not in the local user's contact list, we show stale presence assuming that to get actual/real time presence the contact needs to provide it to you (or block you in some cases). Chris

  • Anonymous
    March 05, 2010
    The comment has been removed

  • Anonymous
    March 08, 2010
    @Norman In the R2 wave, you can implement a technical support tool using UCMA 2.0.  See the ACD sample in that SDK. In the 14 wave, you can add conversation window extensions to provide more features to the above scenario (such as a UI to enter notes on the call, look up information, etc.). In 14 you will also be able to integrate the IM conversation window into your application. For more details see the UC "14" Development FAQ on the front page of my blog.

  • Anonymous
    July 01, 2010
    Some user specific SQL query to extract specific information from the Database are available at the below link: techtips.opdubey.info/.../office-communicator-queries