Aptus Talks Custom App Development Via the Digium IP Phones API

Today’s guest blog post comes to us from Aptus, creators of a unique phonebook solution for Asterisk. Maaz B, technical advocate and Haisum Musawwir, lead developer, share their experiences building a custom IP phone application using the Digium phone App Engine API. Maaz and Haisum have put together a terrific resource for app developers. Read the post, check out their github and be sure to share on Twitter, LinkedIn, and Facebook.

At Aptus we are about to release our FonB Asterisk Phonebook Solution. FonB provides a web-based tool that manages four types of contacts as well as contacts in Highrise CRM, your active calls, and your call history for Asterisk-based phone systems. One of our features is a custom JavaScript app that runs on Digium’s IP Phones. Using the Digium phone API we were able to integrate FonB call history and contacts and make them accessible on the phone. Although FonB integrates with several brands of IP phones, the unique features of the Digium API allowed us to provide a better user experience. This post talks about how we developed the deskphone app and our thoughts on using the Digium phone API.

We noticed that the Digium API gives your app much more control and possibilities than other phones’ development APIs. Digium achieves this via the JavaScript engine. We have integrated FonB call history and contacts with Snom, Polycom, Grandstream, Aastra and Yealink phones using XML. These XML-based APIs are just templates which you can render based on data received from a database. All data manipulations are supposed to be done on the server side only. With JavaScript, the Digium API provides us with a way to manipulate data inside the application, tailored to our requirements. It supports almost all ECMAScript 5 JavaScript functions and objects.

One of the most useful objects in the Digium Phone API is ‘NetRequest.’ It is similar to XMLHttpRequest object; however, it is implemented in such a way that it sends fragmented TCP packets as the request rather than a single, big HTTP request. It also has user and password properties for authentication. Having AJAX support gives us the possibility of sending requests with various methods such as POST, GET, DELETE and PUT rather than only GET. Fortunately, at Aptus, we developed our backend as an API, enabling us to easily use the Digium API on the endpoint to manipulate and retrieve data from our backend.

A challenge we encountered was managing authentication with our web server. Digium’s API has an ‘Auth’ module; however, it is made for communication purposes with Switchvox (Digium’s business phone system) or with DPMA (Digium Phone Module for Asterisk). The question that arose was: how can we maintain sessions and cookies with the server? Unfortunately, there wasn’t a clear way to set or get them. Our simple solution was to save the IP at the server after authenticating it via username and password in a GET request. Once that was accomplished, we began exploring the power of Digium’s phone API.

The best thing about Digium’s phone API is its widgets. The List widget was found to be the most useful among them. We wanted to list the contacts and call history from the FonB database.

For each contact or number in a user’s call history, we wanted to show icons to identify whether a particular contact belonged to one or more of our four contact categories:

  1. Highrise CRM.
  2. Google Contacts.
  3. (My Contacts) the Personal Contacts.
  4. Internal extension.

The ‘List object’ supports both text and widget content to be stored in cells. We used the Image widget to show the image of a particular contact type and the Group widget to show multiple images if a contact had multiple contact sources. We then added that Group of images inside a cell in a List and added duration, call time, contact name, number, etc as strings in the rest of the cells in a row. To make the List scrollable, we added the List to the Scroll widget and added the Scroll widget to the Window. This mix of different widgets results in a sleek list of contacts and call history, letting the user dial the number he currently has focus on – which is possible thanks to the digium.phone.dial function.

After we had listings of call history and contacts, AJAX support and events on keys provided a way for pagination and search. A user can use the right navigation key or softkey(3) to go to the next page and use the left navigation key or softkey (2) to go to the previous page. A user can search through the call history for a particular number or for contacts for a particular name by pressing the (*) key or ‘search’ softkey. To filter the call history for ‘inbound/outbound’ or ‘missed calls,’ and ‘contacts’ for Google, Highrise, personal contacts or extensions, a user can simply press (#) to see filtering options and then select any filter. These onkey events were vital for a better user experience. No XML API based development platform provides these capabilities. They are only available with the Digium phone API. Overall, it is a comprehensive API for making dynamic apps.

Some features, such as images, dialpad shortcuts, and a mix of search and filter in our app were only possible on Digium phones. Digium’s Javascript API helped in improving user experience and included new features which we couldn’t provide in our app for other phones due to the limitations in XML-based APIs.

The source code of our app is now public, and we will keep improving our app based on the feedback we receive from the community. Our plan is to make it as comprehensive as the web interface of FonB, so that everything a user would do on the FonB web interface, would be doable on their Digium phone. No other vendor can facilitate developing IP phone applications at this level. Digium, for sure, has made life easy when it comes to IP phone application development.

Edit: Download the Aptus Digium Phone app from the Asterisk Exchange:

Here’s a video that will elaborate even more about what we’ve done with the Digium API:

About the author

Billy is a Marketing Manager at Digium with a passion for Asterisk. You can find Billy on the web on Google+ and Twitter

Leave a Reply