I am trying to implement a Ring Group failover scenario in FreePBX where, if a caller’s call is missed (no one answers the Ring Group), the system should send an SMS to the caller instead of voicemail.
What I want to achieve
-
When a caller calls my main number
-
The call goes to a Ring Group
-
If no agent answers the call
-
I want to send an SMS to the caller saying something like:
“We are sorry we missed your call, but we are either working with a client or stepped away from the office…”
The SMS content/template is handled by my own SMS server.
From FreePBX/Asterisk, I only want to:
-
Capture the CallerID (caller number)
-
Send it to my SMS API
-
Let the SMS application send the message using a default template
Current Setup
Call Flow
-
Inbound call arrives on DID
+15550001111(dummy) -
Call is routed to Ring Group 8889
-
Ring Group rings extension
1000for 5 seconds -
If nobody answers, Ring Group No Answer Destination is set to a Custom Destination
-
Custom Destination target:
Gosub(sms-api-8889,s,1)
Dialplan (simplified)
[sms-api-8889] exten => s,1,NoOp(=== Missed Call SMS ===) same => n,Set(SRC=${FILTER(0-9,${CALLERID(num)})}) same => n,AGI(send_missedcall_sms.php,${SRC}) same => n,Hangup()
AGI Script
-
send_missedcall_sms.php -
Receives the caller number
-
Sends it to my SMS API endpoint
-
SMS server sends the message using a default template
-
API returns
200 OK
The SMS part works perfectly.
Problem I Am Facing
After the SMS is sent:
-
The call does not fully stop
-
A new inbound call attempt starts again
-
Ring Group rings again
-
No answer → SMS is sent again
-
Call starts again
-
This continues in a loop
From the logs, I can see multiple inbound channels, for example:
PJSIP/Twilio-0000000f
PJSIP/Twilio-00000011
PJSIP/Twilio-00000013
And the SMS log confirms multiple sends:
REQUEST dest=15550002222
RESPONSE http_code=200
REQUEST dest=15550002222
RESPONSE http_code=200
REQUEST dest=15550002222
RESPONSE http_code=200
Each SMS corresponds to a new inbound call attempt, not the same call looping internally.
How to fix this issue.