Page 263 - Asterisk™: The Future of Telephony
P. 263
This creates a folder at the destination specified containing the directory and file hier-
archy Adhearsion needs to operate. Right away, you should be able to execute the newly
created application by running:
ahn start ~/newproject
To familiarize yourself with the Adhearsion system, take a look through the applica-
tion’s folders and read the accompanying documentation.
Adhearsion dialplan writing
The ability to write dialplans in Adhearsion is typically the first feature newcomers use.
Since Ruby permits such fine-grained modification of the language itself at runtime,
one of the things Adhearsion does is make aesthetic changes, which are intended to
streamline the process of developing dialplans.
Below is an Adhearsion Hello World application:
my_first_context {
play "hello-world"
}
Though this is completely valid Ruby syntax, not all Ruby applications look like this.
Adhearsion makes the declaration of context names comfortable by interpreting the
dialplan script specially. Your scripts will be located in the root folder of your newly
created Adhearsion application.
As calls come into Asterisk and subsequently Adhearsion, Adhearsion invokes its own
version of the context name from which the AGI request originated. Given this, we
should ensure that a context in extensions.conf has this same name and forwards calls
properly to Adhearsion.
The syntax for directing calls to Adhearsion is as follows:
[my_first_context]
exten => _.,1,AGI(agi://127.0.0.1)
This catches any pattern dialed and goes off to Adhearsion via AGI to handle the call-
processing instructions for us. The IP provided here should of course be replaced with
the necessary IP to reach your Adhearsion machine.
Now that you have a basic understanding of how Adhearsion and Asterisk interact,
here is a more real-world dialplan example in Adhearsion:
internal {
case extension
when 10..99
dial SIP/extension
when 6000..6020, 7000..7030
# Join a MeetMe conference with "join"
join extension
when _'21XX'
if Time.now.hour.between? 2, 10
dial SIP/"berlin-office"/extension[2..4]
Asterisk Development with Adhearsion | 235