How to set dial options in Asterisk callfile - asterisk

I'm already making calls from file, but I want to put TtM(MyMacro) dial options. The call file haves these properties:
$callFileOptions = "Channel: SIP/Algar_AMD/$phoneNumber
\nCallerid: $phoneNumber
\nMaxRetries: 0
\nRetryTime: 1
\nWaitTime: 30
\nContext: from-internal
\nExtension: $internalExtension
\nPriority: 1";
This configuration will make external call first and when answered it will be transferred to internal extension.
I've tried to change the Channel property to SIP/Algar_AMD/$phoneNumber,300,TtM(MyMacro), SIP/Algar_AMD/$phoneNumber,,TtM(MyMacro) and SIP/Algar_AMD/$phoneNumber|TtM(MyMacro), but to no avail.
MyMacro will execute the AMD application to detect machine/human answer.

Got it!
My macro at extensions_custom.conf is this
[macro-AsteriskMachineDetection]
exten => s,1,BackGround(en/silence/05);
same => n,AMD(3500,630,600,5000,110,50,5,750,5000);
same => n,NoOp(AMDSTATUS = ${AMDSTATUS} - NUMBER = ${CALLERID(number)} - CAUSE = ${AMDCAUSE});
same => n,GotoIf($[${AMDSTATUS}=MACHINE]?machine:human);
same => n(machine),Macro(hangupcall,);
same => n(human),Dial(Local/${EXT_DEST});
and I've changed the callfile configuration to this:
$callFileOptions = "Channel: SIP/Algar_AMD/$phoneNumber
\nCallerid: $phoneNumber
\nMaxRetries: 0
\nRetryTime: 1
\nWaitTime: 30
\nContext: from-internal
\nExtension: $internalExtension
\nSetvar: EXT_DEST=$internalExtension
\nApplication: Macro
\nData: AsteriskMachineDetection
\nPriority: 1";
Edit:
$callFileOptions = "Channel: SIP/Algar_AMD/$phoneNumber
\nCallerid: $phoneNumber
\nMaxRetries: 0
\nRetryTime: 1
\nWaitTime: 30
\nSetvar: EXT_DEST=$internalExtension
\nApplication: Macro
\nData: AsteriskMachineDetection
\nPriority: 1";

Related

Asterisk 11.7 Matching on Caller ID

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]

Asterisk, blacklisted number won't hang up

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

Multiple SendDTMF extension in asterisk

Good day, I need type extension after dial, I wrote a macros and use it in Dial command, for example:
Dial(Local/123123#outbound-allroutes,,M(sendnum^5^123)
[macro-sendnum]
exten => s,1,Wait(${ARG1})
exten => s,n,SendDTMF(${ARG2})

But sometimes I need type several ext. numbers, how can I do that?
I guessed pass more params in macros at first param is count of IVR steps, and other params are options for steps then in macros process those params in loop, for example:
Dial(Local/123123#outbound-allroutes,,M(sendnum^2^5^2010^6^123)
and macros for this:
macro-sendnum]
exten => s,1,Set(TIMES=${ARG1})
exten => s,n,Set(i=0})
exten => s,n,While($[${i} < ${TIMES}])
exten => s,n,Set(i=$[ ${i} + 1 ])
exten => s,n,Wait(${ARG$[${i} + 1]})
exten => s,n,SendDTMF(${ARG$[${i} + 2]})
exten => s,n,EndWhile
But that doesn't work. Could you please help me? Thank you in advance and sorry for my bad endgish.
pro-sip*CLI> core show application SendDTMF
-= Info about application 'SendDTMF' =-
[Synopsis]
Sends arbitrary DTMF digits
[Description]
It will send all digits or terminate if it encounters an error.
[Syntax]
SendDTMF(digits[,timeout_ms[,duration_ms[,channel]]])
[Arguments]
digits
List of digits 0-9,*#,a-d,A-D to send also w for a half second pause,
and f or F for a flash-hook if the channel supports flash-hook.
timeout_ms
Amount of time to wait in ms between tones. (defaults to .25s)
duration_ms
Duration of each digit
channel
Channel where digits will be played
So you can use 'w' as pause.

