Slack notifications via curl
Slack is a very good team collaboration tool that we use on a daily basis for sharing information. Remember the good old times on the irc channels? Slack is conceptually the same, but implemented with the latest and greatest web technologies out there (web sockets, rest api, etc). Also it was created with a lot extensibility/integration points, which opens a lot of cool options when it comes to send automatic notifications from scripts and programs.
The easiest way is simply send a HTTP POST request from your script, using curl. You will need two things:
- Create an incoming webhook in slack
- Post your notification with curl
Go to slack home using a web browser, and select Add Integrations. Scroll to the bottom, and select Incoming WebHooks (click on Add).
You have the option to select your channel (or create a new one), and you will see your hook url which looks something like https://hooks.slack.com/services/${ID}/
.
Give it a name and a custom icon.
Then, you can use this curl command to post: