Slack
Creating a Slack App
Section titled “Creating a Slack App”To send messages to Slack channels or users, you first need to create a Slack App and configure an Incoming Webhook.
Create a new app
Section titled “Create a new app”Go to the Slack API Apps page and click Create New App → From scratch.
Name and workspace
Section titled “Name and workspace”Choose a name for the app and select the Slack workspace where it will be installed.
Enable Incoming Webhooks
Section titled “Enable Incoming Webhooks”In the app settings, navigate to Incoming Webhooks and enable them.
Add a webhook to a channel
Section titled “Add a webhook to a channel”Click Add New Webhook to Workspace and choose the channel you want the app to post to.
Copy the webhook URL
Section titled “Copy the webhook URL”Copy the Webhook URL — you’ll use this to send messages.
For more information, refer to the official Slack Webhook documentation.
Example Webhook URL
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXXNotification Implementation
Section titled “Notification Implementation”Store the webhook URL as SLACK_WEBHOOK_URL in the secrets store; it reaches the build as an environment variable. Then post messages with a simple HTTP POST request. The webhook always posts to the channel it was created for.
import os
import polars as plimport requests
SLACK_WEBHOOK_URL = os.environ["SLACK_WEBHOOK_URL"]
def send_slack_message(message): response = requests.post(SLACK_WEBHOOK_URL, json={"text": message}, timeout=10) # Slack answers with the plain text "ok", or an error status with the reason response.raise_for_status()
def transform(): send_slack_message("⚠️ *New Alert!*") return pl.LazyFrame({"sent": [True]})Example Message Formatting
Section titled “Example Message Formatting”Formatting and examples
Slack supports basic formatting using Markdown-like syntax:
*bold*→ bold_italic_→ italic`code`→code<https://example.com|Custom Link>→ Custom Link
You can also include emojis and attachments for richer notifications.
