Catch AWS Spend Spikes Before Standup
Daily AWS Cost Explorer pull that compares yesterday's spend to your budget and alerts Slack on anomalies.
Read recent Twilio outbound messages every hour, change nothing, and alert Slack when SMS failures cross your limits, with the top error code.
One-time passwords, delivery updates and appointment reminders go out as SMS, and when a carrier starts filtering a sender, a sender registration lapses, or a number runs out of balance, messages quietly come back failed or undelivered. Users simply cannot log in, and the team hears about it from support tickets. Twilio records every outcome and an error code, but nobody watches the rate. This blueprint turns a scheduled, read-only call to the Twilio Messages API into an SMS delivery gate: io.kestra.plugin.core.http.Request reads recent outbound messages, one jq query computes the failure rate and the most common error code, and the result routes to a quiet log or a Slack alert.
list_messages (io.kestra.plugin.core.http.Request) calls GET /2010-04-01/Accounts/{AccountSid}/Messages.json with PageSize=1000 and a DateSent>= filter for the lookback window, using HTTP basic auth with the Account SID and Auth Token. It is a read: nothing is sent, redacted or deleted. Retries cover short network blips, and allowFailed plus allowFailure keep an API error from aborting the flow so it can be reported instead.summarize_delivery (io.kestra.plugin.core.debug.Return) first guards for a missing or non-200 response (UNREACHABLE). Otherwise one jq query keeps outbound messages (direction starting with outbound) whose status is final (delivered, sent, undelivered, failed), ignores ones still queued or sending, computes the share that failed or came back undelivered, and finds the most common error_code. Fewer than min_messages finished messages is LOW_VOLUME; at or above critical_failure_rate is CRITICAL; at or above warning_failure_rate is WARNING; otherwise HEALTHY.route_by_delivery (io.kestra.plugin.core.flow.Switch) branches on that classification: HEALTHY and LOW_VOLUME log quietly, WARNING posts a Slack note, CRITICAL and UNREACHABLE page Slack. A defaults fallback logs anything unexpected.log_audit_result (io.kestra.plugin.core.log.Log) writes one audit line per run with the HTTP status and the full summary.errors block pages Slack if the flow itself fails, and the hourly_check trigger runs at 35 minutes past every hour, shipped disabled: true.status output (HEALTHY / WARNING / CRITICAL / LOW_VOLUME / UNREACHABLE) other flows can gate on, for example to switch OTPs to WhatsApp or email while SMS is failing.Twilio's console shows message logs and its status callbacks report one message at a time. Kestra turns a plain, read-only API call into a scheduled, typed classification with retries, a failure path and an execution history, and the status output lets your messaging flows fall back to another channel automatically.
TWILIO_ACCOUNT_SID: the Account SID (starts with AC).TWILIO_AUTH_TOKEN: the matching Auth Token (or an API key secret, if you use an API key SID as the username instead).SLACK_WEBHOOK: Slack incoming webhook used for every alert branch and the flow-failure alert.In Kestra OSS, secrets are supplied as environment variables prefixed SECRET_ and base64-encoded, for example SECRET_TWILIO_ACCOUNT_SID=$(echo -n 'ACxxxxxxxx' | base64), and read back with {{ secret('TWILIO_ACCOUNT_SID') }}. Use the Enterprise secrets backend for encryption at rest and access control.
TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN and SLACK_WEBHOOK as secrets.min_messages and compare the counts and error code in the logs with the Messaging logs in the Console.hourly_check.next_page_uri when you send more than 1,000 messages in the window.From to watch one sender (for example the OTP short code) with its own limits.lookback_days: type INT, default 1.warning_failure_rate: type FLOAT, default 5.0 (percent).critical_failure_rate: type FLOAT, default 15.0 (percent).min_messages: type INT, default 50.status: one of HEALTHY, WARNING, CRITICAL, LOW_VOLUME, UNREACHABLE.{{ fromJson(outputs.summarize_delivery.value).top_error }} for the most common error code.next_page_uri or a shorter window.lookback_days: 1 covers yesterday and today so far.sent means the carrier accepted the message but no delivery receipt came back; it is counted as finished but not as a failure, because many routes never return receipts.