$astman originate example?

Using freePBX Distro 12.0.76.2. Based on all the docs I have found, the following should work:

<?php if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) { include_once('/etc/asterisk/freepbx.conf'); } global $astman; $call_data = array( "Channel" => "SIP/[email protected]", "CallerID" => "14408", "Context" => "ext-local-custon", "Exten" => "231144808", "Priority" => "1"); $astman->Originate($call_data); $astman->log("Called with: $call_data", 1); ?>

However, it does not originate the call. All I see in the CLI with verbosity and debug on 30 is:

[2015-10-18 14:13:39] DEBUG[48771]: manager.c:5271 process_message: Running action ‘Login’
[2015-10-18 14:13:39] DEBUG[48771]: manager.c:5271 process_message: Running action ‘Originate’
Nothing in the freepbx.log.
Seems like I’m not passing the channel variables correctly. Does anyone have an example?

Thanks!

Context needs to be from-internal
Channel needs to be Local/335298@from-internal

Thanks, Andrew.

I changed the context, but it made no difference in output. When I telnet to AMI, the following works perfectly:

ACTION: Originate
CallerID: 14408
Channel: SIP/[email protected]
Context: ext-local-custom
Exten: 231144808
Priority: 1

The call completes correctly. Now I just need to do that in PHP. Do you have an examples of using $astman->Originate($call_data); ? Is my array OK as a param for $astman?

You didn’t read my post. Please reread what I posted.

Hi, Andrew.

I did read your post, and I changed the Context to “from-internal” and the Channel to “Local/335298@from-internal” but I got the same result. Just says, “Originate” in the CLI.

If I put this into AMI, the call fails.

ACTION: Originate
CallerID: 144808
Channel: Local/335298@from-internal
Context: from-internal
Exten: 335298
Priority: 1

If I put this into AMI, the call works as expected and the MWI state is changed:

ACTION: Originate
CallerID: 144022
Channel: SIP/335299@BCCMNP02
Context: ext-local-custom
Exten: 231144022
Priority: 1

This call is outbound to a Cisco Call Manager trunk 10.44.1.11 (I can also use the trunk name, like SIP/335298@BCCMNP02). Extension 335298 turns the MWI light on for CallerID 14408.

My understanding is the tech has to be SIP because BCCMNP02 is a SIP trunk.

When I use Local/335298@from-internal in AMI, the MWI on target extension does not change.

I can do it in the dialplan with

Set(CALLERID(num)=144808)
Dial(SIP/[email protected])

I need to do this in PHP though.

Also, note the last line of my code:

$astman->log("Called with: $call_data", 1);

Shouldn’t that produce some output in spite of whatever the context is?

Thanks for your help.

OK, I got it working. Set extension to “s” and context default:

<?php
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
      include_once('/etc/asterisk/freepbx.conf');
}
global $astman;
$call_data = array(
	"Channel" => "SIP/335298@BCCMNP02",
	"CallerID" => "144808",
	"Context" => "default",
	"Exten" => "s",
	"Priority" => "1");
$astman->Originate($call_data);
$astman->log("Called with: Channel: Local/[email protected], CallerID: 144808", 1);
?>

However, the last line, which I believe should produce output on the CLI with verbosity over 1, still produces no output.

Any ideas on that?

This is still very incorrect. I have no idea what “default” context is. Something you added perhaps.

Working example on thousands of systems:

I used the “default” context and “s” extension because $astman refused to originate without a context and extension, and any real extension and context confuses it. They do nothing. All asterisk needs to make the call is the tech/data line for channel, but I have to set callerID so Cisco Call manager knows which MWI to change state. The default context is explained in extensions.conf:

;-------------------------------------------------------------------------------
; default
;
; FreePBX does not use the default context. This context is used by asterisk when
; it has no other information provided and needs to deliver a call. Hitting this means
; there has been some sort of configuration error, or a potential bug somehwere.
; This context can be reached from either internal or external sources.
;
[default]
include => ext-local
exten => s,1,Playback(vm-goodbye)
exten => s,n,Noop(ERROR: FreePBX Does not use the [default] context, confguration error)
exten => s,n,Macro(hangupcall)
;-------------------------------------------------------------------------------

Thanks for the reference for home class, but as you can see that would not work in my case. The extension I am calling does not exist in any context in freePBX, it’s just a Cisco Call Manager extension I pull from a database.

So, any idea why the line

$astman->log("Called with: Channel: Local/[email protected], CallerID: 144808", 1);

produces no output on the CLI?