Kirk Evans is a Microsoft Architect for the Azure Center of Excellence.
Introduction to SharePoint and Azure IaaS
Building SharePoint Apps with Windows Azure Platform as a Service
SharePoint Solutions and Architectures on Windows Azure Infrastructure Services
Understanding Authentication and Permissions with Apps for SharePoint and Office
This post will show how to initiate a chat using Skype from a Windows app.
I am working on a team project that needs to add a bunch of functionality such as sharing to social networks and initiating discussion with others. We have a very limited amount of time to build this functionality ourselves. Rather than code everything by hand, we are taking advantage of the functionality in Windows apps to do the heavy lifting for us. For instance, rather than build in all the logic to post to Twitter or Facebook or send an email ourselves, we can instead leverage sharing in apps to share information to other Windows apps. Similarly, we did not want to build a new instant messaging app ourselves, instead we wanted to use what the platform provides out of box.
The first part of the problem is trying to figure out how to contact a user. In our scenario, we want to initiate a conversation with our existing contacts. Windows 8x provides a very easy way to find contacts using the ContactPicker class.
When this code is run, you can now choose from your available contacts in Windows. If you have connected to LinkedIn, Facebook, or Twitter, your contacts from those networks will appear. Select one, and choose OK, and the contact information is returned to your app.
Want to select contacts from another source? You can also provide your own contact picker implementation. There is a Contact Picker app sample that shows how you could provide your own contact picker to select contacts from another system, perhaps from O365 or your own system.
The next part of the equation is determining if your contact has a Skype account or not. One of the properties of the Contact class is ConnectedServiceAccounts, which will let you determine if the contact has an associated Skype account. If we determine the user has a Skype account associated with their contact information, we can launch the Skype app.
When the app is run, the value of “skypeAccount.Id” on line 18 will be their Skype ID. We request the amount of screen real estate by using the LauncherOptions class. The result is Skype is launched using snap view, and our app takes the remaining available real estate on the screen.
There are many different options for initiating a conversation such as opening or creating a chat, as we did by appending the “?chat” querystring to the URI. If we omit the querystring, the default is to call the user. You could also initiate a video call. The various options are documented in the Skype URI API Reference.
Another option would be to initiate a call using the contact’s phone number instead of their Skype ID. Simply replace the “skypeAccount.Id” on line 18 above with their phone number, and Skype will initiate a call with the contact. You could also initiate a conversation with the user with their email address. There are lots of options now that you see how easy this is.
Skype URI API Reference
Build apps that connect with People and Calendar, Part 1: Contact Cards
Contact Picker app sample