Cancel ringing call from call file or originate

Is there a way to cancel/hangup a call that is currently ringing that was generated from a call file or originate command?

I know theres a softhangup() but that requires a channel and only way I know to get that is after the call is answered using the channel variable.

Did you try using AMI?

How would I go about hanging up a ringing channel? I see hangup command but I don’t know how to get the channel while its ringing.

Why are you trying to do this. That will give a clue as to the best way to identify the channel name (although, in principle, you look at the AMI events). It might also indicate that you really need a time limit, not a cancel.

Also, this is the wrong forum for support questions.