How to HangUp a call when we know the extension

Hello,
I’m using AMI to write a code to hang-up an extension’s call.
All I know is: Extension’s number

While the AMI’s HangUp() only accepts channels (call unique id).
Is it possible to get the channel name (or call’s unique id) for a particular extension?

Thank you in advance,
Behzad

Ok. How can I get the channel’s name when I know a call’s unique id?

I found a solution finally.

What we know: CALL’s UNIQUE ID.
What we want: CALL’s Channel name.

Run @ CLI: show channels (This displays list of active channels)
For each of the channels, run: show channel xxxx (where xxx is a channel name). This command displays details of the requested channel, including call’s unique id. This is how I wrote a script in Python to determine a channel’s name based on the call’s unique id.

alternatively you can use AMI to capture the newChannel event which will give you everything you need. It just gets a little complicated because you have to build a state engine to keep track of all the channels going up and down.

certainly doable though.

[quote=“g2010”]alternatively you can use AMI to capture the newChannel event which will give you everything you need. It just gets a little complicated because you have to build a state engine to keep track of all the channels going up and down.

certainly doable though.[/quote]

That’s an interesting idea. Thank you.