<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>After originating a PJSIP call, I need to get the channel for that call, so I can end it later in a hangup handler.</div><div>So I use this:</div><div><br></div><div><a href="https://wiki.asterisk.org/wiki/display/AST/Function_CHANNELS">https://wiki.asterisk.org/wiki/display/AST/Function_CHANNELS</a><br></div><div><br></div><div>In this bit of dialplan:</div><div><br></div><div>    same => n,Originate(PJSIP/0203123456@voipfone-205,exten,bcab-bridge-conference,s,1)</div><div>    same => n,Verbose(1,***CHANNELS ARE ${CHANNELS()})</div><div>    same => n,SET(GLOBAL(chan)=${CHANNELS(PJSIP\/voipfone-205-(.*))})</div><div><br></div><div>Now, of course, I get more than one channel shown, like this:</div><div><br></div><div>***CHAN WE WANT IS PJSIP/voipfone-205-00000249 PJSIP/voipfone-205-0000024c PJSIP/voipfone-205-0000024d<br></div><div><br></div><div>Assuming I use CUT to trim out the first in the list, can we ALWAYS be absolutely sure that the channel just created by Originate is the highest numbered/first in list?</div><div><br></div><div>Otherwise, I'm wondering if there's a reliable way to get the channel created by originate, when there may be many other active channels on the system, too.</div><div><br></div><div>In case anyone's wondering, I'm using it so that when there is only one party left in a conference, it'll clear down the newly created external channel.</div><div>For which I need the outgoing name, of course...</div><div><br></div><div><div>    same => n,GotoIf($["${CONFBRIDGE_INFO(parties,1234)}" = "1"]?hangchan)</div><div>    same => n,Return()   </div><div>    same => n(hangchan),SoftHangup(${GLOBAL(chan)}) </div></div></div></div></div></div></div></div></div>