Bridge Communications

Saturday, April 22, 2017

Skype Web SDK - Part IV

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 : Extending Conversations

It's likely in your travels that will have the need to do more than send a single message.  Being able to see incoming messages and reply to chat messages is a must.  This type of notification event is handled by the ChatService handler.  It is located in the client.conversationsManager.conversations namespace and be initialized like this.

 client.conversationsManager.conversations.added((conversation) => {

Accepting invitations to a conversation you aren't yet part of is a must if you want to send messages or audio to that conversation.'Notified', () => {
      var name = conversation.participants(0).person.displayName();
      var chatService = conversation.chatService;

      if (chatService.accept.enabled() &&
         confirm('Accept incoming chat request from ' + name + '?')) {
          console.log('accepting the incoming chat request');
      } else {
          console.log('declining the incoming chat request');
Reject and accept are the 2 commands that control whether or not you will be part of the conversation.

If you want to be able to send the user a notification that you are typing a message ( a good way to know the conversation is still active ) you could create a text box on your html page called "input" and then handle it with a method like this.

var input = document.querySelector('input');
var typing = false;

input.onkeydown = () => {
    if (!typing) {
        typing = true;
        setTimeout(() => {
            typing = false;
        }, 1500);

The 1500 means you will send the notification every 1500 ms or every 1.5 seconds while the user is typing.  This avoids sending an event for each and every character.

Accept and Respond in 1 Routine?

Perhaps you are writing some sort of bot to handle and request, and notify the user of such.  If you want to handle it in 1 small routine you can do something like this.

client.conversationsManager.conversations.added(conversation => {
  if (conversation.chatService.accept.enabled())
        conversation.chatService.accept().then(() => {
              conversation.chatService.sendMessage('Got your invite');

Next week we'll look at Audio Service component of a Conversation.

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


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