Version v0.4.0 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot. For up-to-date documentation, see the latest version.

Discord connection

Discord connection

Post messages to a Discord channel from a task over a managed Leoflow Connection. DiscordWebhookHook sends to a channel webhook.

Declare the provider

# leoflow.yaml
dag_id: discord_notify
connectors:
  - discord

URI shape

discord://:<webhook_token>@?__extra__=<json>

There is no host. The webhook token lives in Password (percent-escaped), and the webhook endpoint path (webhooks/<id>/<token>) rides in Extra under __extra__. The hook joins Discord’s base webhook URL with the endpoint to post.

Fields the UI asks for

FieldRequiredNotes
Conn Idyese.g. discord_default. Exported as AIRFLOW_CONN_DISCORD_DEFAULT.
Conn Typeyesdiscord.
PasswordoptionalThe webhook token. Encrypted at rest (ADR 0019).
ExtrayesJSON: {"webhook_endpoint":"webhooks/123/abc"}.
HostnoLeave blank.

Example DAG

# dag.py
from airflow.sdk import DAG, task


@task
def send():
    from airflow.providers.discord.hooks.discord_webhook import (
        DiscordWebhookHook,
    )

    hook = DiscordWebhookHook(
        http_conn_id="discord_default",
        message="DAG finished",
    )
    hook.execute()


with DAG("discord_notify", schedule=None, catchup=False, tags=["example"]):
    send()
# leoflow.yaml
schema_version: "1.0"
dag_id: discord_notify
python_version: "3.12"
connectors:
  - discord
connections:
  - discord_default

Security notes

  • The webhook URL is the secret: anyone with it can post to the channel. Keep the endpoint in Extra and the token in Password — both are encrypted at rest.
  • Rotate on leak: delete and recreate the webhook in Discord channel settings, then update the Connection.
  • Never log AIRFLOW_CONN_DISCORD_DEFAULT.
  • ADR 0019 — secret encryption at rest.
  • ADR 0021 — agent secret delivery (AIRFLOW_CONN_<CONN_ID>).
  • TestDiscordConnectionURIShapeIntegration — chain-of-custody delivery test.