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, message='', attachments=None, blocks=None, channel=None, username=None, icon_emoji=None, icon_url=None, proxy=None, timeout=None, retry_handlers=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.

Parameters
  • slack_webhook_conn_idSlack 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.

  • proxy (str | None) – Proxy to make the Slack Incoming Webhook call. Optional

  • timeout (int | None) – The maximum number of seconds the client will wait to connect and receive a response from Slack. Optional

  • retry_handlers (list[slack_sdk.http_retry.RetryHandler] | None) – List of handlers to customize retry logic in slack_sdk.WebhookClient. Optional

template_fields: collections.abc.Sequence[str] = ('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?