Skip to main content

Microsoft Teams notifications

This example shows how to set up Airflow notifications in a Microsoft Teams channel by using Airflow callbacks. Teams notifications about DAG runs and tasks let you quickly inform many team members about the status of your data pipelines.

Before you start

Before trying this example, make sure you have:

Send task failure notifications to MS Teams

Follow these steps to receive notifications in MS Teams for failed tasks in an example DAG. Refer to the Airflow callbacks section of our notifications guide to learn how to set up notifications for other types of events.

  1. Open the folder containing your Astro Project. Copy the contents of the include folder in the project GitHub repository to your Astro project include folder.

    ├── .astro
    ├── dags
    └── include
    ├── hooks
    │ └──
    ├── operators
    │ └──
  2. Create a Microsoft Teams Incoming Webhook for the channel where you want to receive notifications. Copy and save the webhook URL.

  3. In the Airflow UI, create an Airflow connection by clicking on Admin and then Connections. Create a new connection with the following parameters. Note that you won't be able to test this connection from the Airflow UI.

    • Connection Id: ms_teams_callbacks
    • Connection Type: HTTP
    • Host: <your-organization><your-webhook-id>
    • Schema: https



Some corporate environments make use of outbound proxies. If you're behind an outbound proxy for internet access, put the proxy details in the Extra field when creating the HTTP Connection in the Airflow UI (For example, {"proxy":"http://my-proxy:3128"}).


If the HTTP connection type is not available, double check that the HTTP provider is installed in your Airflow environment.

  1. Import the failure callback function at the top of your DAG file.

    from include.ms_teams_callback_functions import failure_callback
  2. Set the on_failure_callback keyword of your DAG's default_args parameter to the imported failure_callback function.

    start_date=datetime(2023, 7, 1),
    "on_failure_callback": failure_callback,
  3. Run your DAG. Any failed task will trigger the failure_callback function which sends a notification message to your Teams channel.

The include folder of the project repository also contains callback functions for other triggers in addition to the failure callback shown here. You can modify any of the functions to customize the notification message. To learn more about all available callback parameters, see Airflow callbacks.


See also

Was this page helpful?

Sign up for Developer Updates

Get a summary of new Astro features once a month.

You can unsubscribe at any time.
By proceeding you agree to our Privacy Policy, our Website Terms and to receive emails from Astronomer.