[Asterisk-Users] Camp on?
Paul Zimm
pbzinc at dejazzd.com
Mon May 1 05:12:15 MST 2006
> Why not just create a .call file when the number is busy? The .call
> file tries to dial the destination with the retry interval and max
> attempts you specify, when the call goes thru, dial that other number.
>
Here's what I have been using to produce a callback feature. It's not
pretty but it works
**************************************************************************
; menu callback initiated
exten => *,1,GotoIf($[ ${CALLERID(num)} > 800 ]?:i|1)
exten => *,n,System(/usr/bin/ast_callback ${CALLERID(num)} ${CALLEDEXTEN} )
exten => *,n,AGI(tts_playback.sh,"call back activated",li)
exten => *,n,Hangup()
**************************************************************************
The GotoIf statement is checking to see if the call is an internal call
The CALLEDEXTEN variable that I defined contains the extension number
you dialed, you could also have it be the channel (ie Zap/2) your dialing.
This is the /usr/bin/ast_callback script.
**************************************************************************
#!/bin/bash
#
# Initiate a call file to call back busy extension
callerid=` echo $1 | sed -e 's/"//g'`
called=` echo $2 | sed -e 's/"//g'`
CALLBACKFILE=$(cat <<-EOF1
Channel: local/callback at extensions
MaxRetries: 3
RetryTime: 5
WaitTime: 5
CallerID: Call Back <$callerid>
Context: callback
Extension: $called
Priority: 1
EOF1)
echo "$CALLBACKFILE" > /var/spool/asterisk/callback/c_back$callerid$$
mv /var/spool/asterisk/callback/c_back$callerid$$
/var/spool/asterisk/outgoing/c_back$callerid$$
**************************************************************************
This is the context that the ast_callback script call file 'dials' back
into:
**************************************************************************
[callback]
exten => _8XX,1(available),ChanIsAvail(${ext_${EXTEN}}|s)
exten => _8XX,n,System(/usr/bin/ast_callback_ok ${CALLERID(num)}
${ext_${EXTEN}} )
exten => _8XX,available+101,System(/usr/bin/ast_sleep 5)
exten => _8XX,n,Set(loops=$[ ${loops} + 1 ])
exten => _8XX,n,GotoIf($[ ${loops} < 120 ]?available:)
exten => _8XX,n,Hangup()
**************************************************************************
I have all my extension channels defined as global variables (ie
ext_820 => Zap/13). So ${ext_${EXTEN}} maps extension number to channel.
If they the phone is no longer busy another call file is initiated where
the extension you were attempting to reach will be calling you back.
If it's still busy we wait 5 seconds and try again. There must be a
better way to do a 5 second wait but I used a script.
**************************************************************************
#!/bin/bash
#
# Initiate a call file to call back extension that is no longer busy
callerid=` echo $1 | sed -e 's/"//g'`
called=` echo $2 | sed -e 's/"//g'`
CALLBACKFILE=$(cat <<-EOF1
Channel: $called
MaxRetries: 2
RetryTime: 15
WaitTime: 15
CallerID: Call Back <$callerid>
Context: internal
Extension: $callerid
Priority: 1
EOF1)
echo "$CALLBACKFILE" > /var/spool/asterisk/callback/c_back$callerid$$
mv /var/spool/asterisk/callback/c_back$callerid$$
/var/spool/asterisk/outgoing/c_back$callerid$$
**************************************************************************
**************************************************************************
#!/bin/bash
#
# sleep for x seconds
sleep $1
**************************************************************************
More information about the asterisk-users
mailing list