Puppet syncing dir

Still does not work
In/etc/puppet/manifests/site.pp
file { "/home/render/installation/":
ensure => "directory",
owner => "render",
group => "render",
recurse => "true",
mode => "0750",
source => "puppet:///files/installation/",
}
Dir still is empty on client
ls /etc/puppet/files/installation/
1 2 3 4 5
On puppet client in log
Mar 21 12:28:12 lw-003 puppet-agent[28098]: (/File[/home/render/installation/]) Failed to generate additional resources using 'eval_generate: Error 400 on SERVER: Not authorized to call search on /file_metadata/files/installation with {:checksum_type=>"md5", :recurse=>true, :links=>"manage"}
Mar 21 12:28:12 lw-003 puppet-agent[28098]: (/File[/home/render/installation/]) Could not evaluate: Error 400 on SERVER: Not authorized to call find on /file_metadata/files/installation Could not retrieve file metadata for puppet:///files/installation: Error 400 on SERVER: Not authorized to call find on /file_metadata/files/installation
Mar 21 12:28:12 lw-003 puppet-agent[28098]: Finished catalog run in 0.28 seconds
I had the same issue and found this question on Google. I had to change the path to the files for the manifests (modulename/manifests/init.pp):
"puppet:///files/installation/",
to:
"puppet:///modules/files/installation/",
The notation without /modules/ was deprecated in 2.7 and no longer supported in newer versions:
DEPRECATION NOTICE: Files found in modules without specifying 'modules' in file path will be deprecated in the next major release. Please fix module 'modulename' when no 0.24.x clients are present
try this example,
file {
"/scratch/usern/testmod" :
ensure => directory,
source => "puppet:///files/testmod",
recurse => true,
owner => "usern",
group => "groupn",
mode => "0775",
backup => false,
}
You have to specify 'files' and if you are doing a recursive copy, specify 'recurse => true'. That might be the solution to your problem.
the 'fileserver.conf' should look something like the following :
]# cat /etc/puppet/fileserver.conf
[files]
path /etc/puppet/files
allow *

Error using GotoIf in a dialplan

I am trying to implement a complex dialplan that requires interaction with the user. Based on this interaction, the dialplan jumps to another part. Some sample code is given below:
[test]
;This is a test.
exten => 0,n(qa1),NoOp()
exten => 0,1,Verbose(1, "This is a test")
exten => 0,n,Set(USER_ANSWER=0)
exten => 0,n,Read(USER_ANSWER,,1,,2,10)
exten => 0,n,Verbose(1, "User keyed in ${USER_ANSWER}")
exten => 0,n,GotoIf($[$["${USER_ANSWER}"="1"] | $["${USER_ANSWER}"="2"]]?eval1:qa1)
exten => 0,n,Verbose(1, "User keyed in ${USER_ANSWER}")
exten => 0,n(eval),NoOp()
...
On running the above code, asterisk hangs up after evaluating the GotoIf condition above. The error messages are as follows:
-- User entered '1'
-- Executing [0#test:19] Verbose("DAHDI/13-1", "1, "User keyed in 1"") in new stack
"User keyed in 1"
-- Executing [0#test:20] GotoIf("DAHDI/13-1", "1?eval1:qa1") in new stack
-- Goto (test,0,21)
-- Executing [0#test:21] NoOp("DAHDI/13-1", "") in new stack
[Jan 25 10:47:48] WARNING[29738]: pbx.c:3677 pbx_extension_helper: No application 'If' for extension (test, 0, 22)
My questions are:
What does that error message mean?
How can I correct it so it works?
The GotoIf is invoked correctly. The label eval1 has If statements following it. Asterisk does not have If statements. Replacing the If statements with ExecIf did the trick. One can figure out what commands are available by typing, at the Asterisk CLI prompt, the following command:
core show application <command name here>
If the above command returns an output, then that command is available, else not.

Resources