S
S
Sergey Ryzhkin2021-07-05 13:50:57
Asterisk
Sergey Ryzhkin, 2021-07-05 13:50:57

How to reset outgoing when the status is "busy"?

Comrades,
Help with editing the code, I can’t figure out how to reset an outgoing call if the line “where” they call (or call) is busy. The situation is as follows: There are several lines, I dial a mobile number, I call, the first line in the list is taken, the call comes from her name. If I reset the call on my mobile (like I'm busy), then the asterisk automatically dials from the second free outgoing line, and again I have to reset it, and so on until the entire enumeration is completed.
How to reset an outgoing call if the subscriber dropped the incoming one?

Full code under the spoiler.
As I understand it, you need to delve into the section:

[outgoing]
exten => _XXX.,1,Macro(recording,${CALLERID(num)},${EXTEN})
exten => _XXX.,n,Gosub(trunk_check,s,1(${EXTEN}))

Here I just did a search of free lines so that people could call, but there is no call reset when there is a "beat" that the line is busy.

Dial Plan

;
; extensions.conf - the Asterisk dial plan
;

[general]
static=yes
writeprotect=no

[globals]
DIR_RECORDS=/opt/mnt/calls/
TRANSFER_CONTEXT=local

[default]

[macro-recording]
;exten => s,1,Set(fname=${UNIQUEID}-${STRFTIME(${EPOCH},,%Y-%m-%d-%H_%M)}-${ARG1}-${ARG2});
exten => s,1,Set(fname=${STRFTIME(${EPOCH},,%Y/%m/%d)}/${UNIQUEID}-${STRFTIME(${EPOCH},,%Y-%m-%d-%H_%M)}-${ARG1}-${ARG2});
exten => s,n,Set(monopt=nice -n 19 /usr/local/bin/lame -b 32 --silent "${DIR_RECORDS}${fname}.wav" "${DIR_RECORDS}${fname}.mp3" && rm -f "${DIR_RECORDS}${fname}.wav" && chmod o+r "${DIR_RECORDS}${fname}.mp3");
exten => s,n,Set(CDR(filename)=${fname}.mp3);
exten => s,n,Set(CDR(realdst)=${ARG2});
exten => s,n,MixMonitor(${DIR_RECORDS}${fname}.wav,b,${monopt});
exten => s,n(no),Verbose(Exit record);

[phones]
include => local
include => outgoing

[local]
exten => 900,1,Answer()
exten => 900,n,Macro(recording,${CALLERID(num)},${EXTEN})
exten => 900,n,ConfBridge(1,confer)
exten => 101,1,Macro(recording,${CALLERID(num)},${EXTEN})
exten => 101,n,Dial(SIP/801&SIP/802,60)
exten => _XXX,1,Macro(recording,${CALLERID(num)},${EXTEN})
exten => _XXX,n,Dial(SIP/${EXTEN},60,tT)
exten => _XXX,n,Hangup()
exten => _XXX.,1,Goto(outgoing,${EXTEN},1)

[outgoing]
exten => _XXX.,1,Macro(recording,${CALLERID(num)},${EXTEN})
exten => _XXX.,n,Gosub(trunk_check,s,1(${EXTEN}))

;Dial plan "Incoming"
[incoming]
exten => 213135,1,Goto(ivr-main-1,s,1)
exten => 213136,1,Goto(ivr-main-1,s,1)
exten => 213137,1,Goto(ivr-main-1,s,1)
exten => 213153,1,Goto(ivr-main-1,s,1)
exten => 213157,1,Goto(ivr-main-1,s,1)
exten => 213158,1,Background(/etc/asterisk/ivr/notice_record)
exten => 213158,2,Macro(recording,${CALLERID(num)},${EXTEN})
exten => 213158,n,Dial(SIP/114,,t)
exten => 213159,1,Background(/etc/asterisk/ivr/notice_record)
exten => 213159,2,Macro(recording,${CALLERID(num)},${EXTEN})
exten => 213159,n,Dial(SIP/121,,t)
exten => 213162,1,Background(/etc/asterisk/ivr/notice_record)
exten => 213162,2,Macro(recording,${CALLERID(num)},${EXTEN})
exten => 213162,n,Dial(SIP/102,,t)

[trunk_check]
exten => s,1,Dial(SIP/${ARG1}@213135,45,T)
same => n,Dial(SIP/${ARG1}@213136,45,T)
same => n,Dial(SIP/${ARG1}@213157,45,T)
same => n,Dial(SIP/${ARG1}@213153,45,T)
same => n,Dial(SIP/${ARG1}@213158,45,T)
same => n,Dial(SIP/${ARG1}@213159,45,T)
same => n,Dial(SIP/${ARG1}@213162,45,T)
same => n,Hangup()

[ivr-main-1]
exten => s,1,Answer()
exten => s,2,Background(/etc/asterisk/ivr/ivr-welcome-02)
exten => s,3,WaitExten(5)
exten => _XXX,1,Macro(recording,${CALLERID(num)},${EXTEN})
exten => _XXX,2,Background(/etc/asterisk/ivr/notice_record)
exten => _XXX,n,Dial(SIP/${EXTEN},15)
;Check status peer: exists or not
exten => _XXX,n,GotoIf($["${SIPPEER(${EXTEN},status)}" = ""]?num-not-exist,1)
;Check status peer: enable or not
exten => _XXX,n,GotoIf($["${SIPPEER(${EXTEN},status):0:2}" = "UN"]?num-not-connected,1)
;Check channel
exten => _XXX,n,ChanIsAvail(SIP/${EXTEN},s)
;If 2 or 3 - Busy
exten => _XXX,n,GoToIf($[${AVAILSTATUS} = 2]?num-BUSY,1)
exten => _XXX,n,GoToIf($[${AVAILSTATUS} = 3]?num-BUSY,1)
;other statuses
exten => _XXX,n,Goto(num-${DIALSTATUS},1)
;Say - Try again
exten => num-not-exist,1,Wait(2)
exten => num-not-exist,n,Playback(invalid)
;Say - check number
exten => num-not-connected,1,Wait(2)
exten => num-not-connected,n,Playback(ss-noservice)
;Say - Busy
exten => num-BUSY,1,Wait(2)
exten => num-BUSY,n,Playback(vm-isonphone)
;Say - not available
exten => num-NOANSWER,1,Wait(2)
exten => num-NOANSWER,n,Playback(vm-isunavail)
;status CHANUNAVAIL,say - disabled
exten => num-CHANUNAVAIL,1,Wait(2)
exten => num-CHANUNAVAIL,n,Playback(vm-isunavail)
;return Secretariat
exten => t,1,Background(/etc/asterisk/ivr/notice_record)
exten => t,2,Macro(recording,${CALLERID(num)},${EXTEN})
exten => t,n,Dial(SIP/110,15)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Barbolin, 2021-07-05
@Franciz

Check call status when finished. But with this scheme, you still need to check the line before starting the call.

// вот простой пример на AEL))

_XXX. => {
        Noop(---------CALL-OUT-AEL--------);
        Set(lineList=213135;213136)
        while (${LEN(${lineList})} > 0) {
                Set(OUT_LINE=${CUT(lineList,;,1)});
                Set(__lineList=${CUT(lineList,;,2-)});
                if("${DEVICE_STATE(SIP/${OUT_LINE})}"="NOT_INUSE") {
                        Dial(SIP/${EXTEN}@${OUT_LINE},45,T);
                        if("${DIALSTATUS}"="ANSWER") {HangUp;}
                        if("${DIALSTATUS}"="BUSY") {HangUp;}
                }
        }
        HangUp;
        }
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question