We have 2 two major mobile carriers in our country - (1) beginning with 818927, 818937, 818929 and (2) beginning with 818917, 818919, 818987, 818989.
I have 4 usb modems (huawei) and I want 2 different lines to be used for each of those mobile carriers.
I am using DongleStatus because 2 simultaneous calls must be allowed on the same prefix (e.g. when there's two the same SIP agents are calling the same direction e.g. both of them trying to call two different numbers from 818927* range simultaneously)
Here I mention the extensions configuration which doesn't works!
But if you will remove all exten lines and only 1 of them will be remaining, then the whole DongleStatus script mentioned bellow works perfectly (it allows to use 4 lines subsequently by 4 SIP agents simultaneously)
I need your help to find a mistake in mentioned bellow configuration or your suggestion on alternate ways to achieve the same goal. I'm relatively new to asterisk, and I would appreciate not over-complicated answers.
; buklau
exten => _818927XXXXXXX,1,DongleStatus(GSM-001,Dongle0_Status)
exten => _818937XXXXXXX,1,DongleStatus(GSM-001,Dongle0_Status)
exten => _818929XXXXXXX,1,DongleStatus(GSM-001,Dongle0_Status)
exten => _818917XXXXXXX,1,DongleStatus(GSM-003,Dongle2_Status)
exten => _818919XXXXXXX,1,DongleStatus(GSM-003,Dongle2_Status)
exten => _818987XXXXXXX,1,DongleStatus(GSM-003,Dongle2_Status)
exten => _818989XXXXXXX,1,DongleStatus(GSM-003,Dongle2_Status)
same => n,DongleStatus(GSM-002,Dongle1_Status)
same => n,DongleStatus(GSM-003,Dongle2_Status)
same => n,DongleStatus(GSM-004,Dongle3_Status)
same => n,GotoIf($[${Dongle0_Status} = 2]?dongle0dial:dongle1check)
same => n(dongle0dial),Dial(Dongle/GSM-001/${EXTEN:2},60,tT)
same => n,Hangup
same => n(dongle1check),GotoIf($[${Dongle1_Status} = 2]?dongle1dial:dongle2check)
same => n(dongle1dial),Dial(Dongle/GSM-002/${EXTEN:2},60,tT)
same => n,Hangup
same => n(dongle2check),GotoIf($[${Dongle2_Status} = 2]?dongle2dial:dongle3check)
same => n(dongle2dial),Dial(Dongle/GSM-003/${EXTEN:2},60,tT)
same => n,Hangup
same => n(dongle3check),GotoIf($[${Dongle3_Status} = 2]?dongle3dial:utel)
same => n(dongle3dial),Dial(Dongle/GSM-004/${EXTEN:2},60,tT)
same => n,Hangup
This part:
exten => _818989XXXXXXX,1,DongleStatus(GSM-003,Dongle2_Status)
same => n,DongleStatus(GSM-002,Dongle1_Status)
is equal to
exten => _818989XXXXXXX,1,DongleStatus(GSM-003,Dongle2_Status)
exten => _818989XXXXXXX,2,DongleStatus(GSM-002,Dongle1_Status)
So it will not work with any other patern used above. If you need part be for all above, use something like
exten => _8189XXXXXXXXX,2,DongleStatus(GSM-002,Dongle1_Status)
Hint: You always can ask asterisk show how it understand dialplan, for that do
asterisk -rx "dialplan show number#context"
Related
There is an extension, for which I need a random sound file to be played, and once it's played the call should be hung up. I have the below dialplan which plays, for example, the 2nd playback and then 3rd one is played etc., but it should hangup after playing back one sound file
exten => 123.,7,Goto(${RAND(8,12)})
exten => 123.,8,Playback(/var/lib/asterisk/sounds/customer_Menu1)
exten => 123.,9,Playback(/var/lib/asterisk/sounds/customer_Menu2)
exten => 123.,10,Playback(/var/lib/asterisk/sounds/customer_Menu3); after playback it supposed rejected..
exten => 123.,11,Playback(/var/lib/asterisk/sounds/customer_Menu4)
exten => 123.,12,Playback(/var/lib/asterisk/sounds/customer_Menu5)
exten => 123.,13,Hangup()
exten => 123.,14,Hangup(34)
How can I make this work; calling, playing only one random menu and hanging up?
Just give the hangup command a priority label and add a Goto() pointing to it after playing each item.
Also:
if you want to use pattern matching for an extension (I assume that's why you have a dot after 123) you should prefix it with an underscore
same can be used in place of exten => ... for the extension when you're repeating the same thing
n can be used for the next priority so you don't have to worry about keeping all the numbers straight
Now if we get rid of the priority numbers, what do you use in place of Goto(${RAND(8,12)})? More labels:
[mycontext]
exten => _123.,1,NoOp("start of context")
; ...
same => n,Goto(menu${RAND(1,5)})
same => n(menu1),Playback(/var/lib/asterisk/sounds/customer_Menu1)
same => n,Goto(goodbye)
same => n(menu2),Playback(/var/lib/asterisk/sounds/customer_Menu2)
same => n,Goto(goodbye)
same => n(menu3),Playback(/var/lib/asterisk/sounds/customer_Menu3)
same => n,Goto(goodbye)
same => n(menu4),Playback(/var/lib/asterisk/sounds/customer_Menu4)
same => n,Goto(goodbye)
same => n(menu5),Playback(/var/lib/asterisk/sounds/customer_Menu5)
same => n(goodbye),Hangup(34)
Or, more simply, use the RAND() function to choose the name of the file to play:
[mycontext]
exten => _123.,1,NoOp("start of context")
; ...
same => n,Playback(/var/lib/asterisk/sounds/customer_Menu${RAND(1,5)})
same => n,Hangup(34)
Should be something like this:
exten => _123.,7,Set(FILES=customer_Menu1:customer_Menu2:customer_Menu3)
same => n,Playback(${CUT(FILES,:,${RANDOM(1,3)}); CUT will get nth argument delimited by :
same => n,Hangup(34)
Or like miken32 show you if your files are always same name.
Also nice idea is move configure variables like FILES in [general] section or special file included in code.
You DO NOT need /var/lib/asterisk/sounds/ before every file. Just check that in your /etc/asterisk/asterisk.conf sound path is /var/lib/asterisk/sounds(default).
I have an this extension in file /etc/asterisk/extensions_custom.conf:
exten => _XXXX,1,NoOp("-- from internal custom --")
exten => _XXXX,n,Set(CURL_RESULT=${CURL(https://your.domain.com/sip_webhook?callid=${EXTEN}&sourceid=${CALLERID(num)})})
exten => _XXXX,n,Wait(3)
exten => _XXXX,n,Dial(PJSIP/${EXTEN},60)
exten => _XXXX,n,Hangup()
The second line sends a request to a webhook in my server and stores the response in CURL_RESULT
I want to execute Dial only if CURL_RESULT was successful is there any way to achieve conditional execution of an extension?
something like:
if(CURL_RESULT=="OK")
exten => _XXXX,n,Dial(PJSIP/${EXTEN},60)
else
exten => _XXXX,n,Hangup()
Yes, as arheops indicated, this is actually a common built-in concept in the dialplan: conditional executing and conditional branching.
There are a lot of ways you could this - to give you some ideas:
#1: Conditional execute if true
exten => _XXXX,1,ExecIf($["${CURL_RESULT}" = "OK" ]?Dial(PJSIP/${EXTEN},60))
same => n,Hangup()
#2: Conditional branch if false
exten => _XXXX,1,GotoIf($["${CURL_RESULT}" != "OK" ]?exit)
same => n,Dial(PJSIP/${EXTEN},60)
same => n(exit),Hangup()
#3: Conditional branch if true/false:
exten => _XXXX,1,GotoIf($["${CURL_RESULT}" = "OK" ]?dial:exit)
same => n(dial),Dial(PJSIP/${EXTEN},60)
same => n(exit),Hangup()
That last example doesn't add anything in this case, but providing a true and false label is often useful.
If you want a true If/Else application in Asterisk, that works similar to in conventional programming languages, you can use the If module: https://github.com/InterLinked1/phreakscript/blob/master/apps/app_if.c (this has since been merged into Asterisk, you don't need to patch separately).
It's not currently included in mainline Asterisk so you'd need to drop that into your source, compile, and reinstall.
With that, you could do something like:
same => n,If($["${CURL_RESULT}" = "OK" ])
same => n,Dial(PJSIP/${EXTEN},60)
same => n,NoOp(${DIALSTATUS})
same => n,Else()
same => n,Playback(goodbye) ; do something else
same => n,EndIf()
same => n,Hangup() ; something after both
Each type of conditional syntax tends to work slightly nicer than some of the others in particular circumstances.
How to remove first 3 digits/letters from CALLED NUMBER. Let's say number 123456789 calls to abc987654321. I want to remove abc because in the context I have only 987654321. I know how to cut from CALLER but don't know how to cut from CALLED(Destination) number. This is what I tried so far but nothing happen:
exten => _[a-z]XXXXXXXXXXXX,1,Set({CALLEDID}=${CALLEDID:3})
exten => _[a-z]XXXXXXXXXXXX,2,Dial(SIP/${CALLEDID},1)
exten => _[a-z]XXXXXXXXXXXX,3,Voicemail(${CALLEDID}#VoiceMail)
exten => _[a-z]XXXXXXXXXXXX,4,Playback(Goodbye)
exten => _[a-z]XXXXXXXXXXXX,5,Hangup
You can use FILTER function or just do goto. You not need cut from destination,you need cut from extension.
exten => _[a-z]XXXXXXXXXXXX,1,Goto(${EXTEN:3},1)
exten => _XXXXXXXXXXXX,1,Dial(SIP/${EXTEN},1)
exten => _XXXXXXXXXXXX,n,Voicemail(${EXTEN}#VoiceMail)
exten => _XXXXXXXXXXXX,n,Playback(Goodbye)
exten => _XXXXXXXXXXXX,n,Hangup
Please note, your dialplan still do voicemail if called part hanguped after call. Read default extensions.conf.sample to see how to deal with voicemail
I am in a situation where I often need to change the active call flow control (which can only be one..right?).
I find that netsting call flow controls is very unhandy if you have 4 different scenarios.
So what I would like to do is to create an 4 different extensions that set the appropriate call flow as the inbound route destination.
To make an example:
I have
CALL FLOW NR 1
CALL FLOW NR 2
CALL FLOW NR 3
CALL FLOW NR 4
I would like to create:
extension *881 -> Toggles Call Flow nr 1 and sets it as destination
of the inbound route
extension *882 -> Toggles Call Flow nr 2 and sets it as destination
of the inbound route
extension *883 -> Toggles Call Flow nr 3 and sets it as destination
of the inbound route
extension *884 -> Toggles Call Flow nr 4 and sets it as destination
of the inbound route
Is something like that possible?
If so...how would you achieve it?
My system is based asterisk 11 and freepbx 2.11.
Thank you in advance for your time and effort.
You can put as many time conditions as needed.
You can use special code to turn on/off time condition(used for holidays). You can check exact code on timecondition page.
You also can create custom module which will change flow, more info see on dev.freepbx.org. As option you can hire someone do your condition module.
I figured it out
edit /etc/asterisk/extensions_custom.com and paste the following
[from-internal-custom]
include => enable-switch
[check-active-switch]
exten => s,1,NoOp("This context loops through all the switches and checks which one is ON. Than it follows its destination")
exten => s,n,GoSub(sub-get-nr-of-switches,s,1)
exten => s,n,Set(nrofs=${GOSUB_RETVAL})
exten => s,n,Set(i=0)
exten => s,n,Set(default-dest=app-daynight,${switchnr},1)
exten => s,n,Set(switchnr="NULL")
exten => s,n,While($[$[${i} < ${nrofs}] & $[${switchnr} = "NULL"]])
exten => s,n,Set(switchnr=${IF($["${DB(DAYNIGHT/C${i})}" = "NIGHT"]?${i}:"NULL")})
exten => s,n,Set(i=$[${i} + 1])
exten => s,n,EndWhile
exten => s,n,GotoIf($[${switchnr}!="NULL"]?app-daynight,${switchnr},1:${default-dest})
exten => s,n,Hangup()
[sub-get-nr-of-switches]
exten => s,1,Set(nr_of_s=0)
exten => s,n,Set(exten_state="NOT_ACQUIRED")
exten => s,n,While($[${exten_state}!=0])
exten => s,n,Set(exten_state=$[${VALID_EXTEN(app-daynight,${nr_of_s},1)}])
exten => s,n,NoOp(Exten nr ${nr_of_s} of app-daynight is ${exten_state})
exten => s,n,Set(nr_of_s=${IF($[${exten_state}=1]?$[${nr_of_s}+1]:${nr_of_s})})
exten => s,n,EndWhile
exten => s,n,NoOp(${nr_of_s} switches found)
exten => s,n,Return(${nr_of_s})
[enable-switch]
exten =>_*20X,1,NoOp("Abilita Switch selezionato e disabilita altre")
same => n,GoSub(sub-get-nr-of-switches,s,1)
same => n,Set(nrofs=${GOSUB_RETVAL})
same => n,Set(switchtoactivate=${EXTEN:3})
same => n,NoOp(Activated Switch nr ${switchtoactivate})
same => n,Set(i=0)
same => n,While($[${i}<${nrofs}])
same => n,Set(DB(DAYNIGHT/C${i})=DAY)
same => n,Set(i=$[${i}+1])
same => n,EndWhile
same => n,Set(freepbx_toggle_dest=*28${switchtoactivate})
same => n,Goto(app-daynight-toggle,${freepbx_toggle_dest},1)
same => n,Hangup
Next go to freepbx and create a custom destination -> check-active-switch,s,1 and set it as destination of the inbound route
I am new to asterisk. i am working under ubuntu 9.10. I use asterisk 1.8. I want to create a conference room.
in meetme.conf
conf => 1234,1234
in extensions.conf
exten =>1234,1,MeetMe(1234)
Is the pin number a secure one? How to create a secure pin number (do i have to use numbers and characters too)? Secondly how to create a blacklist? If a person tries to register 3 times..and the passed is incorrect how can I put him/her on the blacklist?
Passwords are numbers, however, '1234' is not a good password choice.
Asterisk's dialplan is extremely dynamic; there is no single definition of 'Blacklist'. However, try something like this:
== meetme.conf
conf => 1234
== extensions.conf
exten => 1234,1,GotoIf(${BLACKLIST()}?hangup)
exten => 1234,n(loop),Set(TRIES=$[0${TRIES} + 1]);
exten => 1234,n,GotoIf($["$TRIES" = "3"]?blacklist)
exten => 1234,n,Read(PIN,enter-conf-pin-number,4)
exten => 1234,n,GotoIf($["$PIN" = "9999"]?meetme)
exten => 1234,n,Goto(loop)
exten => 1234,n(meetme),MeetMe(1234)
exten => 1234,n,Hangup
exten => 1234,n(blacklist),Set(CALLERID(num)=${FILTER(0-9\-,${CALLERID(num):-10})})
exten => 1234,n,Set(DB(blacklist/${CALLERID(num)})="Some Comment")
exten => 1234,n(hangup),Hangup
there are all sorts of other ways. this particular setup will only keep the caller from trying to authenticate into that one conference room. if you'd rather ban him from ever touching your automated attendant, you can move the first line to your incoming context.
If you're already sanitizing your callerid (you should be) you can remove the FILTER line and bump the (blacklist) to the next line.