For counting the calls in asterisk , you can use the Group() dialplan function from asterisk dialplan.

To add a call to the group function, use this dialplan application


To view the call count, use the dialplan application



Below dialplan example shows you how to use the group function to limit the total call count to 10 in your asterisk box


exten => _X.,1,Set(GROUP()=call_count)

exten => _X.,n, Noop(Total number of calls : ${GROUP_COUNT(call_count)})

exten => _X.,n,GotoIf($[${GROUP_COUNT(call_count)} < 11]?continue:hang)

exten => _X.,n(continue),Noop()

; Add your dialplan here to handle calls when the call count is below 11

exten => _X.,n(hang),Hangup

Share This