Enhancing FreePBX with Adhearsion
Luca Pradovera
Voice Application Developer, Mojo Lingo
Adhearsion
• 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...
Installation
• Install RVM on the machine
• Install Ruby 1.9.3
• bundle install –no-ri –no-rdoc bundler adhearsion
Your new application
• 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”
 }
Asterisk configuration
• On a FreePBX machine, edit extensions_custom.conf to add a
  context and AGI extension
 [adhearsion]
 exten => s,1,AGI(agi://localhost/fosdem)
FreePBX configuration
• 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
Time-based outbound call
restriction
• 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 mandatory:
 [macro-dialout-trunk-predial-hook]
 exten => s,1,AGI(agi://localhost/time_of_day_filter)
TBOCR: Adhearsion context
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 > 12
    #reject the call
    play "something-terribly-wrong"
    execute "CONGESTION", 60
    hangup
    end
    # if you do not hang up the call here, the call
    # will go through and continue dialing
}
TBOCR: FreePBX
• 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)
AMI Events in Adhearsion
• 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
AMI Events in Adhearsion/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
Thank you!
• http://adhearsion.com
• @adhearsion
• http://mojolingo.com

Enhancing FreePBX with Adhearsion

  • 1.
    Enhancing FreePBX withAdhearsion Luca Pradovera Voice Application Developer, Mojo Lingo
  • 2.
    Adhearsion • Ruby frameworkfor telephony applications • Actively developed by Adhearsion community • Interacts with Asterisk through AGI and AMI • Also supports Tropo via AGI • More platforms Coming Soon...
  • 3.
    Installation • Install RVMon the machine • Install Ruby 1.9.3 • bundle install –no-ri –no-rdoc bundler adhearsion
  • 4.
    Your new application •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” }
  • 5.
    Asterisk configuration • Ona FreePBX machine, edit extensions_custom.conf to add a context and AGI extension [adhearsion] exten => s,1,AGI(agi://localhost/fosdem)
  • 6.
    FreePBX configuration • 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
  • 7.
    Time-based outbound call restriction •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 mandatory: [macro-dialout-trunk-predial-hook] exten => s,1,AGI(agi://localhost/time_of_day_filter)
  • 8.
    TBOCR: Adhearsion context 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 > 12 #reject the call play "something-terribly-wrong" execute "CONGESTION", 60 hangup end # if you do not hang up the call here, the call # will go through and continue dialing }
  • 9.
    TBOCR: FreePBX • Ourmacro 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)
  • 10.
    AMI Events inAdhearsion • 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
  • 11.
    AMI Events inAdhearsion/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
  • 12.
    Thank you! • http://adhearsion.com •@adhearsion • http://mojolingo.com