📜 ⬆️ ⬇️

Auto Dial from Callback from Elastix

Since not all sip-phones can dial out, and sometimes you want to have it, I tried to implement it with the means *. By itself, the option suggests itself via call-files, but there is one trouble: when connected, both subscribers have the phone ringing at the same time, and when the addressee of the dialer picks up the phone and hears the waiting tone, he sometimes gets scared and hangs up ( quickly got used). I tried 2 options, the second seemed to me more universal and logical. They differ in the need to edit (remap) the default from-internal context.

So, the general for all:
in the file /etc/asterisk/extensions_custom.conf add:
[macro-autodial] ;    (  3),    exten => s,1,ExecIf($["${ARG1:0:1}" = "*" | ${LEN(${ARG2})} != 3 ],Hangup) ; .call- exten => s,n,System(echo "Channel: Local/${ARG1}@from-internal" > /tmp/${ARG2}${UNIQUEID}.call) exten => s,n,System(echo "MaxRetries: 10" >> /tmp/${ARG2}${UNIQUEID}.call) exten => s,n,System(echo "RetryTime: 20" >> /tmp/${ARG2}${UNIQUEID}.call) exten => s,n,System(echo "WaitTime: 40" >> /tmp/${ARG2}${UNIQUEID}.call) exten => s,n,System(echo -e "Callerid: \\x22CallBack ${ARG1}\\x22 \\x3C${ARG2}\\x3E" >> /tmp/${ARG2}${UNIQUEID}.call) ;   ,   exten => s,n,System(echo "Context: autodial-internal" >> /tmp/${ARG2}${UNIQUEID}.call) exten => s,n,System(echo "Extension: ${ARG2}" >> /tmp/${ARG2}${UNIQUEID}.call) exten => s,n,System(echo "Priority: 1" >> /tmp/${ARG2}${UNIQUEID}.call) ;    exten => s,n,System(sleep 15 && mv -f /tmp/${ARG2}${UNIQUEID}.call /var/spool/asterisk/outgoing/ &) ;  -  exten => s,n,Playback(ozhidajte-soedinenija) [autodial-internal] exten => _XXX,1,Dial(SIP/${EXTEN}) exten => _XXX,2,Hangup() 


But then the differences begin.
In the first version, we continue in the /etc/asterisk/extensions_custom.conf file.
At the end of the context [from-internal-custom] add:
 ; *20<>   <> exten => _*20X.,1,Macro(autodial,${EXTEN:3},${CALLERID(number)}) exten => _*20X.,2,Hangup() 


In the second variant, we switch to the /etc/asterisk/extensions_override_elastix.conf file, which allows you to reassign default contexts without losing the ability to change settings via the web interface.
In him:
 [from-internal] ;     exten => _[0-9*#]X.,1,Set(DB(LASTCALLED/${CALLERID(number)})=${EXTEN}) ;    exten => _[0-9*#]X.,2,Goto(from-internal-my,${EXTEN},1) ; *20      exten => *20,1,Macro(autodial,${DB(LASTCALLED/${CALLERID(number)})},${CALLERID(number)}) exten => *20,2,Hangup() ; *20<>   <> exten => _*20X.,1,Macro(autodial,${EXTEN:3},${CALLERID(number)}) exten => _*20X.,2,Hangup() ;  [from-internal]   ,     ,    ,  ,        [from-internal-my] include => from-internal-xfer include => bad-number 

')
As a result, * 20number will put the number into automatic redial, and just * 20 will redial the last number dialed, and the last combination will be available only in the second implementation version.

Source: https://habr.com/ru/post/214093/


All Articles