Apache Airflow Provider for Discord
raw JSON → 3.12.2 verified Fri May 01 auth: no python
An Apache Airflow provider package that integrates Discord messaging via webhooks. Version 3.12.2 supports Airflow 2.9+ and Python ≥3.10. Released on a monthly cadence alongside other providers.
pip install apache-airflow-providers-discord Common errors
error ModuleNotFoundError: No module named 'airflow.providers.discord' ↓
cause The provider package is not installed or the Airflow version is too old (pre-2.0).
fix
Install via pip: pip install apache-airflow-providers-discord. Ensure Airflow 2.0+ is installed.
error AttributeError: module 'airflow.hooks.base_hook' has no attribute 'BaseHook' ↓
cause Using deprecated import paths from Airflow 1.x.
fix
Use current import: from airflow.providers.discord.hooks.discord_webhook import DiscordWebhookHook
Warnings
breaking Default hook/operator classes now require 'http_conn_id' to be explicitly set. In older versions (pre-3.0), the webhook URL was read from variable 'discord_webhook_url'. ↓
fix Always provide 'http_conn_id' when instantiating DiscordWebhookHook or DiscordWebhookOperator. Create a Connection with 'discord_webhook' as conn_id and the webhook URL in the 'host' field.
gotcha The webhook URL is stored in the 'host' field of the Airflow connection, not in the 'password' or 'login' fields. Many users mistakenly put it in the password field. ↓
fix In Airflow UI, create a Connection: Conn Id = discord_webhook, Conn Type = HTTP, Host = https://discord.com/api/webhooks/... (the full webhook URL).
gotcha The operator sends the message as a POST request to the webhook URL. If the webhook URL is invalid or Discord returns an error, the task fails with a generic HTTP error. No additional error details are logged. ↓
fix Verify the webhook URL manually by sending a test curl command. Ensure the webhook is active and has proper permissions.
Imports
- DiscordWebhookHook wrong
from airflow.contrib.hooks.discord_hook import DiscordWebhookHookcorrectfrom airflow.providers.discord.hooks.discord_webhook import DiscordWebhookHook
Quickstart
from airflow import DAG
from airflow.providers.discord.operators.discord_webhook import DiscordWebhookOperator
from datetime import datetime, timedelta
import os
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
}
with DAG(
'discord_webhook_example',
default_args=default_args,
description='A simple DAG to send Discord message',
schedule_interval=timedelta(days=1),
start_date=datetime(2021, 1, 1),
catchup=False,
tags=['example'],
) as dag:
discord_task = DiscordWebhookOperator(
task_id='send_discord_notification',
http_conn_id='discord_webhook',
message='Hello from Airflow!',
username='AirflowBot',
avatar_url='',
tts=False,
proxy=None,
dag=dag,
)