I am trying to make a dial plan to block incoming call coming from let say bangladesh where country code is 88
Here is my dial plan
exten => _X.,1,NoOp(${CALLERID(num)})
same => n,Set(regx=^(88)[0-9]$)
same => n,GotoIf($[${REGEX("${regx}" ${CALLERID(num)})} = 1]?blacklisted,s,1)
same => n,Dial(SIP/8.8.8.8/${EXTEN}
[blacklisted]
exten => s,1,Wait(9)
what i want to do is anything that comes from 88 should be sent to blacklist. At the moment if I test call with Caller ID 88 it works but if the call comes from 88XXXXXXX this does not work what can I do to make my dial plan block anything coming from 88XXXXXXXX to goto black list
Why do you use the complex REGEX function? Just do something like that:
exten => _X.,1,NoOp(CallerID is: ${CALLERID(num)})
exten => _X.,n,Set(number=${CALLERID(num)})
exten => _X.,n,ExecIf($[${number:2} = 88],Hangup())
exten => _X.,n,NoOp(Call is being continued)
This will save the callerid num into the "number" variable. Then it will check if the first 2 characters of the variable are equal to 88. If so, the call will be hung up. You can also use GoToIf instead of ExecIf if you want to send the blacklisted call to a specific context where you want to do something else with it.
Asterisk dialplan is regexp itself. Why you use other regexp?
exten => _X.,1,NoOp(${CALLERID(num)})
same => n,Gosub(cid-blacklist,${CALLERID(num)},1)
same => n,Dial(SIP/8.8.8.8/${EXTEN}
[cid_blacklist]
exten => _88.,1,Noop(bangladesh)
same => n,Wait(100)
; this works only when not found match in context.
include=> cid_blacklist_not_found
[cid_blacklist_not_found]
exten => _X.,1,Return;not found in cid blacklist
Related
I am receiving call in one trunk and forwarding that call by second trunk with following
[from-trunk1]
exten => _X.,1,Dial(SIP/trunk2/12345678)
Now I'd like to add IF condition. If callerid of a user calling to trunk1 is 112233, then I'd like to forward it to 445566 from trunk2.
You can just specify the caller ID as part of the extension pattern.
exten => _X./112233,1,Dial(SIP/trunk2/445566)
The CID pattern can accept all the same special characters as the destination pattern if you prefix it with _.
If anyone interested
[from-trunk1]
; if caller is 112233 go 50
exten => _X.,1,NoOp(${CALLERID(num)})
exten => _X.,n,GotoIf($["${CALLERID(num)}" = "112233"]?50)
; if not code below
exten => _X.,n,Playback(tt-monkeys)
; if condition where true, start from 50
exten => _X.,50,Dial(SIP/trunk2/445566)
Please suggest, if you have better code.
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 using the "monitor" command to record full calls. This works well, but only when the user goes through the entire callflow. I tried monitoring the recorded file size as the call progresses. Once the call starts, the file sizes start increasing (of both the "in" and "out" sides of the call). However, if the user hangs up prematurely in the middle of the call, whatever has been recorded thus far is inexplicably dropped and stubs (44 bytes) are left in its place. Any insight into why this behavior occurs will be appreciated.
I am reproducing a snippet from the dialplan I used in my extensions.conf file below:
exten => 7611,1,Answer()
exten => 7611,n,Playback(/var/lib/asterisk/sounds/custom/transferring_with_record_wa rning)
exten => 7611,n,Set(GROUP()=outgoing)
exten => 7611,n,NoOp(The current group count : ${GROUP_COUNT(outgoing)})
exten => 7611,n,GotoIf($[${GROUP_COUNT(outgoing)}>1]?15)
exten => 7611,n,Set(GLOBAL(current_timestamp_7611)=${STRFTIME(${EPOCH},GMT+1,%s)})
exten => 7611,n,Set(GLOBAL(current_full_format_timestamp_7611)=${STRFTIME(${EPOCH},G MT-8,%d%m%Y_%H%M%S)})
exten => 7611,n,NoOp(The current timestamp : ${current_timestamp_7611})
exten => 7611,n,NoOp(The last timestamp : ${last_timestamp_7611})
exten => 7611,n,GotoIf($[(${last_timestamp_7611}+20>${current_timestamp_7611})]?15)
exten => 7611,n,NoOp(All cases passed)
exten => 7611,n,Ringing()
exten => 7611,n,Wait(2)
exten => 7611,n,Monitor(wav,HALEF_audio_ext_7611_${current_full_format_timestamp_761 1})
exten => 7611,n,Dial(SIP/1200#JVXML97,,XgF(default^7611^14))
exten => 7611,n,Set(GLOBAL(last_timestamp_7611)=${STRFTIME(${EPOCH},GMT+1,%s)})
exten => 7611,n,Hangup()
exten => 7611,n,Ringing()
exten => 7611,n,Wait(2)
exten => 7611,n,Playback(/var/lib/asterisk/sounds/custom/busy_later)
exten => 7611,n,Wait(1)
exten => 7611,n,Hangup()
I understand that the "record" command has a "k" parameter which keeps the recorded file upon hangup, but I'm not able to find any similar functionality with the Monitor command. (I'd use "record", but I'd like to record the full call (duplex) and do it automatically, without any user input requirement).
Thanks!
Use MixMonitor command.
Check you have permissions needed for write files.
Check debug if you unsure.
PS. using diaplan WITH n, without labels and goto to EXACT priority is very bad practice, can result hard-catchable bugs. Using GLOBAL variables without need also not so nice idea.
I'm a beginner on Asterisk, but already have my PBX working connected to the PSTN. The issue I'm having is that I have this rule
exten => _*X.*,1,Log(DEBUG, Calling through provider one to ${EXTEN:1:-1})
same => n,Dial(SIP/${EXTEN:1:-1}#oneProvider,60)
There are no other extensions that start with *. What I want to achieve is to dial out as soon as the second * is pressed (and there's nothing the user can press to go to a valid extension), right now it waits a few seconds and dial. I also tried adding ! at the end of the extension, but nothing changed.
Am I missing something? Is this feasible?
Thanks!
This task is not doable in current asterisk.
It will not work beacuase * matched .(dot) in your dialplan.
Except dialplan like this(very ugly one beacuase it will go dialplan for every new digit)
[originalcontext]
exten => *,1,Goto(collect_number,s,1)
[collect_number]
exten => s,1,WaitExten(); wait for single digit
exten => *,1,Set(stars=${stars}*);save stars
exten => *,2,GotoIF($[ "${stars}" == "**" ]?dial,1); if 2 star already,go dial.
exten =>_X,1,Set(digits=${digits}${EXTEN});save digits
exten => _.,3,WaitExten(); wait enother input;
exten => _.,4,Goto(dial,1); go dial if no new digits
exten => dial,1,Dial(SIP/${digits}#oneProvider,60)
Correct solution - use Read application and ask user use # to end number instead of *.
You also can try dialplan like this:
exten => _*X*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXX*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXXX*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXXXX*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXXXXX*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXXXXXX*!,1,Goto(dial,${EXTEN:1:-1},1)
exten => _*XXXXXXXX*!,1,Goto(dial,${EXTEN:1:-1},1); continue upto max number length
[dial]
exten =>_.,1,Dial(SIP/${EXTEN}#oneProvider,,);
But i not fully sure that will work. If works, will be less load(but more lines)
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.