blob: c69fa23842611bf397b46388442c0a4d57ba17d8 [file] [log] [blame]
:py:mod:`airflow.providers.slack.operators.slack_webhook`
=========================================================
.. py:module:: airflow.providers.slack.operators.slack_webhook
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
airflow.providers.slack.operators.slack_webhook.SlackWebhookOperator
.. py:class:: 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)
Bases: :py:obj:`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 <https://api.slack.com/messaging/webhooks#advanced_message_formatting>`_).
It is possible to change this values only in `Legacy Slack Integration Incoming Webhook
<https://api.slack.com/legacy/custom-integrations/messaging/webhooks#legacy-customizations>`_.
.. warning::
This operator could take Slack Webhook Token from ``webhook_token``
as well as from :ref:`Slack Incoming Webhook connection <howto/connection:slack-incoming-webhook>`.
However, provide ``webhook_token`` it is not secure and this attribute
will be removed in the future version of provider.
:param slack_webhook_conn_id: :ref:`Slack Incoming Webhook <howto/connection:slack>`
connection id that has Incoming Webhook token in the password field.
:param message: The formatted text of the message to be published.
If ``blocks`` are included, this will become the fallback text used in notifications.
:param attachments: The attachments to send on Slack. Should be a list of
dictionaries representing Slack attachments.
:param blocks: The blocks to send on Slack. Should be a list of
dictionaries representing Slack blocks.
:param channel: The channel the message should be posted to
:param username: The username to post to slack with
:param icon_emoji: The emoji to use as icon for the user posting to Slack
:param icon_url: The icon image URL string to use in place of the default icon.
:param link_names: Whether or not to find and link channel and usernames in your
message
:param proxy: Proxy to use to make the Slack webhook call
:param webhook_token: (deprecated) Slack Incoming Webhook token.
Please use ``slack_webhook_conn_id`` instead.
.. py:attribute:: template_fields
:annotation: :Sequence[str] = ['webhook_token', 'message', 'attachments', 'blocks', 'channel', 'username', 'proxy']
.. py:method:: hook()
Create and return an SlackWebhookHook (cached).
.. py:method:: execute(context)
Call the SlackWebhookHook to post the provided Slack message