jrobinsonc
4/14/2020 - 11:05 PM

Slack - Send messages using the command line

#!/bin/bash

# Usage
# ./slack <channel> <message>
# ./slack @jrobinson "Test message for a user"
# ./slack #general "Test message for a channel"

CHANNEL=$1
MSG=$2

TOKEN=xoxb...

curl \
    -X POST -d "text=$MSG" -d "channel=$CHANNEL" \
    "https://slack.com/api/chat.postMessage?token=$TOKEN&pretty=1&as_user=true" 2>/dev/null 1>/dev/null