Bridge Communications

Saturday, April 15, 2017

Skype Web SDK - Part III



What is the Skype Web SDK?

The Skype Developer Platform for Web ("Skype Web SDK") is a set of JavaScript Web APIs and HTML controls that enable you to build web experiences that seamlessly integrate a wide variety of real-time collaboration models leveraging Skype for Business services and the larger Skype network. It provides support for multiple core collaboration services like presence, chat, audio, and video, enabling web experiences across a broad spectrum of users, platforms, and devices.






Today's Topic: Conversations

Conversations in S4B are nothing new, it's how we communicate with each.  Conversations can be text (IM), voice (audio) or voice + video (video).  A conversation consists of 2 or more people, which are called participants.  The relationship between objects in a conversation can visualized like this;

SkypeWebSDK_ConvObjects

The services for a conversation are broken into 3 parts as you can see, the Chat Service, the Audio Service, the Video Services, and the History Service.

A Very Simple Conversation

conv = app.conversationsManager.getConversation("sip:johndoe@contoso.com"); conv.chatService.sendMessage("Hi");

The beauty of this is if we had a conversation already going with the user, it grabs it and pushing the message Hi.  If we didn't, S4B will create a brand new conversation with the user and send the message.  This is nice as it saves us some coding logic.

Add More Participants

conv = app.conversationsManager.getConversation("sip:johndoe@contoso.com"); conv.chatService.sendMessage("Hi").then(() => { // joesmith will get an invitation to join the ad-hoc meeting conv.participants.add("sip:joesmith@contoso.com"); });

Ending a Conversation

To end a conversation you simply call the leave method on the conversation;

conversation.leave();


Context Data

Here is where the Skype Web SDK got it right, and made it much easier to pass along extra data with a conversation.  Let's imagine we have a website trying to help a customer find a house in a certain city.  They have entered all their relevant details on our website and now they are ready to get more information from a human.  It is terribly annoying as the customer when you do this, only to have to repeat the data to next person you speak with.  Here is how we can pass along extra context data in both the chat service and the audio service;

conversation.chatService.start({ .. other parameters context: 'Some random data', contextType: 'text/plain' });

conversation.audioService.start({ .. other parameters context: { "key1": "value1" }, contextType: 'text/json' });

Reading the context data

To read the context data from our message we can do something like this.

app.conversationsManager.conversations.added(function(conversation) { var context = conversation.context(); var contextType = conversation.context && conversation.context.type(); });

That will do it for this week, next week we'll dive into some more complicated conversation scenarios.

Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC, 
Full Stack Developer  BridgeOC Bridge Operator Console
Twitter - @droutledge @ndbridge









No comments:

Post a Comment

Any spam comments will be deleted and your user account will be disabled.