Skip to main content

prefect_slack.messages

Tasks for sending Slack messages.

Functions

send_chat_message

Sends a message to a Slack channel. Args:
  • channel: The name of the channel in which to post the chat message (e.g. #general).
  • slack_credentials: Instance of SlackCredentials initialized with a Slack bot token.
  • text: Contents of the message. It’s a best practice to always provide a text argument when posting a message. The text argument is used in places where content cannot be rendered such as: system push notifications, assistive technology such as screen readers, etc.
  • attachments: List of objects defining secondary context in the posted Slack message. The Slack API docs provide guidance on building attachments.
  • slack_blocks: List of objects defining the layout and formatting of the posted message. The Slack API docs provide guidance on building messages with blocks.
Returns:
  • Response from the Slack API. Example response structures can be found in the Slack API docs.

send_incoming_webhook_message

Sends a message via an incoming webhook. Args:
  • slack_webhook: Instance of SlackWebhook initialized with a Slack webhook URL.
  • text: Contents of the message. It’s a best practice to always provide a text argument when posting a message. The text argument is used in places where content cannot be rendered such as: system push notifications, assistive technology such as screen readers, etc.
  • attachments: List of objects defining secondary context in the posted Slack message. The Slack API docs provide guidance on building attachments.
  • slack_blocks: List of objects defining the layout and formatting of the posted message. The Slack API docs provide guidance on building messages with blocks.