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.
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:
- Highrise CRM.
- Google Contacts.
- (My Contacts) the Personal Contacts.
- 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.
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.
Here’s a video that will elaborate even more about what we’ve done with the Digium API: