Skip to content

Instantly share code, notes, and snippets.

@khoipro
Created August 29, 2024 14:44
Show Gist options
  • Save khoipro/177f370c9cc4638fcc1c2b2f422ce7d3 to your computer and use it in GitHub Desktop.
Save khoipro/177f370c9cc4638fcc1c2b2f422ce7d3 to your computer and use it in GitHub Desktop.
Sample Bash script to trigger web hook in Slack
#!/bin/bash
slack_webhook_url="https://hooks.slack.com/services/xxx"
function send_slack_message() {
message="$1"
curl -X POST -H 'Content-type: application/json' --data "{\"text\": \"$message\"}" "$slack_webhook_url"
}
message="Testing\n\n"
# Multiple rows
message+=" 1, 2, 3!!!\n\n"
send_slack_message "$message"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment