airflow.providers.slack.operators.slack_webhook

Module Contents

class airflow.providers.slack.operators.slack_webhook.SlackWebhookOperator(*, http_conn_id: str, webhook_token: Optional[str] = None, message: str = '', attachments: Optional[list] = None, blocks: Optional[list] = None, channel: Optional[str] = None, username: Optional[str] = None, icon_emoji: Optional[str] = None, icon_url: Optional[str] = None, link_names: bool = False, proxy: Optional[str] = None, **kwargs)[source]

Bases: airflow.providers.http.operators.http.SimpleHttpOperator

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.

Parameters
  • http_conn_id (str) -- connection that has Slack webhook token in the extra field

  • webhook_token (str) -- Slack webhook token

  • message (str) -- The message you want to send on Slack

  • attachments (list) -- The attachments to send on Slack. Should be a list of dictionaries representing Slack attachments.

  • blocks (list) -- The blocks to send on Slack. Should be a list of dictionaries representing Slack blocks.

  • channel (str) -- The channel the message should be posted to

  • username (str) -- The username to post to slack with

  • icon_emoji (str) -- The emoji to use as icon for the user posting to Slack

  • icon_url (str) -- The icon image URL string to use in place of the default icon.

  • link_names (bool) -- Whether or not to find and link channel and usernames in your message

  • proxy (str) -- Proxy to use to make the Slack webhook call

template_fields = ['webhook_token', 'message', 'attachments', 'blocks', 'channel', 'username', 'proxy'][source]
execute(self, context: Dict[str, Any])[source]

Call the SlackWebhookHook to post the provided Slack message

Was this entry helpful?