Related
Here is my sample dialplan
exten => _X.,1,Progress()
exten => _X.,n,Playback(welcome,noanswer)
exten => _X.,n,Hangup()
When I tried to call through dhadi channel. I am getting the below logs in asterisk console.
-- Accepting call from '9042394773' to '33468550' on channel 0/8, span 1
-- Executing [33468550#test:1] Progress("DAHDI/i1/9042394773-8", "") in new stack
-- Executing [33468550#test:2] Playback("DAHDI/i1/9042394773-8", "welcome,noanswer") in new stack
-- <DAHDI/i1/9042394773-8> Playing 'welcome.slin' (language 'en')
-- Executing [33468550#test:3] Hangup("DAHDI/i1/9042394773-8", "") in new stack
-- Hungup 'DAHDI/i1/9042394773-8'
But the welcome voice is not audio able.. How do I play weclome voice before atten the call??? Whether I have to change any configuration in asterisk????
Am using asterisk 13.5.
I found this example where a Wait(1) is used between Progress and Playback.
Maybe you can give it a try.
exten => 500,1,Progress()
exten => 500,n,Wait(1)
exten => 500,n,Playback(WeAreClosedGoAway,noanswer)
exten => 500,n,Hangup()
I've an asterisk pbx that manages some sip providers (a ISDN Patton) and some Voip providers.
I'm trying to use matching of CID in my dialplan as described here.
This is the relevant part of my dialplan, please note that this part of dialplan is included my extension.conf:
[patton];Calls from Patton
exten => 0219999999/_0031X.,1,Answer(0)
exten => 0219999999/_0031X.,n,Hangout()
exten => 0219999999,1,Answer(0)
exten => 0219999999,n,Goto(in_4,${EXTEN},1)
[in_4]
exten => 0219999999,1,Noop(Exten: ${EXTEN})
exten => 0219999999,n,Noop(CID: ${CALLERID(NUM)})
In short I want do something different when the CID of the caller cames from Netherlands.
Watching what happens in Asterisk CLI I see:
== Using SIP RTP CoS mark 5
-- Executing [0219999999#patton:1] Answer("SIP/patton-00000011", "0") in new stack
-- Executing [0219999999#patton:2] Goto("SIP/patton-00000011", "in_4,0219999999,1") in new stack
-- Goto (in_4,0219999999,1)
-- Executing [0219999999#in_4:1] NoOp("SIP/patton-00000011", "Exten: 0219999999") in new stack
-- Executing [0219999999#in_4:2] NoOp("SIP/patton-00000011", "Cid: 0031123456789") in new stack
So what I understand is that Asterisk don't apply the CID matching but I don't understand why, considering that if I print the CID it matches perfectly my expression.
Here is a section of my extensions.conf file that deals with inbound caller ID matching (from a PSTN line)
There might be another/better way to do this, but its been a working config for me since 1.4 and I'm now running 13.7 without any issues. (Individual numbers have been replaced with '#') - This is a simple dial plan.
This is used to catch anyone who send an 084 or 087 prefix, a couple of specific numbers and anything from 'international' or lazy system administrators 'UNAVAILABLE'
I've the same thing set up for SIP trunks as well so this should work across any channel type.
[from-pstn]
exten => s,1,Verbose(CLID From BT ${CALLERID(all)})
exten => s,2,GotoIf($[${CALLERID(num):0:3} = 087]?103:3)
exten => s,3,GotoIf($[${CALLERID(num):0:3} = 084]?103:4)
exten => s,4,GotoIf($[${CALLERID(num):0:11} = 07896######]?103:5)
exten => s,5,GotoIf($[${CALLERID(num):0:11} = 01494######]?103:6)
exten => s,6,GotoIf($["${CALLERID(name):0:13}" = "INTERNATIONAL"]?103:7)
exten => s,7,GotoIf($["${CALLERID(name):0:11}" = "UNAVAILABLE"]?103:8)
exten => s,8,GotoIf($[${CALLERID(num):0:10} = 020315####]?103:9)
exten => s,103,Answer
exten => s,104,Wait(1)
exten => s,105,Playtones(info)
exten => s,106,Wait(7)
exten => s,107,Hangup
exten => s,9,Goto(internal-ext,5800,1)
You would want something like;
[from-yourtrunk]
exten => s,1,Verbose(CLID From <yourtrunk> ${CALLERID(all)})
exten => s,2,GotoIf($[${CALLERID(num):0:4} = 0031]?103:3)
exten => s,103,<do something with the call that matches the CLI>
exten => s,3,Goto(<your-internal-ext>,<number>,1)
Something to keep in mind - if you handle inbound caller ID that could start 0031 but its not a call from .nl then you would need to apply some additional patten matching to the 2nd line to enforce a minimum number of digits (for example) otherwise that will match any call that comes in with a CLI of 0031...............................
If you need any more explanation, or I've got the wrong end of the stick just add a comment to this answer.
There can be non zero probability, that cid is go in other format(use Verbose or Noop command to show real cid)
Also in this case any dialplan can work if cid match
Asterisk not select "most matching" dialplan. Insead it select FIRST matching dialplan.
You can use different contexts and include directive to control matching. See examples in extensions.conf.sample
-- Executing [19#test:1] Answer("SIP/test2-0000821a", "") in new stack
-- Executing [19#test:2] Set("SIP/test2-0000821a", "CALLERID(num)=0031123456789") in new stack
-- Executing [19#test:3] Goto("SIP/test2-0000821a", "patton,0219999999,1") in new stack
-- Goto (patton,0219999999,1)
-- Executing [0219999999#patton:1] Answer("SIP/test2-0000821a", "0") in new stack
[Feb 10 08:26:09] WARNING[15817][C-00008bfe]: pbx.c:4869 pbx_extension_helper: No application 'Hangout' for extension (patton, 0219999999, 2)
== Spawn extension (patton, 0219999999, 2) exited non-zero on 'SIP/test2-0000821a'
[Feb 10 08:26:45] NOTICE[1499]: chan_sip.c:28210 handle_request_register: Registration from '"407" <sip:407#78.47.159.180:5060>' failed for '221.144.172.3:5083' - Wrong password
pro-sip*CLI> dialplan show pa
park-dial park-hints park-orphan-routing park-return-routing parkedcalls parkedcallstimeout
patton
pro-sip*CLI> dialplan show patton
[ Context 'patton' created by 'pbx_config' ]
'0219999999' (CID match '_0031X.') => 1. Answer(0) [pbx_config]
2. Hangout() [pbx_config]
'0219999999' => 1. Answer(0) [pbx_config]
2. Goto(in_4,${EXTEN},1)
[pbx_config] pro-sip*CLI> core show applications like Hang
-= Matching Asterisk Applications =-
ChangeMonitor: Change monitoring filename of a channel.
Hangup: Hang up the calling channel.
HangupCauseClear: Clears hangup cause information from the channel that is available through HANGUPCAUSE.
SoftHangup: Hangs up the requested channel.
-= 4 Applications Matching =- pro-sip*CLI>
Addon2(please note, debug is OFFTOPIC on SO)
-- Executing [0219999999#patton:1] NoOp("SIP/test2-0000821c", "cid match") in new stack
-- Executing [0219999999#patton:2] Answer("SIP/test2-0000821c", "0") in new stack
[Feb 10 08:32:18] WARNING[15826][C-00008c00]: pbx.c:4869 pbx_extension_helper: No application 'Hangout' for extension (patton, 0219999999, 3)
== Spawn extension (patton, 0219999999, 3) exited non-zero on 'SIP/test2-0000821c'
pro-sip*CLI> dialplan show pa
park-dial park-hints park-orphan-routing park-return-routing parkedcalls parkedcallstimeout
patton
pro-sip*CLI> dialplan show patton
[ Context 'patton' created by 'pbx_config' ]
'0219999999' (CID match '_0031X.') => 1. Noop(cid match) [pbx_config]
2. Answer(0) [pbx_config]
3. Hangout() [pbx_config]
'0219999999' => 1. NOOP(CIDNOTMATCH) [pbx_config]
2. Answer(0) [pbx_config]
3. Goto(in_4,${EXTEN},1) [pbx_config]
I have a problem lately, of getting crank calls at all hours of the day and night from overseas countries. I am trying to blacklist entire countries, by country code. After googling around I have come up with the following solution, but don't think it is working... as I have tried substituting my own area code and that doesn't work.
Does the coding look correct?
Also, I don't fully understand the [+]?1? part, and would appreciate a breakdown.
FYI, I do have a working blacklist by number set-up, so I know the [blacklisted] context part works.
extentions.conf:
;; same => n,Set(regx=^[+]?1?(215|609)[0-9]{7}$) ;; my test
same => n,Set(regx=^[+]?1?(252|96|27)[0-9]{9}$)
same => n,GotoIf($[${REGEX(“${regx}” ${CALLERID(num)})} = 1]?blacklisted,s,1)
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
Examples of numbers I am trying to block:
+252616251444
+252616531860
+27612238445
+96893327281
The test number I am trying to block is 1-609-123-4567.
Here is my extension.conf:
[from-Provider]
exten => _X.,1,Set(CALLERID(num)=${CALLERID(num):1})
exten => 17025551234,1,Zapateller(nocallerid)
exten => _XX./_+252X.,n,Goto(blacklisted,s,1)
exten => _XX./_+1609X.,n,Goto(blacklisted,s,1)
same => n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
same => n,Dial(SIP/home&IAX2/droid&SIP/office)
same => n,Hangup()
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
This is the result of a call that should go through. It gets blocked and spits out this output until the caller hangs up.
CLI output:
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Zapateller("SIP/Provider_did10-00000080", "nocallerid") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000080' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Zapateller("SIP/Provider_did9-00000081", "nocallerid") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000081' status is 'UNKNOWN'
...
-- Executing [17025551234#from-Provider:1] Zapateller("SIP/Provider_did9-00000088", "nocallerid") in new stack
== Spawn extension (from-Provider, 17025551234, 1) exited non-zero on 'SIP/Provider_did9-00000088'
EDIT (with noop added for callerid)
I replaced the dialplan with yours verbatim. The problem is no calls get through.
I think I see my problem. I need to include exten => 17025551234,1,Zapateller(nocallerid) because that is my DID. I don't know where to place that.
Here is the CLI output. It is the same whether it's a call that should go through or should be blocked...
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did10-000000ec", "CALLERID(num)=16175551234") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-000000ec' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did9-000000ed", "CALLERID(num)=16175551234") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-000000ed' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did9-000000ee", "CALLERID(num)=16175551234") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-000000ee' status is 'UNKNOWN'
EDIT (extensions.conf):
[globals]
[default]
exten => 1001,1,Progress()
exten => 1001,n,Answer()
exten => 1001,n,Playback(hello-world)
exten => 1001,n,Hangup()
[internal]
exten => 100,1,Dial(SIP/home)
same => n,Hangup()
exten => home,1,Dial(SIP/home)
same => n,Hangup()
exten => 103,1,Dial(SIP/office)
same => n,Hangup()
include => default
include => iax2
[iax2]
exten => 10,1,Dial(SIP/home)
same => n,Hangup()
exten => 11,1,Dial(IAX2/droid)
same => n,Hangup()
exten => 12,1,Dial(SIP/home&IAX2/droid)
same => n,Hangup()
exten => 20,1,Dial(IAX2/clive)
same => n,Hangup()
include => default
[from-Provider]
exten => _X.,1,Set(CALLERID(num)=${CALLERID(num):1})
exten => 17025551234,1,Zapateller(nocallerid)
same => n,Noop(CALLERID=${CALLERID(all)})
same => n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
same => n,Dial(SIP/home&IAX2/droid&SIP/office)
same => n,Hangup()
exten => 442035551234,1,Zapateller(nocallerid)
same => n,Set(regx=^[+]?1?(252|96|27)[0-9]{9}$)
same => n,GotoIf($[${REGEX("${regx}" ${CALLERID(num)})} = 1]?blacklisted,s,1)
same => n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
same => n,Dial(SIP/home&IAX2/droid&SIP/office)
same => n,Hangup()
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
I have two DIDs. One in the USA 17025551234, and one in the UK 442035551234. I have no trunk lines.
EDIT (CLI output using ESYSCODER's context)
I have replaced the entire [from-Provider] context with your context exactly as you posted it. Then I dialed my DID number 17025551234from a number that should not be rejected 17025550000 (obviously I am changing the numbers for privacy concerns).
The CLI output is as follows:
com1*CLI>
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did9-00000012", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000012' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did10-00000013", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000013' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did10-00000014", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000014' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did9-00000015", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000015' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did9-00000016", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did9-00000016' status is 'UNKNOWN'
== Using SIP RTP CoS mark 5
-- Executing [17025551234#from-Provider:1] Set("SIP/Provider_did10-00000017", "CALLERID(num)=17025550000") in new stack
-- Auto fallthrough, channel 'SIP/Provider_did10-00000017' status is 'UNKNOWN'
com1*CLI>
What confuses me is that I must have the exten => 17025551234,1,Zapateller(nocallerid) line in order for the the DID 17025551234 to pick up. Where should that fit into the dialplan/context that you are suggestiong. Or am I missing something. Is there another way to answer when my DID number is ringing me? Sorry if I'm being thick here... I may be missing one simple point.
EDIT (priority change)
With the following context the caller gets a message, "The number you have dialed is not in service"...
[from-didforsale]
exten => _XX./_1609123456X,1,Goto(blacklisted,s,1)
exten => _XX.,n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
exten => _XX.,n,Noop(CALLERID=${CALLERID(all)})
exten => _XX.,n,Dial(SIP/home&IAX2/droid&SIP/office)
exten => _XX.,n,Hangup()
and this is the CLI output:
== Using SIP RTP CoS mark 5
[Nov 24 09:08:13] NOTICE[2957]: chan_sip.c:23613 handle_request_invite: Call from 'didforsale_did9' (209.216.15.70:5060) to extension '13022323111' rejected because extension not found in context 'from-didforsale'.
I get the exact same thing with the line commented out ;;exten => _XX./_1609123456X,1,Goto(blacklisted,s,1)
Isn't the dialplan sequence:
1. get caller ID
2. pick up incoming DID extension (I may have the wrong terminology)
3. check caller ID for blacklist
?
You can match caller id doing something like this:
exten => s/_+252X.,n,Goto(blacklisted,s,1)
exten => s/_+1609X.,n,Goto(blacklisted,s,1)
or
exten => _XX./_+252X.,n,Goto(blacklisted,s,1)
exten => _XX./_+1609X.,n,Goto(blacklisted,s,1)
More on pattern matching:
https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching
EDIT
Example to block 1-609-123-456X, where X is any digit:
[from-Provider]
exten => _XX.,1,Set(CALLERID(num)=${CALLERID(num):1})
exten => _XX./_1609123456X,n,Goto(blacklisted,s,1)
exten => _XX.,n,GotoIf(${BLACKLIST()}?blacklisted,s,1)
exten => _XX.,n,Noop(CALLERID=${CALLERID(all)})
exten => _XX.,n,Dial(SIP/home&IAX2/droid&SIP/office)
exten => _XX.,n,Hangup()
[blacklisted]
exten => s,1,Answer
exten => s,n,Hangup
You can add also other patterns like:
_252X. (for numbers starting with 252
_96X. (for numbers starting with 96
If this will not work please add whole CLI log. Noop will show us what callerid is looking like in your PBX.
EDIT 2:
Both lines should have priority 1.
[from-didforsale]
exten => _XX./_1609123456X,1,Goto(blacklisted,s,1)
exten => _XX.,1,GotoIf(${BLACKLIST()}?blacklisted,s,1)
exten => _XX.,n,Noop(CALLERID=${CALLERID(all)})
exten => _XX.,n,Dial(SIP/home&IAX2/droid&SIP/office)
exten => _XX.,n,Hangup()
I have implemented a simple blacklist for my incoming calls. The problem I am having is that my phone is no longer ringing when a blacklister calls(this part is good), but the blacklisted phone doesn't hang up (this is the problem).
Incoming context in extensions.conf:
exten => 12225551234,1,Zapateller(nocallerid)
same => n,GotoIf(${BLACKLIST()}?hangup)
same => n,Dial(SIP/myphone)
same => n(hangup),Hangup()
Add a number to blacklist:
CLI> database put blacklist +14445554321 "Blacklisted for testing"
Call 12225551234 from blacklisted 14445554321...
As seen via CLI interface:
== Using SIP RTP CoS mark 5
-- Executing [12225551234#from-sipProvider:1] GotoIf("SIP/sipProvider_did9-00000738", "1?hangup") in new stack
-- Goto (from-sipProvider,12225551234,5)
-- Executing [12225551234#from-sipProvider:5] Hangup("SIP/sipProvider_did9-00000738", "") in new stack
== Spawn extension (from-sipProvider, 12225551234, 5) exited non-zero on 'SIP/sipProvider_did9-00000738'
== Using SIP RTP CoS mark 5
-- Executing [12225551234#from-sipProvider:1] GotoIf("SIP/sipProvider_did10-00000739", "1?hangup") in new stack
-- Goto (from-sipProvider,12225551234,5)
-- Executing [12225551234#from-sipProvider:5] Hangup("SIP/sipProvider_did10-00000739", "") in new stack
== Spawn extension (from-sipProvider, 12225551234, 5) exited non-zero on 'SIP/sipProvider_did10-00000739'
== Using SIP RTP CoS mark 5
-- Executing [12225551234#from-sipProvider:1] GotoIf("SIP/sipProvider_did9-0000073a", "1?hangup") in new stack
-- Goto (from-sipProvider,12225551234,5)
-- Executing [12225551234#from-sipProvider:5] Hangup("SIP/sipProvider_did9-0000073a", "") in new stack
== Spawn extension (from-sipProvider, 12225551234, 5) exited non-zero on 'SIP/sipProvider_did9-0000073a'
This continues until the blocked caller hangs up. Eventually, after about 50 seconds, if the caller hasn't hung up he hears ringing. I need to hang up his phone or I will be charged if he leaves the phone off the hook.
Try answering the call before hanging up. This is what I use:
exten => 12225551234,1,Zapateller(nocallerid)
same => n,GotoIf(${BLACKLIST()}?badlist,s,1)
same => n,Dial(SIP/myphone)
same => n,Hangup()
[badlist]
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(ss-noservice)
exten => s,n,Hangup
It is possible to initiate call from extension? My extension is look like the following:
[read_text]
exten => s,1,Answer( )
exten => s,n,Dial(SIP/1,G(99))
exten => s,n,Dial(SIP/2,G(99))
exten => s,n,Goto(1)
exten => s,100,System(echo '${text}' | /usr/bin/espeak --stdout |sox -t wav - -r 8000 /tmp/voice.wav)
exten => s,n,Playback(/tmp/voice)
exten => s,n,System(rm /tmp/voice.wav)
exten => s,n,Hangup( )
So if SIP/1 or SIP/2 answers, It plays text and hangup, if nobody answer it continues to Dial
I tried to make call file, but it requires some channel to be setup, I tried to use Local, but unsuccess.
I also found that there are queues, but can't find a way to initiate call to queue from call file. I'm very new to asterisk.
What your trying to do can get pretty messy from the dialplan. Try something along these lines:
[call_read_text]
exten => s,1,Dial(SIP/1,gG(read_text,s,1))
exten => s,n,Dial(SIP/2,gG(read_text,s,1))
exten => s,n,Goto(1)
[read_text]
exten => s,1,System(echo '${text}' | /usr/bin/espeak --stdout |sox -t wav - -r 8000 /tmp/voice.wav)
exten => s,n,Playback(/tmp/voice)
exten => s,n,System(rm /tmp/voice.wav)
exten => s,n,Hangup()
Dont answer the call before you start!
g will continue in the dialplan if the call isn't answered, and call the next extension
G() will jump to read_text,s,1 if the call IS answered, and end the hunt
You can jumpstart all this with a call file, by connecting the first context with the second (will happen on answer).
Something along these lines:
Channel: Local/s#call_read_text
Context: read_text
Extension: s
Priority: 1
More on call files here: http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out. Use Set: foo=bar in the call file to set ${text}