Blueprints

Send Twilio notification when a workflow fails

Source

yaml
id: twilio-notify-on-failure
namespace: company.team

tasks:
  - id: send_twilio_notification
    type: io.kestra.plugin.notifications.twilio.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

About this blueprint

System Notifications

This system flow will send a notification anytime a workflow in a company namespace (or any nested child namespace) fails. Using this pattern, you can get notification for Kestra workflow execution failures alongside other notifications. You can customize that system flow by modifying the task, adding more tasks to the flow or adjusting the trigger conditions. Read more about that pattern in the Administrator Guide. Let's create a flow in the namespace with prefix company that will always fail.

yaml
tasks:
  - id: always_fails
    type: io.kestra.plugin.core.execution.Fail

Whenever you run the failure_flow, it will trigger an execution of the twilio_notify_on_failure flow. As a result, a notification will be sent using Twilio so that prompt action can be taken.

Twilio Execution

Flow

Execution Status

Execution Namespace

More Related Blueprints

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra