{"id":1329,"library":"apache-airflow-providers-slack","title":"Apache Airflow Slack Provider","description":"The Apache Airflow Slack provider package enables interaction with Slack, offering operators and hooks to send messages, upload files, and integrate with Slack workflows. It includes `SlackOperator` for the Slack API and `SlackWebhookOperator` for incoming webhooks. The current version is 9.9.0, and provider packages typically release independently of core Airflow, often aligning with Airflow's major releases or critical bug fixes.","status":"active","version":"9.9.0","language":"en","source_language":"en","source_url":"https://github.com/apache/airflow/tree/main/airflow/providers/slack","tags":["airflow","provider","slack","messaging","notifications"],"install":[{"cmd":"pip install apache-airflow-providers-slack","lang":"bash","label":"Install provider"}],"dependencies":[{"reason":"This is an Airflow provider package and requires Apache Airflow to run.","package":"apache-airflow","optional":false}],"imports":[{"note":"Import path for Slack API operator changed from airflow.contrib in Airflow 1.x to airflow.providers in Airflow 2.0+","wrong":"from airflow.contrib.operators.slack_operator import SlackOperator","symbol":"SlackOperator","correct":"from airflow.providers.slack.operators.slack_operator import SlackOperator"},{"note":"Import path for Slack Webhook operator changed from airflow.contrib in Airflow 1.x to airflow.providers in Airflow 2.0+","wrong":"from airflow.contrib.operators.slack_webhook_operator import SlackWebhookOperator","symbol":"SlackWebhookOperator","correct":"from airflow.providers.slack.operators.slack_webhook import SlackWebhookOperator"},{"symbol":"SlackHook","correct":"from airflow.providers.slack.hooks.slack import SlackHook"},{"symbol":"SlackWebhookHook","correct":"from airflow.providers.slack.hooks.slack_webhook import SlackWebhookHook"}],"quickstart":{"code":"from airflow.providers.slack.operators.slack_webhook import SlackWebhookOperator\nfrom airflow.models.dag import DAG\nfrom datetime import datetime\n\n# IMPORTANT: For this DAG to send messages, an Airflow Connection named 'slack_webhook_default'\n# must be configured. It should be an 'HTTP' connection type, with your Slack Incoming Webhook URL\n# placed in the 'Host' field (e.g., https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX).\n# For local testing without sending actual messages, you can create a dummy HTTP connection.\n\nwith DAG(\n    dag_id='slack_webhook_quickstart',\n    start_date=datetime(2023, 1, 1),\n    schedule=None, # This DAG runs manually\n    catchup=False,\n    tags=['slack', 'example'],\n) as dag:\n    send_message_to_slack = SlackWebhookOperator(\n        task_id='send_message_to_slack',\n        slack_webhook_conn_id='slack_webhook_default',\n        message=\"Hello from Airflow! This is a test message from the quickstart DAG. :airflow:\",\n        channel=\"#general\" # Specify the Slack channel (optional, overrides default webhook channel)\n    )","lang":"python","description":"This quickstart demonstrates how to use the `SlackWebhookOperator` to send a message to a Slack channel. You need to configure an Airflow Connection named `slack_webhook_default` of type `HTTP` with your Slack Incoming Webhook URL in the 'Host' field."},"warnings":[{"fix":"Update all import statements to use the new provider path: `from airflow.providers.slack...`.","message":"Prior to Airflow 2.0, Slack operators and hooks were part of `airflow.contrib`. With the introduction of provider packages, all Slack-related components were moved to `airflow.providers.slack`. Importing from `airflow.contrib.operators.slack_operator` or `airflow.contrib.hooks.slack_hook` will lead to `ModuleNotFoundError` in Airflow 2.0+.","severity":"breaking","affected_versions":"Airflow 2.0+ and `apache-airflow-providers-slack` versions 1.0+"},{"fix":"For `SlackWebhookOperator`, create an `HTTP` connection and place the full webhook URL in the 'Host' field. For `SlackOperator`, create a `Slack` connection and place the Slack API token (e.g., `xoxb-YOUR_TOKEN`) in the 'Password' field.","message":"Operators like `SlackWebhookOperator` and `SlackOperator` rely on correctly configured Airflow Connections. A common mistake is using the wrong connection type (e.g., `Generic` instead of `HTTP` for webhooks, or `Generic` instead of `Slack` for the Slack API) or placing the token/URL in the wrong field (e.g., `Host` for a webhook URL, `Password` for a Slack token).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your Slack App's bot token has the necessary OAuth scopes. For example, `chat:write` for sending messages, `files:write` for uploading files, or specific channel read/write scopes, and install the app to the relevant workspace/channels.","message":"When using `SlackOperator` (which interacts with the Slack API directly), insufficient bot token scopes (permissions) are a frequent cause of `slack_sdk.errors.SlackApiError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If advanced Slack API features are needed, switch to `SlackOperator` or interact with `SlackHook` directly. `SlackWebhookOperator` is best suited for simple message posting.","message":"`SlackWebhookOperator` uses Slack's incoming webhooks, which are simpler but have limitations compared to the full Slack API. It does not support features like uploading files, advanced user/channel lookups, or directly interacting with Slack APIs requiring OAuth. For these advanced use cases, `SlackOperator` (or `SlackHook` directly) should be used.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}