[asterisk-users] Asterisk outbound calling does not wait for answer
before playback
Alvin Austin
aan at crlogic.com
Thu Feb 8 12:35:26 MST 2007
Hello Asteriskers, :-)
We're trying to set up an outbound notification calling for system
alerts with Asterisk 1.4.0. We generate a call file in
/var/spool/asterisk/outgoing and the outbound call is originated through
Zap/1 (Sangoma A200D to a Canadian POTS line). The problem is that
Asterisk does not wait for the other side to answer before it starts
playing the message. So the person called answers the phone after the
second or third ring and only hears the tail end of the message and the
"goodbye".
Ideally, we want to deliver the message immediately after the person
answers, or if an answering machine picks up, right after the "beep".
Any suggestions?
(1) The call file generator script (works ok):
#!/bin/sh
TMPFILE=`mktemp /tmp/tmp.XXXXXXX` || exit 1
echo "TMPFILE = $TMPFILE"
cat <<EOT > $TMPFILE
Channel: Zap/g1/phone_number_here
Callerid: SYSTEM
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: dialout
Extension: s
Priority: 1
EOT
mv -v $TMPFILE /var/spool/asterisk/outgoing
(2) The dialout context in extensions.conf (problem - starts playback
before call is answered)
[dialout]
exten => s,1,NoOp(Dialout)
exten => s,n,Set(TIMEOUT(digit)=5)
exten => s,n,Set(TIMEOUT(response)=8)
exten => s,n,Set(MACHINE=0)
exten => s,n,Answer
exten => s,n,BackgroundDetect(silence/5,1000,50)
exten => s,n,NoOp(Ans Machine detected)
exten => s,n,Set(MACHINE=1)
exten => s,n,BackgroundDetect(silence/30,1000,50,30050)
exten => s,n,NoOp(Ans Machine Message Too Long)
exten => s,n,Hangup
exten => talk,1,GotoIf($[${MACHINE}=1]?machine:human)
exten => talk,2(machine),Goto(dialout-machine,s,1)
exten => talk,3(human),Goto(dialout-human,s,1)
[dialout-machine]
exten => s,1,NoOp(Dialout to Ans Machine)
exten => s,n,Playback(/tmp/asterisk-recording)
exten => s,n,Wait(1)
; we'd like to do something to wait for the "beep" here...
exten => s,n,Playback(vm-goodbye)
exten => s,n,Hangup
[dialout-human]
exten => s,1,NoOp(Dialout to Human)
exten => s,n,Playback(/tmp/asterisk-recording)
exten => s,n,Wait(1)
exten => s,n,Playback(vm-goodbye)
exten => s,n,Hangup
(3) *CLI>
-- Attempting call on Zap/1/1234567 for s at dialout:1 (Retry 1)
> Channel Zap/1-1 was answered.
-- Executing [s at dialout:1] NoOp("Zap/1-1", "Dialout") in new stack
-- Executing [s at dialout:2] Set("Zap/1-1", "TIMEOUT(digit)=5") in new
stack
-- Digit timeout set to 5
-- Executing [s at dialout:3] Set("Zap/1-1", "TIMEOUT(response)=8") in
new stack
-- Response timeout set to 8
-- Executing [s at dialout:4] Set("Zap/1-1", "MACHINE=0") in new stack
-- Executing [s at dialout:5] Answer("Zap/1-1", "") in new stack
(Problem: Asterisk does not wait until the call is answered on the far end!)
-- Executing [s at dialout:6] BackgroundDetect("Zap/1-1",
"silence/5|1000|50") in new stack
-- Playing 'silence/5' (language 'en')
-- Executing [talk at dialout:1] GotoIf("Zap/1-1", "0?machine:human")
in new stack
-- Goto (dialout,talk,3)
-- Executing [talk at dialout:3] Goto("Zap/1-1", "dialout-human|s|1")
in new stack
-- Goto (dialout-human,s,1)
-- Executing [s at dialout-human:1] NoOp("Zap/1-1", "Dialout to Human")
in new stack
-- Executing [s at dialout-human:2]
Playback("Zap/1-1","/tmp/asterisk-recording") in new stack
-- Playing '/tmp/asterisk-recording' (language 'en')
-- Executing [s at dialout-human:3] Wait("Zap/1-1", "1") in new stack
-- Executing [s at dialout-human:4] Playback("Zap/1-1", "vm-goodbye")
in new stack
-- Playing 'vm-goodbye' (language 'en')
-- Executing [s at dialout-human:5] Hangup("Zap/1-1", "") in new stack
== Spawn extension (dialout-human, s, 5) exited non-zero on 'Zap/1-1'
-- Hungup 'Zap/1-1'
[Feb 8 13:29:37] NOTICE[32512]: pbx_spool.c:351 attempt_thread: Call
completed to Zap/1/1234567
Thanks for any ideas on this!
Alvin
More information about the asterisk-users
mailing list