text
stringlengths
0
152
mentation to support the library is essential.
The frameworks listed in Table 18-3 met all or most of the preceding criteria at this
writing. If you do not see a library listed here for your preferred programming lan‐
guage, it might be out there somewhere, but simply didn’t make our list.
Table 18-3. AGI development frameworks
Language
Framework
Adhearsion
Ruby
Asterisk-Java Java
.NET
AsterNET
Node.js
ding-dong
PHP
PAGI
Python
Panoramisk
Python + Twisted
StarPy
Conclusion
AGI provides a powerful interface to Asterisk that allows you to implement first-
party call control in the programming language of your choice. You can take multiple
approaches to implementing an AGI application. Some approaches can provide better
performance, but at the cost of more complexity. AGI provides a programming envi‐
ronment that may make it easier to integrate Asterisk with other systems, or just pro‐
vide a more comfortable call-control programming environment for the experienced
programmer. In many cases, the use of a prebuilt framework will be the best
approach, especially when evaluating or prototyping a complex project. For the ulti‐
mate performance, we still recommend you consider writing as much of your appli‐
cation as you can using the Asterisk dialplan.
Conclusion
|
329
CHAPTER 19
Asterisk REST Interface
People who think they know everything are a great annoyance to those of us who do.
—Isaac Asimov
The Asterisk REST Interface (ARI) was created to address the limitations inherent in
developing external or enhanced functionality outside Asterisk. While AGI allows
you to trigger external applications, and AMI allows you to externally supervise and
control calls in progress, any attempt to integrate both into a complete external appli‐
cation quickly becomes complex and kludgy. ARI allows developers to build a stand-
alone and complete application, using Asterisk as the underlying engine.
As of this writing, ARI requires a very basic dialplan in order to trigger the Stasis()
dialplan application, which then hands the channel over to ARI. By the time you read
this, it’s very likely that this requirement has changed, as the Asterisk developer com‐
munity has actively been working on allowing ARI to spawn without any dialplan in
the middle.
Using an external interface such as ARI to control Asterisk is not necessarily going to
make your life easier. The skills required to implement and troubleshoot applications
of this type require a comprehensive skill set, in not only your language of choice, but
also in Linux system administration, Asterisk administration, network troubleshoot‐
ing, and fundamental telephony concepts. For the skilled developer, ARI can give you
the power you want in your applications, but for someone learning, we recommend
you consider mastering the dialplan before you dive into external development envi‐
ronments. The dialplan is peculiar, but it is also completely integrated, high-
performance, and relatively easy to learn.
Having said that, let’s get you up and running with ARI.
331
ARI Quick Start
This section gives you a simple working example of ARI. Later in the chapter we’ll
cover things in more detail.1
In this quick-start section we will be using a very simple HTTP
access layer. You must be very careful about putting this sort of
configuration into production. If, for example, you are going to run
your application on a separate machine and connect it to Asterisk
across a socket, you will want a more secure connection. What
we’re doing in this section is akin to a sailing club using dinghies to
teach; useful as an introduction, but foolish and dangerous to set
out to sea in such a craft.
Basic Asterisk Configuration
You should already have the Asterisk web server running, so you simply need to ver‐
ify that your /etc/asterisk/http.conf file looks similar to the following:
[general]
enabled = yes
bindaddr = 127.0.0.1
Next, a simple /etc/asterisk/ari.conf file is needed:
[general]