1. 2012
E n h a n c in g F r e e P B X w it h
A d h e a r s io n
Luca Pradovera
Voice Application Developer, Mojo Lingo
2. Ad h e ars io n
Ruby framework for telephony applications
Actively developed by Adhearsion community
Interacts with Asterisk through AGI and AMI
Also supports Tropo via AGI
More platforms Coming Soon...
3. In s tallatio n
Install RVM on the machine https://gist.github.com/843946
The script:
Installs RVM
Installs the build requirements
Installs Ruby 1.9.3 and the Gem system
Sets up Ruby
Installs Adhearsion and required gems
4. Vo ic e ap p lic atio n
Is a way to add logic to telephony systems
Can interact with external databases and protocols
Examples: MySQL, Rails, XMPP, LDAP
5. Yo u r n e w ap p lic atio n
ahn create <appname>
Important files are dialplan.rb and config/startup.rb
Edit startup.rb to set the correct argument delimiter
Build a simple dialplan:
fosdem {
play “tt-monkeys”
}
6. As te ris k c o n fig u ratio n
On a FreePBX machine, edit extensions_custom.conf to
add a context and AGI extension
[adhearsion]
exten => s,1,AGI(agi://localhost/fosdem)
Start the Adhearsion application with “ahn start .”
7. Fre e P B X c o n fig u ratio n
Tools > Custom Destination, Add Custom destination with a
name of “adhearsion,s,1”
Setup > IVR: Create an IVR with your custom destination in it
Route the default DID to the IVR: Setup > Inbound Routes >
All DIDs, set default to IVR and the name of your IVR
Create a SIP user if needed and dial 7777 to simulate an
incoming call
Press 1 and hear the sweet sound of monkeys!
8. Tim e -b as e d o u tb o u n d c all
re s tric tio n
Requirement: restricting outbound calls based on the
timezone at the destination or any other criteria
Done by one of our customers
Add to extensions_custom.conf, macro name is mandated
by FreePBX:
[macro-dialout-trunk-predial-hook]
exten => s,1,AGI(agi://localhost/time_of_day_filter)
9. TB O C R : Ad h e ars io n c o n te x t
time_of_day_filter {
# tz = Timezone.find_by_number(call.variables[:agi_dnid])
# time = Time.now.localtime(tz.offset)
time = Time.now
if time.hour > 11
#reject the call
play "something-terribly-wrong"
execute "CONGESTION", 5
hangup
10. TB O C R : Fre e P B X
Our macro will be executed every time an outside
extension is dialed
For demonstration purposes, we have added a simple
outbound catch-all route
Dial 4044754849 (my phone number at Mojo Lingo!)
11. AM I E ve n ts in Ad h e ars io n
AMI allows you to do event monitoring and handling
To enable AMI and events, first edit manager_custom.conf
adding a new user
[adhearsion]
secret = ahn123
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = all
write = all
12. AM I E ve n ts in Ad h e ars io n /2
Reload the manager in the Asterisk console
Edit startup.rb enabling AMI with the proper credentials
Edit events.rb to add some monitoring code
Restart the Adhearsion application if running
13. Th an k yo u !
Adhearsion Project
http://adhearsion.com
github.com/adhearsion
@adhearsion
Luca Pradovera
@lucaprado on Twitter – polysics on Github
lpradovera@mojolingo.com (Email/XMPP)