Can Asterisk be configured to accept only fixed number of concurrent calls

Hi

I need to configure Asterisk to accept only a per-configured number of concurrent calls and return error in case of the limited is reached.

The calls will be done via SIP.

For example, Configure it to accept only 20 concurrent calls and through an error on call number 21.

Hello. You can use group_count

same = n,Set(GROUP()=${myGroup})
same = n,GotoIf($[${GROUP_COUNT(${myGroup})}<=20]?lineOpen)
same = n,Hangup(21)

same =n(lineOpen),NoOp(What to do next)