> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/unix/send-slack-message-from-command-line.md).

# send slack message from command line

Install Incomming webhook to your channel <https://api.slack.com/incoming-webhooks#sending_messages>

you will then get some url `https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX`

create `/usr/local/bin/notifyme`

```
#!/bin/sh

curl -X POST --data-urlencode "payload={\"channel\": \"#alert\", \"username\": \"mybot\", \"text\": \"$*\", \"icon_emoji\": \":name_badge:\"}" https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
```

and send message via your command line

```
$ chmod +x /usr/local/bin/notifyme
$ notifyme hello world!

# or after some command
$ sleep 5; notifyme process is finished
```
