Answer the question
In order to leave comments, you need to log in
There are 25 SIP providers in Asterisk, how to make dialplan so that dialing goes cyclically in a circle?
There are 25 SIP providers in Asterisk, how to make dialplan so that dialing goes cyclically in a circle?
That is, the first call from the subscriber is directed to the first SIP provider, the second call to the second provider, the 3rd call to 3 providers ... The 25th call to the 25th provider, 26th - again goes to the first provider.
On the Internet, I found an implementation example for three SIP providers (I checked for three SIP providers, it works) ... Please help me to modernize the code, or offer a more flexible code without reference to the number of SIP providers.
[context]
exten => _X.,1,ExecIF($["${DB_EXISTS(dial/count)}" = "0"]?Set(DB(dial/count)=0))
exten => _X., n,Set(DB(dial/count)=${IF($[${DB(dial/count)} > 2]?1:$[${DB(dial/count)} +1])})
exten => _X.,n,ExecIF($["${DB(dial/count)}" = "1"]?Dial(SIP/${EXTEN}@sipgate,,tT))
exten => _X., n,ExecIF($["${DB(dial/count)}" = "2"]?Dial(SIP/${EXTEN}@arinos,,tT))
exten => _X.,n,ExecIF($[ "${DB(dial/count)}" = "3"]?Dial(SIP/${EXTEN}@sipnet,,tT))
exten => _X.,n,Hangup
Answer the question
In order to leave comments, you need to log in
Line 2: ... ial/count)} > 2 ]?1:$[${DB(dial/count)} +1])})
and add all necessary extensions
....al/count)}" = " 25 "]?Dial(SIP/${EXTEN}@sip25net,,tT))
Of course, I don’t know Asterisk so well, and especially AEL capabilities, but it seems to me that in any case, each provider needs to be assigned a number. Will it be in the dialplan using a counter variable, as in the example you gave, or in sip.conf, each provider will have its own “number”, showing the dialplan the final number of trunks, in fact, it does not matter. Your dialplan is offhand working, there is a variable that increases by 1 after each call, and this is the general algorithm for iterating trunks. But in AEL the number of lines will be less, especially if you have 25 trunks.
Instead of the names 'sipgate', 'arinos', 'sipnet' etc. use numbers 'sip1', 'sip2', ..., 'sip25'. The dialplan is then reduced to:
[context]
exten => _X.,1,ExecIF($["${DB_EXISTS(dial/count)}" = "0"]?Set(DB(dial/count)=0))
same => n,Set(DB(dial/count)=${IF($[${DB(dial/count)} > 24]?1:$[${DB(dial/count)} +1])})
same => n,Dial(SIP/${EXTEN}@sip${DB(dial/count)},,tT))
same => n,Hangup
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question