Created
September 24, 2020 12:15
-
-
Save janbenetka/b1097f6a6fed59aa7465eb1329f65ba0 to your computer and use it in GitHub Desktop.
[Airflow > Slack message] Creation of DAG that notifies Slack channel #Airflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
slack_message = "Home & Work for bundleId {} is ready for shipping!".format("{{ ti.xcom_pull(task_ids='get_bundle_id') }}") | |
notify_slack = SimpleHttpOperator( | |
task_id="notify_slack", | |
endpoint=slack_webhook_url, | |
data=json.dumps( | |
{"attachments": [{"fallback": slack_message, "text": slack_message, "color": "good"}]}), | |
headers={"Content-Type": "application/json"}, | |
depends_on_past=False, | |
response_check=lambda response: True if response.status_code == 200 else False, | |
http_conn_id="http_slack_hook" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment