SlackWebhookOperator

Slack

This operator allows you to post messages to Slack using incoming webhooks. Takes both Slack webhook token directly and connection that has Slack webhook token. If both supplied, http_conn_id will be used as base_url, and webhook_token will be taken as endpoint, the relative path of the url.

View Source

Last Updated: Nov. 3, 2020

Access Instructions

Install the Slack provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Parameters

http_conn_idstrconnection that has Slack webhook token in the extra field
webhook_tokenstrSlack webhook token
messagestrThe message you want to send on Slack
attachmentslistThe attachments to send on Slack. Should be a list of dictionaries representing Slack attachments.
blockslistThe blocks to send on Slack. Should be a list of dictionaries representing Slack blocks.
channelstrThe channel the message should be posted to
usernamestrThe username to post to slack with
icon_emojistrThe emoji to use as icon for the user posting to Slack
icon_urlstrThe icon image URL string to use in place of the default icon.
link_namesboolWhether or not to find and link channel and usernames in your message
proxystrProxy to use to make the Slack webhook call

Documentation

This operator allows you to post messages to Slack using incoming webhooks. Takes both Slack webhook token directly and connection that has Slack webhook token. If both supplied, http_conn_id will be used as base_url, and webhook_token will be taken as endpoint, the relative path of the url.

Each Slack webhook token can be pre-configured to use a specific channel, username and icon. You can override these defaults in this hook.

Example DAGs

Improve this module by creating an example DAG.

View Source
  1. Add an `example_dags` directory to the top-level source of the provider package with an empty `__init__.py` file.
  2. Add your DAG to this directory. Be sure to include a well-written and descriptive docstring
  3. Create a pull request against the source code. Once the package gets released, your DAG will show up on the Registry.

Was this page helpful?