Originate a call via outbound-allroutes instead of a trunk

This question is related to How to get the return status when originating a call?

I try to originate a call via AMI which works great when i use a trunk name as context. The call first goes outbound and when the called person picks up, the person got connected to an internal extension. Now i would like to use outbound-allroutes so asterisk selects the right outbound rule / trunk itself. I guess it doesn’t work because i set up each outbound rule to only match one single extension, f.e.:

  • Outbound rule: OUT_700
  • Dial pattern:
  • Match pattern: X.
  • CallerID: 700

So the generated extensions_additional.conf looks like that:

[outrt-7] ; 700
include => outrt-7-custom
exten => _X.,1,Macro(user-callerid,LIMIT,EXTERNAL,)

exten => _X./700,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => _X./700,n,Gosub(sub-record-check,s,1(out,${EXTEN},dontcare))
exten => _X./700,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _X./700,n,Set(_NODEST=)
exten => _X./700,n,Macro(dialout-trunk,23,${EXTEN},,off)
exten => _X./700,n,Macro(dialout-trunk,4,${EXTEN},,off)
exten => _X./700,n,Macro(outisbusy,)

Now if i originate the call, this happens on CLI:

-- Called [email protected]
	-- Executing [[email protected]:1] Macro("Local/[email protected];2", "user-callerid,LIMIT,EXTERNAL,") in new stack
	-- Executing [[email protected]:1] Set("Local/[email protected];2", "TOUCH_MONITOR=1459437919.4929") in new stack
	-- Executing [[email protected]:2] Set("Local/[email protected];2", "AMPUSER=01234567") in new stack
	-- Executing [[email protected]:3] GotoIf("Local/[email protected];2", "0?report") in new stack
	-- Executing [[email protected]:4] ExecIf("Local/[email protected];2", "1?Set(REALCALLERIDNUM=01234567)") in new stack
	-- Executing [[email protected]:5] Set("Local/[email protected];2", "AMPUSER=") in new stack
	-- Executing [[email protected]erid:6] GotoIf("Local/[email protected];2", "0?limit") in new stack
	-- Executing [[email protected]:7] Set("Local/[email protected];2", "AMPUSERCIDNAME=") in new stack
	-- Executing [[email protected]:8] GotoIf("Local/[email protected];2", "1?report") in new stack
	-- Goto (macro-user-callerid,s,15)
	-- Executing [[email protected]:15] GotoIf("Local/[email protected];2", "1?continue") in new stack
	-- Goto (macro-user-callerid,s,28)
	-- Executing [[email protected]:28] Set("Local/[email protected];2", "CALLERID(number)=01234567") in new stack
	-- Executing [[email protected]:29] Set("Local/[email protected];2", "CALLERID(name)=Mister Smith") in new stack
	-- Executing [[email protected]:30] Set("Local/[email protected];2", "CDR(cnum)=01234567") in new stack
	-- Executing [[email protected]:31] Set("Local/[email protected];2", "CDR(cnam)=Mister Smith") in new stack
	-- Executing [[email protected]:32] Set("Local/[email protected];2", "CHANNEL(language)=de") in new stack
	-- Auto fallthrough, channel 'Local/[email protected];2' status is 'UNKNOWN'

I tried to set EXTEN=700 or DID=700 by fputs($oSocket, “Variable: DID=$ext\r\n”); but it doesn’t help.

@ladiko Have you tried just originating a call without matching on the caller id? Does that work properly?

sure, i first tried it without any DID or EXTEN variable, as i thought it might be set somehow auto-magically. The CLI output is exactly the same. I guess i have to go through the dialplan starting from outbound-allroutes and see where it fails.

if i run sudo asterisk -rx "originate Local/[email protected] extension [email protected]" in bash, the CLI outputs:

Asterisk 13.8.0, Copyright (C) 1999 - 2014, Digium, Inc. and others.
Created by Mark Spencer <[email protected]>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 13.8.0 currently running on asterisk (pid = 17556)
	-- Remote UNIX connection
	-- Remote UNIX connection disconnected
	-- Called [email protected]
	-- Executing [[email protected]:1] Macro("Local/[email protected];2", "user-callerid,LIMIT,EXTERNAL,") in new stack
	-- Executing [[email protected]:1] Set("Local/[email protected];2", "TOUCH_MONITOR=1460381222.651") in new stack
	-- Executing [[email protected]:2] Set("Local/[email protected];2", "AMPUSER=") in new stack
	-- Executing [[email protected]:3] GotoIf("Local/[email protected];2", "0?report") in new stack
	-- Executing [[email protected]:4] ExecIf("Local/[email protected];2", "1?Set(REALCALLERIDNUM=)") in new stack
	-- Executing [[email protected]:5] Set("Local/[email protected];2", "AMPUSER=") in new stack
	-- Executing [[email protected]:6] GotoIf("Local/[email protected];2", "0?limit") in new stack
	-- Executing [[email protected]:7] Set("Local/[email protected];2", "AMPUSERCIDNAME=") in new stack
	-- Executing [[email protected]:8] GotoIf("Local/[email protected];2", "1?report") in new stack
	-- Goto (macro-user-callerid,s,15)
	-- Executing [[email protected]:15] GotoIf("Local/[email protected];2", "1?continue") in new stack
	-- Goto (macro-user-callerid,s,28)
	-- Executing [[email protected]:28] Set("Local/[email protected];2", "CALLERID(number)=") in new stack
	-- Executing [[email protected]:29] Set("Local/[email protected];2", "CALLERID(name)=") in new stack
	-- Executing [[email protected]:30] Set("Local/[email protected];2", "CDR(cnum)=") in new stack
[2016-04-11 15:27:02] WARNING[19109]: func_cdr.c:377 cdr_write_callback: CDR requires a value (CDR(variable)=value)
	-- Executing [[email protected]:31] Set("Local/[email protected];2", "CDR(cnam)=") in new stack
[2016-04-11 15:27:02] WARNING[19109]: func_cdr.c:377 cdr_write_callback: CDR requires a value (CDR(variable)=value)
	-- Executing [[email protected]:32] Set("Local/[email protected];2", "CHANNEL(language)=de") in new stack
	-- Auto fallthrough, channel 'Local/[email protected];2' status is 'UNKNOWN'

Does it work for others?

This is where the call dies. It’s already loaded and executed your outbound routes, the call is dieing during the caller Id macro where it’s setting the outbound caller ID which as you can see here is completely empty. You should send the caller id and see what happens.

Do you mean i should set CALLERID(number)=700 ?