AMI Originate a call to IVR?


I am using asterisk 10 with FREEPBX (which kind of locks down the extension files)

I’d like to originate an External call and connect it automatically to a specific IVR I create in FreePBX.

Can someone please help.

This will call the # 16305555555, but when i answer it just hangs up.

Action: Originate
Channel: SIP/16305555555@flowroute
Context: greetingivr
Priority: 1
CallerID: 6305551234
Async: yes

The greetingivr is just setup in my freepbx ivr module. Please assist, I don’t know where to start on this one!


I figured it out after far too many hours!

Here are the details incase anyone else has the same issues. First the issue is I wanted to automate voice broadcast campaigns where we could contact people by taking numbers from our database and dialing them, playing information, and then after it was completed give them the option if they wanted to speak to someone press 1 and then put it in a queue.

my setup is Freepbx and asterisk 10.

First things first, is I needed to setup the dial plan and context. This was a big issue since it DID NOT work by specifying an extension. It would just hang up, so what I did instead was use “s”

here is the actual dial plan, and I put it in extensions_custom.conf:

exten => s,1,Answer()
exten => s,n,Wait(1)
exten => s,n,Playback(hello-world)
exten => s,n,Wait(1)
exten => s,n(dest-ext),Goto(ivr-2,s,1)
exten => s,n,Hangup()

WHat this does is answer the call, play HELLO-WORD, wait then transfer to the ivr.

The ivr was found by opening up the extensions_additional.conf and finding what freepbx labled it as [ivr-2] ;campaign ivr .

Then reload the dialplan by typing

asterisk -rx “dialplan reload”

and last but not least here is the command I send to AMI

Action: Originate
Channel: SIP/16305555555@flowroute
Context: call-file-test
Extension: s
Priority: 1
CallerID: 6305755555
async: yes

this now dials 6305555555 plays hello world, then goes to and plays the IVR I setup where the end user on the outside world can be connected into our QUEUE by pressing 1.

The biggest issue I had was for some reason I could not use an EXTENSION #, I needed to use “s”, but everything works!

Hope this saves someone else some time! Now I simply have a .net program on my front end that I can query my database and send each call to ami.

This can be done easily using AMI or simple PHP AGI.

This the code that im using for originate a call using a PHP agi Script

<?php $cmd= "/usr/sbin/asterisk -rx \"originate SIP/100 extension 18002884587@extensiones\" "; system($cmd); ?>

This is my code using php and AMI

<?php $extension='102'; //where 9999 is the extension you would like to call $socket = fsockopen("","5038", $errno, $errstr, $timeout); fputs($socket, "Action: Login\r\n"); fputs($socket, "UserName: admin\r\n"); // default username and password for TrixBox users fputs($socket, "Secret: 123\r\n\r\n"); // for other Asterisk platforms plase get your username and // password from /etc/asterisk/manager.con $wrets=fgets($socket,128); echo $wrets; fputs($socket, "Action: Originate\r\n" ); fputs($socket, "Channel: SIP/$extension\r\n" ); fputs($socket, "Exten: 4443\r\n" ); fputs($socket, "Context: extensiones\r\n" ); fputs($socket, "Priority: 1\r\n" ); fputs($socket, "Async: yes\r\n\r\n" ); fputs($socket, "Action: Logoff\r\n\r\n"); sleep (1); $wrets=fgets($socket,128); ?>

Both code are working fine just set the propper permision and config the Asterisk manager config or if if you will use the php script just adjust the permision on the asterisk.conf

Actually, I put down the proper method that works. I was not looking on how to originate a call, I was looking at how to do the following

  2. When Answered Connect to IVR

The steps you provided will not connect an outbound EXTERNAL call to a internal IVR.

I did not have any issue originating a call between two extensions, that worked without issue. I posted the steps used on how to resolve in my response a few days ago…

Thanks though!