Skip to content

Instantly share code, notes, and snippets.

View wwalker's full-sized avatar

Wayne Walker wwalker

View GitHub Profile
require 'pp'
def handle_originate_response
ahn_log "Looking for a matching OriginateResponses key: #{event.headers['ActionID']}"
attempt_id = OriginateResponses[event.headers['ActionID']]
ahn_log "attempt_id is #{attempt_id}"
if attempt_id
methods_for :rpc do
def async_call_into_context(channel, context, options={})
ahn_log.info "async_call_into_context channel: <#{channel}>"
ahn_log.info "async_call_into_context channel: <#{context}>"
ahn_log.info "async_call_into_context channel: <#{options.inspect}>"
#action = send_action_asynchronously "Login", "Username" => @username, "Secret" => @password, "Events" => "Off"
options[:variable] = options[:variables].map {|pair| pair.join('=')}.join('|')
# we get a PIN, here's the last DTMF of the pin (#):
DEBUG agi: >>> WAIT FOR DIGIT 6000
DEBUG agi: <<< 200 result=35
DEBUG agi: >>> EXEC playback 247_messages/4
DEBUG agi: <<< 200 result=0
# pressed 1
DEBUG agi: >>> EXEC BACKGROUND 247/are_you_able_to_respond
DEBUG agi: <<< 200 result=0
def initial_question(voice_message, query, retries = 3)
response = nil
while retries > 0 do
response = input 1,
:timeout => DTMF_TIMEOUT_SECONDS,
:play => [ query, '247/press_one_for_yes', '247/press_two_for_no', '247/press_three_to_hear_this_message_again']
break if ((response == '1') || (response == '2'))
play voice_message
retries -= 1
end
-- Executing [s@deliver_voice_message:2] NoOp("SIP/tsi-00cb1040", "inboundRecordMessageCall starts") in new stack
-- Executing [s@deliver_voice_message:3] NoOp("SIP/tsi-00cb1040", "AMDStatus = MACHINE") in new stack
-- Executing [s@deliver_voice_message:4] AGI("SIP/tsi-00cb1040", "agi://127.0.0.1/") in new stack
-- AGI Script Executing Application: (BACKGROUND) Options: (247/our_system_identified_this_as_an_answering_machine_if_you_are_human_press_one)
-- <SIP/tsi-00cb1040> Playing '247/our_system_identified_this_as_an_answering_machine_if_you_are_human_press_one' (language 'en')
[May 29 00:45:38] DEBUG[6894]: res_agi.c:1916 run_agi: SIP/tsi-00cb1040 hungup
# set time zone as early as possible
ENV['TZ']='UTC'
require 'rubygems'
require 'activesupport'
# set the time zone for Active Support (it monkey patches Time)
Time.zone = 'Etc/UTC'
require 'logger'
require 'rubygems'
require 'adhearsion'
require 'adhearsion/voip/asterisk/manager_interface'
begin
asterisk = Adhearsion::VoIP::Asterisk::Manager::ManagerInterface.connect :host => "127.0.0.1", :username => "manager", :password => "password", :events => true
result = asterisk.send_action_synchronously "core show channels"
puts result.inspect
result.headers
rescue Adhearsion::VoIP::Asterisk::Manager::ManagerInterfaceError => error
require 'pp'
require 'drb'
require 'rubygems'
require 'adhearsion'
require 'adhearsion/voip/asterisk/manager_interface'
begin
asterisk = Adhearsion::VoIP::Asterisk::Manager::ManagerInterface.connect :host => "127.0.0.1", :username => "247_manager", :password => "b0n3h34d", :events => true
result = asterisk.send_action_synchronously 'COMMAND', :command => "core show channels"
@wwalker
wwalker / gist:120653
Created May 30, 2009 22:06
new log info
DEBUG ami: Sending AMI action:
>>> Action: login
>>> ActionID: jyOCouM7-l97L-B4Px-9hAc-j7gUYULeH14K
>>> Username: 247_manager
>>> Secret: b0n3h34d
>>> Events: Off
>>>
INFO ami: Successful AMI actions-only connection into 247_manager@127.0.0.1
INFO ami: Successful AMI events-only connection into 247_manager@127.0.0.1
DEBUG ami: Sending AMI action:
[msgdemon@app1 tools]$ telnet localhost 5038
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Asterisk Call Manager/1.0
Action: login
ActionID: jyOCouM7-l97L-B4Px-9hAc-j7gUYULeH14u
Username: 247_manager
Secret: b0n3h34d
Events: Off