TwilioExecution icon
Flow icon
ExecutionStatus icon
ExecutionNamespace icon

Send Twilio notification when a workflow fails

Send a Twilio notification when any Kestra workflow fails or warns. A namespace-wide system flow for on-call escalation and pipeline monitoring.

Categories
Core
id: failure-alert-twilio
namespace: company.team

tasks:
  - id: send_twilio_notification
    type: io.kestra.plugin.twilio.notify.TwilioExecution
    url: "{{ secret('TWILIO_ALERT_URL') }}"
    identity: "0000001"
    executionId: "{{ trigger.executionId }}"
    accountSID: "{{ secret('TWILIO_ACCOUNT_SID') }}"
    authToken: "{{ secret('TWILIO_AUTH_TOKEN') }}"
    body: "Kestra Workflow Failure: {{ trigger.executionId }} has failed on {{
      taskrun.startDate }}"

triggers:
  - id: on_failure
    type: io.kestra.plugin.core.trigger.Flow
    conditions:
      - type: io.kestra.plugin.core.condition.ExecutionStatus
        in:
          - FAILED
          - WARNING
      - type: io.kestra.plugin.core.condition.ExecutionNamespace
        namespace: company
        comparison: PREFIX

Get a Twilio notification the instant any workflow in your namespace fails. This system flow watches every execution under a namespace prefix and fires a Twilio message on FAILED or WARNING status, so on-call engineers learn about broken pipelines from their phone instead of from a downstream stakeholder. It solves the classic monitoring gap: failures that happen overnight, on weekends, or in pipelines nobody is actively watching go unnoticed until the damage spreads.

How it works

  • A io.kestra.plugin.core.trigger.Flow trigger listens to executions across all flows in the instance.
  • Two conditions filter what fires the alert: io.kestra.plugin.core.condition.ExecutionStatus matches FAILED and WARNING, and io.kestra.plugin.core.condition.ExecutionNamespace matches the company prefix so every nested child namespace is covered.
  • When a matching execution occurs, the send_twilio_notification task of type io.kestra.plugin.twilio.notify.TwilioExecution sends the alert.
  • The message body includes the failed {{ trigger.executionId }} and the {{ taskrun.startDate }}, and authentication is read from secrets via accountSID, authToken, and the notification url.

What you get

  • Real-time mobile alerts for every failed or degraded run, no manual polling.
  • One central system flow instead of per-flow notification logic duplicated everywhere.
  • Coverage of an entire namespace tree from a single prefix condition.
  • Direct links back to the failing executionId for fast triage.

Who it's for

  • On-call and platform engineers who need to react to incidents fast.
  • Data and DevOps teams running critical scheduled pipelines.
  • Anyone responsible for SLAs on overnight or unattended workflows.

Why orchestrate this with Kestra

A tool like Twilio sends messages but has no idea what your pipelines are doing. Kestra's event-driven Flow trigger reacts to execution state across your whole platform, applies declarative status and namespace conditions in plain YAML, and adds retries, full execution lineage, and a searchable audit trail. A standalone scheduler or cron job cannot observe other workflows' outcomes and fan out alerts on failure: that cross-flow, status-aware reactivity is exactly the gap Kestra fills.

Prerequisites

  • A running Kestra instance with the Twilio plugin available.
  • A Twilio account with a configured notification endpoint.

Secrets

  • TWILIO_ALERT_URL: the Twilio notification URL.
  • TWILIO_ACCOUNT_SID: your Twilio account SID.
  • TWILIO_AUTH_TOKEN: your Twilio auth token.

Quick start

  1. Add the three Twilio secrets to your Kestra instance.
  2. Create this flow as a system flow.
  3. Adjust the ExecutionNamespace prefix to match your own namespace.
  4. Run any flow under that namespace that fails (for example a io.kestra.plugin.core.execution.Fail task) and confirm the alert arrives.

How to extend

  • Add more ExecutionStatus values or a label condition to narrow what triggers alerts.
  • Enrich the message body with the flow id, namespace, or a direct execution link.
  • Add parallel tasks to also post to Slack, PagerDuty, or email for layered escalation.
  • Branch on namespace so production failures page on-call while dev failures stay low priority.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.