Twilio — alert on SMS delivery-failure spike
OTP codes go through Twilio — overnight a carrier started blocking the message type, delivery dropped to 30%. You only learn from support tickets.
Recipe
#!/usr/bin/env bash
# Last 100 messages — failure ratio.
TWILIO_SID="${TWILIO_SID:?must be set}"
TWILIO_TOKEN="${TWILIO_TOKEN:?must be set}"
THRESHOLD_PCT="${THRESHOLD_PCT:-15}"
JSON=$(curl -sS -u "$TWILIO_SID:$TWILIO_TOKEN" \
"https://api.twilio.com/2010-04-01/Accounts/$TWILIO_SID/Messages.json?PageSize=100")
TOTAL=$(echo "$JSON" | python3 -c 'import json,sys;print(len(json.load(sys.stdin)["messages"]))' 2>/dev/null)
FAILED=$(echo "$JSON" | python3 -c '
import json,sys
m = json.load(sys.stdin)["messages"]
print(sum(1 for x in m if x.get("status") in ("failed", "undelivered")))
' 2>/dev/null)
[ -z "$TOTAL" ] || [ "$TOTAL" -lt 5 ] && { echo "no-data"; exit 0; }
PCT=$((FAILED * 100 / TOTAL))
[ "$PCT" -ge "$THRESHOLD_PCT" ] && echo "high ${PCT}% (${FAILED}/${TOTAL})" || echo "ok ${PCT}%"
Same thing in Enterno.io
Endpoint + Enterno HTTP monitor with "ok" keyword every 5 min — alert hits 60s before users start emailing support. Pair with email-check on your sending domain — DMARC fails dent SMS partner trust too.
Related recipes
Ensure your site returns 2xx every minute, alert to Slack/Telegram on failure.
Minimal script that checks an SSL certificate and alerts 14 days before expiry.
Detect the moment a replica falls behind the primary by more than 10 seconds.