Skip to content

Instantly share code, notes, and snippets.

@amberovsky
Created March 13, 2016 10:45
Show Gist options
  • Save amberovsky/6f6ad3eef0d9e94730bc to your computer and use it in GitHub Desktop.
Save amberovsky/6f6ad3eef0d9e94730bc to your computer and use it in GitHub Desktop.
Slack incoming webhooks from bash (send notification to slack from shell)
read -d '' SLACK_PAYLOAD_DATA << EOF
{
"channel": "#channel",
"username": "Bot",
"text": "Message by _$(id -un)@$(hostname -f)_.",
"icon_emoji": ":poop:",
"attachments": [
{
"fields": [
{
"title": "User",
"value": "$(id -un)",
"short": true
},
{
"title": "Host",
"value": "$(hostname -f)",
"short": true
}
]
}
]
}
EOF
SLACK_COMMAND="curl -X POST --data-urlencode 'payload=${SLACK_PAYLOAD_DATA}' https://hooks.slack.com/services/XXX/QQQ/WWW"
eval ${SLACK_COMMAND}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment