PHPAGI program to dial number

Hey ,I am using PHPAGI to dial any number .Below is the code that i am using to dial any number.
While initiating call i am using M option with dial application.But when customer answer the call ,macro-context is being called from agi file .I dont want to go to dialplan to perform any action during answer.I want to call api when agent answer the call in agi file only.
Is there any way to deal with this ?Below is the line i am using to dial number and i have attached code file also.

Help me to resolve .Thanks :blush:

$agi->exec(“dial”, “SIP/1001/XXXXXXX735,30,M(Answer)”);

call.txt (2.6 KB)

Why can not you perform another AGI script in macros? M invokes a macros in which you can call your API. Or your aim is not to use a dialplan at all?

my aim is not to use dialplan at all.do you have any soution or suggestion?

In this case i advise you to use AMI protocol. Your PHP script connects to the Asterisk using AMI protocol and waits for Event: Bridge or Event: Link event, which means called party has allready picked up the phone. But keep in mind that you need to determine a call is yours or not. Because your script will receive such event of all calls on Asterisk.

Here is an example of Event: Bridge:

Event: Bridge
Privilege: call,all
Bridgestate: Link
Bridgetype: core
Channel1: SIP/1001-0007656d
Channel2: SIP/trunk_number_one-0007656e
Uniqueid1: 1580980305.484739
Uniqueid2: 1580980306.484740
CallerID1: 1001
CallerID2: XXXXXXXXXXXX

You need to parse this data to determine whether this event of your call.

By the way, there is a connection using AMI which is never used $agiAsteriskManager = new AGI_AsteriskManager(); in your attached file.

I got your point but i still confuse how to use this in php script.If you don’t mind ,can you explain it through php script.

Why do you not want to use dialplan (as this can be achieved easily from there)? You are calling this agi from dialplan itself so adding one more context for macro wouldn’t hurt.
Personally I would use option U (for subroutine) instead of M as Macros are deprecated now

Thanks satish for your reply. I am new to php and whatever i am learning ,trying to implement it .I will go for Macro and call other agi file.I thought may be something is there in AGI feature which will indicate that call is answered that i don’t know ,that’s why i have asked this question in Asterisk community so that you guys can solve or suggest something to resolve my concern.

Thanks for your valuable suggestion. :grinning:

AGI is not a substitute of the dialplan, and unexpected results canbe found, when trying to replace the dial plan at all using AGI, this is the beauty and the real power of AGI when combining Asterisk commands and functions with external AGI programming.

Also as @satish4asterisk says at the end you are using the dial plan at least to call your AGI, take the advise and replace Macro by Sub

Thanks dear,I will go for Sub instead of Macro.Thanx for valuable suggestion. :blush:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.