SIP GROUP() adding our SIP phones on incoming calls

We’re using for our SIP trunks (2 currently). And we need a way to make sure that no one can dial out when both trunks are in use. I’m trying to use GROUP() to keep track of connections, but it also adds phones, and adds a whole lot of them when it dials Queue agents. This causes the SIPGROUP variable to get reset to 0 or an inaccurate number.

The reason we need this is because if both trunks are in use and someone tries to dial out, a call goes to one-way audio. This happens 100% of the time and’s support said ‘We don’t help with configuration’ and their documentation is lackluster at best. Is anyone in the same situation that has a working configuration for keeping track of channels?

Ideally, I’d only want to add to the group, since that’s the real peer and if we have 2 connections from them, then we can’t make anymore. Thanks.

exten = _NXXNXXXXXX,n,GotoIf($[${GROUP_COUNT(SIPGROUP)} >= 4]?100) ;If the group has 2 or more calls, do not dial.
;4 is used because each phone is a channel as is each call.
exten = _NXXNXXXXXX,n,Dial(${OUT_2}/+1${EXTEN},60)
exten = _NXXNXXXXXX,100,Playback(all-circuits-busy-now)
exten = _NXXNXXXXXX,101,congestion()
exten = _NXXNXXXXXX,102,busy()

exten = _NXXNXXXXXX,n,Set(CALLERID(num)=1${CALLERID(num)})
exten = _NXXNXXXXXX,n,Goto(voicemenu-custom-1|s|1)