# This is an example dialplan. Feel free to remove this file and
# start your dialplan from scratch.
# This "internal" context would map over if Adhearsion were invoked
# in Asterisk's own "internal" context. For example, if you set up
# your extensions.conf file for Adhearsion as so:
#
# [internal]
# exten => _.,1,AGI(agi://192.168.1.3)
#
# then, when Adhearsion receives that call, it sees it came from
# the "internal" context and invokes this.
internal {
# In this example context you'll see use of a User object. This
# is intended to be an ActiveRecord object created from your
# config/database.rb file.
dialer = Phone.find_by_name(callerid)
if (extension == "9000")
exec("VoiceMailMain")
elsif (extension.length > 6) or (extension.length == 3)
#dial outbound here
dialstring = 'Zap/g1/' + extension
if dialer.can_call_out
dial dialstring
end
elsif number = Number.find_by_number(extension)
#not a special extension, send to internal fixtures
case number.has_number_type
when "Phone"
phone = Phone.find_by_id(number.has_number_id)
dial phone.username, :for => 30.seconds
exec("VoiceMail",phone.vmbox.mailbox)
when "Vmbox"
vmbox = Vmbox.find_by_id(number.has_number_id)
exec("VoiceMail",vmbox.mailbox)
end
elsif number = Number.find_by_number(extension[1..-1])
puts "zomg -1"
case extension[0..0]
when "5"
exec("SIPAddHeader","\"Alert-Info: Auto Answer\"")
phone = Phone.find_by_id(number.has_number_id)
dial phone.username
end
end
}
incoming {
phones = Phone.find_all_by_rings(true)
dial phones, :for => 30.seconds
exec("VoiceMail","1031@default")
}