Skip to content

Instantly share code, notes, and snippets.

@janbenetka
Created September 24, 2020 12:15
Show Gist options
  • Save janbenetka/b1097f6a6fed59aa7465eb1329f65ba0 to your computer and use it in GitHub Desktop.
Save janbenetka/b1097f6a6fed59aa7465eb1329f65ba0 to your computer and use it in GitHub Desktop.
[Airflow > Slack message] Creation of DAG that notifies Slack channel #Airflow
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