Book Image

Twilio Cookbook: Second Edition

By : Roger Stringer
Book Image

Twilio Cookbook: Second Edition

By: Roger Stringer

Overview of this book

Table of Contents (20 chapters)
Twilio Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Displaying availability


Great, now you're able to make calls from one browser to another. Your application is starting to look pretty sweet. There's only one thing still missing though. How will you figure out who is available to receive an incoming call? Furthermore, how will you keep this list updated as clients connect and disconnect?

Getting Started

We can show a list of people who are available to be called in a few easy steps as follows:

  1. Register a handler function for presence events with Twilio.Device.presence().

  2. When a presence event is received, add or remove that client from a list in the UI.

  3. When the client name is clicked in the list, invoke the previously written call() function.

The complete code for this recipe can be found in the Recipe1 folder under Code.

How to do it…

We're going to display a list of clients who are connected to the same Twilio app, and then we will make a call to them by performing the following steps:

  1. Download the Twilio Helper Library available at https://github...