Calling AGI from AMI


I need to do a kind of auto-Dialer. The thing is that calls will be originate from nowhere, so I can’t use AGI for that. I must use AMI for create a connection to Asterisk first.

So, I’m using PHP for this but once I connect to my Asterisk, I don’t know how to execute an AGI for make calls. Google :smile: didn’t help me to find an example for this.

Is it possible to call an AGI from AMI? I want to execute a file wich will have the “dial” things.
How I do that?
Should I execute the file from the “commands” line?

function managerLogin()
        $socket = fsockopen("","5038", $errno, $errstr);

        fputs($socket, "Action: Login\r\n");
        fputs($socket, "UserName: test\r\n");
        fputs($socket, "Secret: test\r\n\r\n");
        fputs($socket, "Events: on\r\n\r\n");

while (managerLogin())
        fputs($socket, "Action: AGI\r\n");
        fputs($socket, "Channel: \r\n");
        fputs($socket, "Commands: \r\n\r\n");




I hope this isn’t bulk marketing or debt collection.


I hope this isn’t bulk marketing or debt collection.[/quote]
No, it’s only for internal purposes.

david, if I use Originate, I can’t figure out how to catch channel status like such as: ${ANSWEREDTIME}, ${HANGUPCAUSE}, etc.

When I use Originate, I don’t know where catch this. Should I use AGI? but where?

Should I originate the call and call and AGI? that’s my question.


For failed party A calls, wrap the call in a local channel.

The party B side is normal dialplan.