enhancing freepbx with adhearsion

12
Enhancing FreePBX with Adhearsion Luca Pradovera Voice Application Developer, Mojo Lingo

Upload: mojo-lingo

Post on 18-Dec-2014

284 views

Category:

Documents


0 download

DESCRIPTION

Enhancing FreePBX with Adhearsion presented by Luca Pradovera at FOSDEM 2012

TRANSCRIPT

Page 1: Enhancing FreePBX with Adhearsion

Enhancing FreePBX with Adhearsion

Luca Pradovera

Voice Application Developer, Mojo Lingo

Page 2: Enhancing FreePBX with Adhearsion

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...

Page 3: Enhancing FreePBX with Adhearsion

Installation

• Install RVM on the machine

• Install Ruby 1.9.3

• bundle install –no-ri –no-rdoc bundler adhearsion

Page 4: Enhancing FreePBX with 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”

}

Page 5: Enhancing FreePBX with Adhearsion

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)

Page 6: Enhancing FreePBX with Adhearsion

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

Page 7: Enhancing FreePBX with Adhearsion

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)

Page 8: Enhancing FreePBX with Adhearsion

TBOCR: Adhearsion contexttime_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

}

Page 9: Enhancing FreePBX with Adhearsion

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)

Page 10: Enhancing FreePBX with Adhearsion

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

Page 11: Enhancing FreePBX with Adhearsion

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

Page 12: Enhancing FreePBX with Adhearsion

Thank you!

• http://adhearsion.com

• @adhearsion

• http://mojolingo.com