Callback

Материал из Xgu.ru

Перейти к: навигация, поиск


[править] Asterisk Callback

#!/bin/sh

CALLERID=$1
EXTENSION=$2

TEMP=`mktemp /tmp/callXXXXXXXXXXXX`.call
cat <<EOF > $TEMP
Channel: Sip/$EXTENSION
Extension: $CALLERID
Context: local
Priority: 1
EOF

chown asterisk:asterisk $TEMP
mv $TEMP /var/spool/asterisk/outgoing/
exten => _85X,1,Goto(callback,${EXTEN},1)
[callback]
exten => _85X,1,Set(MYEXT=${EXTEN})
exten => _85X,n,Hangup
exten => h,1,System(/usr/local/bin/callback.sh ${CALLERID(num)} 70${MYEXT:2})


[править] Перезвонить на номер, который пытался дозвониться

#!/bin/sh

EXTEN=$1
QUEUE=/tmp/call-queue/$EXTEN
CALL_TO="`head -1 $QUEUE`"
if [ -n "$CALL_TO" ]
then
        sed -i 1d $QUEUE
        TEMP=`mktemp /tmp/callXXXXXXXXXXXX`.call
cat <<EOF > $TEMP
Channel: Sip/$EXTEN
Extension: $CALL_TO
Context: gr3
Priority: 1
EOF

        cat $TEMP
        chown asterisk:asterisk $TEMP
        mv $TEMP /var/spool/asterisk/outgoing/
fi
[macro-incoming]                                                                
                                                                                
;exten => s,1,GotoIf($[${CALLERID(number)}=3301]?end)                           
;exten => s,1,GotoIf($[${BLACKLIST()}=1]?end)                                   
exten => s,1,Set(CALLFILENAME=from-${CALLERID(number)}-to-${MACRO_EXTEN}-${STRFT
IME(${EPOCH},EUROPE/kiev,"%Y-%m-%d-%H:%M:%S")})
exten => s,n,Monitor(wav,${CALLFILENAME},m)
exten => s,n,Dial(SIP/${MACRO_EXTEN},10)
;exten => s,n,GotoIf($[${ISNULL(${DB(mobile/${MACRO_EXTEN})})}]?end)
;exten => s,n,Dial(SIP/odessa/${DB(mobile/${MACRO_EXTEN})})
exten => s,n,GotoIf($[${DIALSTATUS}cro-test]=BUSY]?busy)
exten => s,n(busy),System(echo ${CALLERID(number)} >> /tmp/queue/${MACRO_EXTEN})
exten => s,n,Playback(/var/tmp/busy)
exten => s,n,Hangup
exten => s,n,VoiceMail(${MACRO_EXTEN}@default)
exten => s,n(busy),Playback(/var/tmp/busy)
exten => s,n(end),Hangup

exten => h,1,System(/usr/local/bin/queue.sh ${MACRO_EXTEN})
Источник — «http://xgu.ru:81/wiki/Callback»