Stop Dialplan Execution

Hi

We have a realtime Asterisk configuration for each extension, which is similar to below:
1 AGI call_inbound.agi|reception|8
2 AGI call_inbound.agi|all|12
3 Voicemail 200@internal|su

The problem is that when somebody calls this extension (reception) and it gets answered, when the person at that extension hangs up, the second priority (all) is still executed unless the caller hangs up as well.

CLI shows in realtime exactly what’s described above, i.e.:

-- Executing AGI("SIP/ip.ip.ip.ip-085f22f8", "call_inbound.agi|reception|8") -- Launched AGI Script /var/lib/asterisk/agi-bin/call_inbound.agi -- AGI Script Executing Application: (Dial) Options: (SIP/200|8) -- Called 200 -- SIP/200-0862abe0 is ringing -- SIP/200-0862abe0 answered SIP/ip.ip.ip.ip-085f22f8 -- Packet2Packet bridging SIP/ip.ip.ip.ip-085f22f8 and SIP/200-0862abe0 -- AGI Script call_inbound.agi completed, returning 0 -- Executing AGI("SIP/ip.ip.ip.ip-085f22f8", "call_inbound.agi|all|12") -- Launched AGI Script /var/lib/asterisk/agi-bin/call_inbound.agi -- AGI Script Executing Application: (Dial) Options: (SIP/201|12) -- Called 201 -- SIP/201-085e4930 is ringing

We tried adding Hangup command at the end of the agi script, however the next priority still gets executed regardless. We also tried adding Hangup command as a 4th priority, but that didn’t make any difference. Would anyone be able to point in the right direction of using a Hangup command, or perhaps show an example of working Hangup command within the agi script please?

We are having the same issue with both Asterisk 1.4.20 and 1.8.

Many thanks!

If you use a dialplan, it will stop after the first outgoing call that gets answered.

Your problem almost certainly lies in the AGI scripts which you have not provided.

This is why the dialplan has not stopped:

AGI Script call_inbound.agi completed, returning 0

For it to stop, the application (AGI in this case) must returna non-zero return code.

Thanks a lot David - appreciate your help! Indeed our script returns 0 upon exit. Could you please confirm that it should return -1 to prevent the following priority from executing?

My quick reading of the code indicates that doing that will result in AGISTATUS being set to FAILURE, but the AGI application returning zero. You will probably have to do something in the script, or check AGISTATUS after it returns.

The easiest thing is probably to try it.

Are you sure you need to use AGI. A lot of things, even database access, can be done in pure dialplan code.

Although I haven’t tried it, I would expect if you tested the result of EXEC Dial for non-zero and executed the AGI HANGUP command, it ought to work.