How can i end the call is created by Dial command

My system has a feature that: the caller make a call and then system creates a thread to charge the caller and exec Dial command to other at the same time. When the charging is fail, i want system hangup the call created by Dial command.
I search for a long time but not found any solutions.
Help me please.
Sorry for my english.

There’s not enough information to really be able to answer it. You haven’t explained how exactly you are doing things or what you are using (AGI? AMI?).

Using AMI, it can hang up one of the channels. It can also redirect the caller to another part of the dialplan, which will implicitly terminate the Dial application.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+ManagerAction_Hangup

https://wiki.asterisk.org/wiki/display/AST/ManagerAction_Redirect

1 Like

thank for reply, i’m using asterisk java - agi :slight_smile:

i can explain like this:
user A --> asterisk --> asterisk agi server (by java) --> exec Dial command to call user B, user B answer the call (1)
–> charging money of user A (2)
(2) is the thread created when user B answered the call.
If (2) fail when user A not enought money, for example, the agi server end the call in (1).

Thank for your reply.

AGI really wasn’t written to be used quite like that, so I’m not sure if there’s a way in it to do as you state. You may have to resort to AMI as @david551 mentioned.

1 Like

excuse me, i have other question,
i’m trying using AMI, Hangup action can end the channel, but how can i get exactly the channel created by Dial command in (1).

user A --> asterisk --> asterisk agi server (by java) --> exec Dial command to call user B, user B answer the call (1)
–> charging money of user A (2)

A channel variable is set on the prmiary channel containing that information. Also there will be AMI events that contain it.

i found a solution:
using CommandAction with content: “core show channels concise”
response string with multi line, each line is an active channel, like this:
“SIP/84904628775-00000025!default!888!3!Up!Dial!SIP/84904628776, 20, tr!84904628775!!!3!31!SIP/84904628776-00000026!1560502259.37”
the SIP/84904628775-00000025 is the channel name
the SIP/84904628776-00000026 is the brigded channel - this is the channel created when user A call to extension.

so i can hangup the target channel by search refer bridged channel.

its not good solution but still resolved problem.

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