Paul Adams contacted me recently since he's been reading my posts about Asterisk and 'Microsoft OCS 2007' integration.
Paul wrote an interesting application that enables call queuing that 'respects' OCS presence. That is, if the agent's OCS status is "Busy", "Away" or "Do not Disturb", don't send them a call from the call queue. Leveraging Asterisk.NET & the Microsoft OCS development tools - in C# (Visual Studio 2005) - he was successfully able to control calls in Asterisk 1.4 based on any user's presence in OCS.
He wrote a simple test app that register's with OCS 2007 for a single or multiple users presence. Whenever a users presence changes - OCS 2007 informs his app directly.
Using an agi entry in the Asterisk dial plan, Asterisk asks his app what to do next. Then - based on the user's presence - the app tells Asterisk to queue the call or pass it to the user.
Eventually, he intends that the user can 'register' themselves for call queues (via a web page perhaps) - and this information will be used by the app to determine what calls should go to what users & if they are available right now or now. He explained that he intends to turn this app into a service and run it on his OCS or OCS Mediation server - and control incoming calls for his call center.
He told me, "I'm impressed with Asterisk.NET - and with the tools from Microsoft - they have made it really easy to monitor presence. It's more difficult to CHANGE presence - but I'm not so worried about that right now."
With information Paul sent me I was able to write a tutorial on controlling Asterisk based on an OCS user's presence. Credit goes to Paul for this tutorial.
Controlling Asterisk based on an OCS 2007 User's Presence Tutorial
This tutorial, although very basic, demonstrates is that it's easy to add 'OCS presence' awareness to desktop apps written in Visual Studio. Then you can control Asterisk using Asterisk.NET.
This is not intended to be a professional, server-based solution (because it uses the desktop Office Communicator client) - there is other MS development API's for OCS server interaction. Still, this provides some powerful presence integration with the popular Asterisk and OCS 2007 platforms.
Microsoft's Office Communication Server 2007 does not include call queuing, (it is believed call queuing shall be included in R2 of OCS 2007 - but how it will function or what it will offer is not yet clear).
Asterisk can provide call queuing - but Asterisk is not aware of the presence of a user in OCS. So how do we control Asterisk to pass calls to OCS users based on their presence?
Tools needed:
- Microsoft's C# - there is a free version of C# called the Express Version which maybe suitable for this - Visual Studio Professional 2005 or later works just as well.
- Asterisk.NET (1.4.0.1) - http://sourceforge.net/projects/asterisk-dotnet
- Microsoft Office Communicator 2007 SDK
- Office Communicator Presence Controls
You can 'tweak' the example app provided with Asterisk.NET & demonstrate this can be done.
"Preparing your Persona"
Install the "Office Communicator Presence Controls".
Now open "Program Files\ Microsoft Office Communicator 2007 Presence Controls".
Here you will find a readme.doc. Pages 7 & 8 tells you how to compile the managed control - which will produce "PresenceControls.dll".
Remember where this dll is - we'll need it later. Close this project.
"Check Asterisk.NET works with your Asterisk server"
On your Asterisk server, edit your extensions.conf file and add these 2 lines in any context you wish to use:
exten => 200,1,agi(agi://<ip address of dev PC in here>/customivr)
exten => 200,2,Hangup()
Open Asterisk.NET in Visual Studio - once loaded - you should see two projects inside it:
Asterisk.NET & Asterisk.NET.Test
Under the Asterisk.NET.Test project - view the code in "Program.cs". Update the IP address & login credentials to match your Asterisk server.
From the Solution Explorer panel, right-click on the Asterisk.2005 solution - and choose Rebuild. When it finishes - navigate in Windows to the "bin\Release" subfolder under the Asterisk.NET folder. Run the Asterisk.NET.Test.exe
You should see a command window running the test app. You should now be able to use a softphone to connect to Asterisk - and dial 200. If you are watching the Asterisk console - you should be able to see Asterisk receiving instructions from the test app running on your desktop.
"Amend the Asterisk.NET test app to react to OCS presence"
Return to the Asterisk.NET solution in Visual Studio. Right click on Asterisk.NET.Test - choose Add...- and from the sub-menu, choose Windows Form... I shall leave the name of the form as default - Form1.cs
Look at Form1.cs in the Designer View (not code view). Right-click anywhere in the toolbox panel & select "Choose Items..." You should see this window...
Press "Browse...". Now find the "PresenceControls.dll" from earlier. This will add the following two controls to the toolbox.
The "Persona" control is to monitor one user, and the "PersonaList" monitors multiple users.
Drag a "Persona" control onto your form. Now change the "Modifiers" property of the "Persona1" control to Public.
Now change to the code view for Form1.cs. Immediately after the InitalizeComponent line, I added a line to assign a user to the persona control - as below:
InitializeComponent();
persona1.SipUri = "<username>@<domainname.com>";
Once assigned a SipUri - the Persona control will register with the OCS server for that user - and continue to receive updates from the OCS server whenever the presence changes for that user.
You do have to have Office Communicator installed for the persona control to work - but the assigned user can be any user that you can detect presence for. Basically - if you have the permissions to add a user to your contacts in the Office Communicator (OC) client - you can monitor the presence of that user here.
Move to the code view of Program.cs - and change line 29 to exclude the checkManagerAPI(); command - like this below:
// checkManagerAPI();
checkFastAGI();
Move to the code view of CustomIVR.cs - here is the code controlling Asterisk when you dial the extension numbered 200.
Approx line 40 - after the answer command, add a new line to create an instance of the form1 we created.
Form1 testform = new Form1();
The form contains the persona control for our user.
We then use the persona control within the IVR code to control the call flow based on the presence of that user. "TextStatus" from the Persona control will give us a text response of the status of that user.
Use this line to display to the console the status of the user:
Console.WriteLine(testform.persona1.TextStatus);
Then use this code anywhere within the IVR code to control call flow based on the presence of the user in OCS.
if (testform.persona1.TextStatus == "Busy" || testform.persona1.TextStatus == "On the Phone")
{
<runs some code in here if the user is busy or one the phone>
}
Note that within OCS the "On the Phone" status is used when a user is on the phone (doh!) - but from an OC client it appears their status is set to "Busy".
If a user is not logged in to OCS - the presence is set to "Unknown". It also shows the text from the four OC client custom presence states if you have used them.
Rebuild the Asterisk.2005 solution - and run the Asterisk.NET.Test.exe again. Now when you call 200 from a Asterisk connected softphone - you should see the presence of the OCS user you are monitoring appear on the console of the test app each time the IVR menu 'loops'.
To help with troubleshooting - this is the contents of the "Release" directory when finshed.
Note: Make sure you have you need RTMPLTFM.dll & Uccp.dll in the working directory.
Happy OCS 2007 presence integration with Asterisk! If you try it, let me know how it goes.
android apple asterisk at&t blackberry cell phone cisco dell digium e911 facebook fcc google google talk gps im ip-pbx ipad iphone ipod itexpo ITEXPO lync microsoft mobile phone open source outage phone review sip skype sony unified communications verizon video video conferencing voip vonage wireless xbox 360
- Apple (280)
- Bittorrent (2)
- Call Center and CRM (48)
- Computer Hardware (183)
- Computer Software (71)
- Gadgets (650)
- Google (225)
- Home Entertainment (263)
- Internet (173)
- Linux (111)
- Microsoft (376)
- MovableType (48)
- News (187)
- Personal and Humor (118)
- Politics (9)
- Reviews (246)
- Security (2)
- Social Networking (42)
- Sports/Outdoor Technology (9)
- Tablets (32)
- Technology and Science (355)
- Unified Communications (471)
- VoIP (2285)
- Wireless (584)
- p2p (20)
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- September 2013
- August 2013
- July 2013
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- October 2005
- September 2005
- August 2005
- July 2005
- June 2005
- May 2005
- April 2005
- March 2005
- February 2005
- January 2005
- December 2004
- November 2004
- October 2004
- September 2004
- August 2004
- July 2004
- June 2004
- May 2004
- April 2004
- March 2004
Featured Videos