Flow icon
TeamsExecution icon

Set up alerts for failed workflow executions using Microsoft Teams

Send automatic Microsoft Teams alerts on failed or warning Kestra executions using a single system flow, the Flow trigger, and TeamsExecution.

Categories
CoreSystem
id: failure-alert-teams
namespace: system

triggers:
  - id: on_failure
    type: io.kestra.plugin.core.trigger.Flow
    dependsOn:
      - states:
          - FAILED
          - WARNING

tasks:
  - id: send_alert
    type: io.kestra.plugin.microsoft365.teams.TeamsExecution
    url: "{{ secret('TEAMS_WEBHOOK') }}"
    executionId: "{{ trigger.executionId }}"

Catch every failed or degraded workflow before it becomes an incident. This system flow posts a Microsoft Teams alert the moment any Kestra execution finishes in a FAILED or WARNING state, so you manage failure notifications from one central place instead of wiring alerts into every individual flow. It is a drop-in monitoring pattern for teams that already run their day in Teams and want execution failures surfaced in the right channel within seconds.

How it works

  1. The on_failure trigger of type io.kestra.plugin.core.trigger.Flow listens to executions across your instance.
  2. A dependsOn entry with states: [FAILED, WARNING] filters those executions, firing only when the status is one of those states.
  3. When the condition matches, the send_alert task of type io.kestra.plugin.microsoft365.teams.TeamsExecution posts a message to your Teams channel. It uses the incoming {{ trigger.executionId }} so the alert links straight back to the failed execution.

What you get

  • A single source of truth for failure alerts across all namespaces and flows.
  • Near real time notifications in Microsoft Teams for FAILED and WARNING executions.
  • Direct context on which execution failed via its execution id.
  • No per flow boilerplate: add one system flow and you are covered.

Who it's for

  • Platform and data engineering teams running Kestra in production.
  • On call engineers who triage incidents from Microsoft Teams.
  • Teams standardizing observability and incident response across many pipelines.

Why orchestrate this with Kestra

Kestra system flows turn the platform's own execution events into automation. The Flow trigger reacts to execution state changes the instant they happen (no polling, no cron), and the dependsOn states list keeps noise down by alerting only on real failures and warnings. Because the logic is declarative YAML, it is versioned, reviewable, and reusable across every namespace, with built in retries and full execution lineage. A messaging tool like Microsoft Teams has no awareness of your orchestration layer on its own; Kestra is what observes the failures and pushes them into the channel.

Prerequisites

  • A Kestra instance running your workflows.
  • A Microsoft Teams channel with an incoming webhook configured.

Secrets

  • TEAMS_WEBHOOK: the incoming webhook URL for the target Microsoft Teams channel.

Quick start

  1. Create an incoming webhook in your Microsoft Teams channel and copy the URL.
  2. Store it as the TEAMS_WEBHOOK secret in Kestra.
  3. Add this flow to the system namespace.
  4. Trigger any flow to fail and confirm the alert lands in Teams.

How to extend

  • Restrict alerts to specific namespaces by adding a when expression (for example {{ trigger.namespace startsWith 'company' }}) to the dependsOn entry. See the Administrator Guide.
  • Customize the TeamsExecution payload to include richer context.
  • Add parallel tasks to notify other channels (email, Slack, PagerDuty) from the same flow.
  • Branch on labels or flow id to route alerts to different Teams channels.

Links

Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.