Outbound Calling: Rate Limit or Queue (Not a Call Queue)

@david551

At first, I wasn’t sure what you’re suggesting. But found a solution after giving it a little thought.

By setting the GROUP_COUNT() resource as ${EPOCH}, I can count the calls placed in the current second.

From there, it’s a simple regular expression to determine if the number of calls exceeds the target calling rate.

Sending calls that exceed the target to another context to wait for a fraction of a second, before trying again.
Otherwise, the call continues and will Dial() the providers trunk.

[globals]
calls_per_sec=20

[OUTBOUND]
exten => _X.,1,NoOp(Rate Limited Calling)
 same => n,Set(GROUP()=${EPOCH})
 same => n,GotoIf($[${GROUP_COUNT(${EPOCH})}>${calls_per_sec}]?DELAY,${EXTEN},1)
 same => n,Dial(SIP/provider/${EXTEN})
 
[DELAY]
exten => _X.,1,NoOp(Half Second Delay)
 same => n,Wait(0.5)
 same => n,Goto(OUTBOUND,${EXTEN},1)

I understand the risks of bypassing the providers system, have my own toll-fraud protections in place too.

Thank you!