Pages Menu

Posted by on May 22, 2015 in Learn Skype Web SDK | 0 comments

Learn Skype Web SDK Day 17 : Sending & Receiving “Is Typing” Notifications

Learn Skype Web SDK Day 17 : Sending & Receiving “Is Typing” Notifications

This is one post in a series of more than 30, devoted to helping you get up to speed quickly with the new Skype Web SDK. Each lesson comes with source code (in GitHub) and a working demo page so you can see what it does. Check out the full list of posts on the Skype Web SDK page.

View Demo

One of the surprisingly useful features of Skype for Business that I found when I started using it is the “is typing” messages. When the person you’re in a conversation with is typing a message, you get notification of that in the client. It’s a great way to know that the person is constructing their answer, rather than ignoring you.

If you’ve been using the Skype for Web API and created something which can send and receive messages, you’ll notice the lack of this feature even more. Wouldn’t it be nice if there was an easy way to include this into your Skype for Web API projects? Well there is!

The isTyping feature consists of two parts: you sending notification that you’re typing, and reacting to receiving messages that the remote party is typing. You don’t need to worry about “not typing anymore” messages: when you send a isTyping message it lasts 5 seconds, the server will automatically send a “stopped typing” message unless you continue to send isTyping messages.

Stage 1 – sending isTyping messages. You need some trigger to start sending the messages. In JQuery, a good starting place would be the keyup() on a text input box. Assuming you already have a conversation set up (if not see earlier posts), then sending the isTyping notification is as simple as:

[code language=”javascript”]
$(‘#someinputbox’).keyup(function (){

That’s it! By binding the call to the keyup function you’ll ensure that the message is sent each time a character is pressed, which should be enough to keep the messages realistic.

Stage 2 – receiving isTyping messages. This is a little more complicated, but only because the messages are hidden in a hard-to-find place. The reason for this is that although in our examples we’re only going to be looking at a conversation between two people, it’s possible to have group conversations and conferences, and the API needs to be able to cope with all scenarios. Therefore, it doesn’t make any sense to have a isTyping member on the conversation itself, it needs to be on every participant in the conversation.

In a previous post, we saw how to set up a new conversation. Part of that process involved creating a Conversation Participant, which we then added to the conversation. It’s this participant object which contains our isTyping message. Luckily, there’s a changed() event here as well, making it fairly easy to react to changes in typing messages. Assuming you’ve already created a participant:

[code language=”javascript”] (newState) {
//do something with newState

newState is a boolean signifiying whether or not the participant is typing. In designing a user interface, a common approach is to show a message (such as ‘Bob is typing…’) if the value is true, and to simply hide the message if it’s false.

Here’s a full example showing this in action

[code language=”javascript”]

Conversation State:


    Demo Online

    You can try this code out against your own Skype for Business environment by going to the demo page. From here you can also download the code from GitHub if you want to host it locally, or take it and use it in your next project.

    Disclaimer: This is sample code, intended to inform and educate. It is not production-ready and is lacking key components such as error handling. You use it entirely at your own risk. You should fully understand the effects, limitations and risks of the code before executing, and understand the implications of any set-up steps. By using these code examples you are using the Skype Web SDK, so you should read the Skype Software License Terms to which you are agreeing.

    Good to Know

    Post a Reply

    Your email address will not be published. Required fields are marked *

    This site uses cookies to help make this website better. By continuing to use this site we’ll assume you’re OK with that (implied consent).