Answer the question
In order to leave comments, you need to log in
How to call randomly/consecutively from different numbers?
Hi friends!
Bought several phones from MTT. numbers (let them be ABC). How can I configure in asterisk to call from asterisk through a random number every time? those. first calls through A, then through B, then through C. Then again through A, and so on? So that customers see different numbers.
Some groups of trunks or something like that logically. Tell me please.
PS. if the client himself calls to A, B or C, then he gets on the incoming line (I have already configured this).
Answer the question
In order to leave comments, you need to log in
Try this. I did not test the code, I wrote it in notepad, there may be errors.
asterisk -rx "database put TRUNKS_LIST/1/MYTRUNK1"
asterisk -rx "database put TRUNKS_LIST/2/MYTRUNK2"
asterisk -rx "database put TRUNKS_LIST/3/MYTRUNK3"
exten => XXXXX.,1,Noop(---------------Random-trunk-for-out-calls-----------------)
same => n,Set(CIRCLE_COUNT=4) ;;; указываем количество попыток, что бы не зациклиться
same => n(set_trunk),Set(TRUNK_NUMBER=${RAND(1,3)}) ;;; выбираем номер транка
same => n,Set(CIRCLE_COUNT=$[${CIRCLE_COUNT} - 1])
same => n,GotoIf($["${CIRCLE_COUNT}"="0"]?end_call) ;;; если попыток не осталось - закончить перебор
same => n,Set(TRUNK_NAME=${DB(TRUNKS_LIST/${TRUNK_NUMBER})}) ;;;; достаем имя транка из внутренней ДБ по номеру
same => n,Set(TRUNK_STATE=${DEVICE_STATE(SIP/${TRUNK_NAME})}) ;;;; проверяем занят ли транк
same => n,GotoIf($["${TRUNK_NAME}"="NOT_INUSE"]?:set_trunk) ;;; если транк занят, берем следующий
same => n,Dial(SIP/${TRUNK_NAME}/${EXTEN})
same => n(end_call),HangUp()
As far as I remember, there is no built-in mechanism for SIP.
Use a global variable - counter, and number the outgoing trunks, for example, trunk1, trunk2...
Before each call, increase the value of the variable by 1, as long as it is less than the number of trunks. On overflow, reset the counter. And then call the trunk by collecting its name from the "trunk" constant and the trunk number.
The counter can be replaced with RAND if desired, the dialplan will look simpler if there is no special need for round-robin
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question