Skip to content

Instantly share code, notes, and snippets.

@u110
Created August 15, 2019 05:56
Show Gist options
  • Save u110/ba67ba97012ebe00086eba8c514cb762 to your computer and use it in GitHub Desktop.
Save u110/ba67ba97012ebe00086eba8c514cb762 to your computer and use it in GitHub Desktop.
from airflow.operators.slack_operator import SlackAPIPostOperator
SLACK_TOKEN = "xoxb-XXXX-YYYY-ZZZ"
# refs.
# https://api.slack.com/docs/message-attachments#action_fields
if __name__ == "__main__":
op = SlackAPIPostOperator(
task_id="slack_post_task",
token=SLACK_TOKEN,
text="post message test",
channel='#bot',
username='airflow-bot',
attachments=[{
"text": "DANGER!",
"color": "danger"
}]
)
op.execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment