Tackling AMI/PHP issue - Originate and CallerID

Hello Everyone, :mrgreen:

Here is what I want to do:
Allow a user to dial a number through browser. Index.php will ask for user phone number ($x), party phone number ($y), and caller id number ($z). Then process the call to $x and give him ringtone of calling to $y with caller id $z as provided by the user on the form.

Here is what I have done so far:
Explored floAPI (phpclasses.org/browse/package/2521.html) and here is my dial request in a php file:

Vairables $x and $y are typed by user when they browes to index.php and so this works beautifully.

Here is my problem and question to you:
1- The above method works for calling but it has a BIG flaw. Asterisk calls both parties simultaneously leading to confusion if one party picks up later than the other. In fact Asterisk should dial party $x first because they initiaed the call and once they pickup then dial party $y. How can I overcome this problem in originate command? do a channel status check? how? I am pretty new to this so maybe there is even a whole new approach through phpagi???!!! or something else.

2- I know that originate through AMI should be able to pass CallerID and Async variable but I am not sure how to do it with floAPI. Any leads would be much appreciated.

3- I am also confused about phpagi and floAPI. Maybe someone can shed a bit of light there. Is floAPI an application that does the dirty work for connecting to Asterisk AMI? I have used it to run any CLI command possible on Asterisk and it works. While if I do a “manager show commands” then I come up with different set of commands. Which way should I take? phpagi or floAPI? I am totally confused.

Note:

spits out different instructions than those of:

from Asterisk CLI, leading me to beleive they are two different things?! Or are they? and that floAPI uses originate and not manager originate command. Please correct me if I am wrong. That’s also when I get stuck with Caller ID because I don’t know how to pass caller id variable along with originate.

Thanks a bunch

I am pretty certain that originate will not start the application/dialplan side until the channel is up, so both calls will not be made at once.

To set the CLI, use a dialplan, rather than running Dial directly and pass in a parameter with the Originate.

Caution: allowing users to specify CLI is open to abuse, and many public network providers will not allow arbitrary CLIs to be set.

According to the voip-info page on API originate, does connect one channel first, then the second. You, however, are not using API originate, but CLI originate which is under-documented on that site.

In API (or AMI, I think it was renamed), COMMAND executes a CLI command. What you have entered into the php api class would result in the following being sent to API:

ACTION: COMMAND command: originate SIP/Trunk/5555555555 application Dial SIP/trunk/5555555556
Thus executing the CLI Originate with the paramater “SIP/Trunk/5555555555 application Dial SIP/trunk/5555555556”. The CLI originate examples use an extension (which can easily be configured to dial). But, why use the CLI, when there’s an API originate available?

$originate_attack_plan = array( "Channel" => "SIP/Trunk/$x", "Context" => "default", "Exten" => "$y", "Priority" => "1", "Timeout" => "30000", "Callerid" => "$x" ); $sampleapi->request("ORIGINATE", $originate_attack_plan);
Clearly, you’d have to make a context and extention that would check and dial whatever you passed it. (You’ll have to adjust that to your needs; I do not have an Asterisk server at the moment to verify the syntax of that code.)

Now, having said all this, I believe that the reason that you are getting this immediate dial result (irrelevant of using the API to open a CLI command) is because of passing it directly do the dial application and not to an extension. Try passing to an extension instead of the dial application and see if that helps. I think the extensions are configured to not proceed until connection and dial may not be.

Whoever Bruce is (who illuminated me to this topic via email, torontob, I presume), I would like to mention that floAPI is not actively maintained, per se (because I no longer work regularly with Asterisk), however, whenever bugs are found with any of my classes on phpclasses.org and told to me by the mechanisms available there (or email or any other successful communication with me), I do take care of them. Though technically, I’ve never heard of any bugs in this class so far.

Thanks for the detailed reply Joshua/flobi. This clears up a lot for me. Will test this out and report if I need further help.

Best Regards,

Hello,

Using the above method for originate doesn’t call. I am wondering if there is a syntax problem?!

Thanks