Slack Incoming Webhook Operators¶
SlackWebhookOperator¶
Use the SlackWebhookOperator
to post messages
to predefined Slack channel through Incoming Webhook
Using the Operator¶
You could send simple text message
slack_webhook_operator_text = SlackWebhookOperator(
task_id="slack_webhook_send_text",
slack_webhook_conn_id=SLACK_WEBHOOK_CONN_ID,
message=(
"Apache Airflow® is an open-source platform for developing, "
"scheduling, and monitoring batch-oriented workflows."
),
)
Or you could use Block Kit for create app layouts
slack_webhook_operator_blocks = SlackWebhookOperator(
task_id="slack_webhook_send_blocks",
slack_webhook_conn_id=SLACK_WEBHOOK_CONN_ID,
blocks=[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": (
"*<https://github.com/apache/airflow|Apache Airflow®>* "
"is an open-source platform for developing, scheduling, "
"and monitoring batch-oriented workflows."
),
},
"accessory": {"type": "image", "image_url": IMAGE_URL, "alt_text": "Pinwheel"},
}
],
message="Fallback message",
)