Slack Incoming Webhook Connection

The Slack Incoming Webhook connection type enables Slack Incoming Webhooks Integrations.

Authenticating to Slack

Authenticate to Slack using a Incoming Webhook URL.

Default Connection IDs

Warning

The airflow.providers.slack.hooks.slack_webhook.SlackWebhookHook and community provided operators not intend to use any Slack Incoming Webhook Connection by default right now. It might change in the future to slack_default.

Configuring the Connection

Schema

Optional. Http schema, if not specified than https is used.

Slack Webhook Endpoint (Host)

Optional. Reference to slack webhook endpoint, if not specified than hooks.slack.com/services is used. In case if endpoint contain schema, than value from field Schema ignores.

Webhook Token (Password)

Specify the Slack Incoming Webhook URL. It might specified as full url like https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX in this case values from Slack Webhook Endpoint (Host) and Schema fields ignores. Or it might specified as URL path like T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX in this case Slack Incoming Webhook URL will build from this field, Schema and Slack Webhook Endpoint (Host).

Extra

Specify the extra parameters (as json dictionary) that can be used in slack_sdk.WebhookClient. All parameters are optional.

  • timeout: The maximum number of seconds the client will wait to connect and receive a response from Slack Incoming Webhook.

  • proxy: Proxy to make the Slack Incoming Webhook call.

If you are configuring the connection via a URI, ensure that all components of the URI are URL-encoded.

Examples

Snippet for create Connection as URI:
from airflow.models.connection import Connection

conn = Connection(
    conn_id="slack_default",
    conn_type="slackwebhook",
    password="T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
    extra={
        # Specify extra parameters here
        "timeout": "42",
    },
)

# Generate Environment Variable Name
env_key = f"AIRFLOW_CONN_{conn.conn_id.upper()}"
print(f"{env_key}='{conn.get_uri()}'")
Set Slack API Connection as Environment Variable (URI)
export AIRFLOW_CONN_SLACK_DEFAULT='slackwebhook://:T00000000%2FB00000000%2FXXXXXXXXXXXXXXXXXXXXXXXX@/?timeout=42'

Was this entry helpful?