airflow.providers.slack.operators.slack_webhook

Module Contents

Classes

SlackWebhookOperator

This operator allows you to post messages to Slack using Incoming Webhooks.

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

Bases: airflow.models.BaseOperator

This operator allows you to post messages to Slack using Incoming Webhooks.

Note

You cannot override the default channel (chosen by the user who installed your app), username, or icon when you’re using Incoming Webhooks to post messages. Instead, these values will always inherit from the associated Slack App configuration (link). It is possible to change this values only in Legacy Slack Integration Incoming Webhook.

Warning

This operator could take Slack Webhook Token from webhook_token as well as from Slack Incoming Webhook connection. However, provide webhook_token it is not secure and this attribute will be removed in the future version of provider.

Parameters
  • slack_webhook_conn_id (str | None) – Slack Incoming Webhook connection id that has Incoming Webhook token in the password field.

  • message (str) – The formatted text of the message to be published. If blocks are included, this will become the fallback text used in notifications.

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

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

  • channel (str | None) – The channel the message should be posted to

  • username (str | None) – The username to post to slack with

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

  • icon_url (str | None) – 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 | None) – Proxy to use to make the Slack webhook call

  • webhook_token (str | None) – (deprecated) Slack Incoming Webhook token. Please use slack_webhook_conn_id instead.

template_fields :Sequence[str] = ['webhook_token', 'message', 'attachments', 'blocks', 'channel', 'username', 'proxy'][source]
hook()[source]

Create and return an SlackWebhookHook (cached).

execute(context)[source]

Call the SlackWebhookHook to post the provided Slack message

Was this entry helpful?