AGI and Custom Context

Hi,

First of I’m new to agi and custom contexts, so bear with with me…

I was under the impression I could call an agi script, it would run then the rest of the dial plan would excute.

I have the following in extension_custom.conf

[code]
[from-did-direct]
include => from-did-direct-custom
include => ext-findmefollow
include => ext-local

[from-did-direct-custom]
exten => _.,1,Noop(from-did-direct-custom****)
exten => _.,n,AGI(support.php,${EXTEN},${CALLERID(num)})[/code]

The output from the cli when my did is called:

-- Goto (from-did-direct,608,1) -- Executing [[email protected]:1] NoOp("SIP/GammaOut-0000001d", "*****from-did-direct-custom*********") in new stack -- Executing [[email protected]:2] AGI("SIP/GammaOut-0000001d", "support.php,608,xxxxx") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/support.php -- <SIP/GammaOut-0000001d>AGI Script support.php completed, returning 0 -- Auto fallthrough, channel 'SIP/GammaOut-0000001d' status is 'UNKNOWN' -- Executing [[email protected]:1] NoOp("SIP/GammaOut-0000001d", "*****from-did-direct-custom*********") in new stack -- Executing [[email protected]:2] AGI("SIP/GammaOut-0000001d", "support.php,h,xxxxx") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/support.php -- <SIP/GammaOut-0000001d>AGI Script support.php completed, returning 0

As you can see from the above output the script is being called twice, the first time is correct and the correct varibles are being passed to the script but the second time with an h varible is being called, which I do not understand.

My extenion 608 is never rung.

Any advice would be great

Thanks in advance

Your understanding of how includes work in Asterisk is not correct.

You will want to go read up on them to get your proper flow.

As far as the “h” it is a result of eventually the call hanging up up. At that point Asterisk will look for the “h” extension which you have defined because you are using “_.” which matches everything.

I think I understand now…

When using a include like I have the call is “hijacked” and once I have finished with sending the varibles of the call to the agi script I then need to send the call on it’s way.

For example:

[from-did-direct]
include => from-did-direct-custom
include => ext-findmefollow
include => ext-local


[from-did-direct-custom]
exten => _.,1,Noop(*****from-did-direct-custom*********)
include => ext-findmefollow
exten => _.,n,AGI(support.php,${EXTEN},${CALLERID(num)})
exten => _.,n,Goto(ext-local,${EXTEN},1)

The above code seems to work for mine and other peoples DID, but when the catch all did comes into play it stops working.

After some playing around, I found I could not easily ‘Hijack’ a call before it reaches an extension to pass the caller number and destination extension number to my agi script. Is this possible?

Thanks for you help

why don’t you just send all incoming calls to your own context (via the context= statement in the trunk)

Then process your call with your custom code and then if appropriate send it down to from-pstn…

I don’t think I’m able find out what extensions will be called if I set the context in the trunk… is that correct?