Menu

Dipesh Majumdar

Blog and Paintings

How to post notification on slack channel with bash script

In order to do this first go to your slack channel (home page) and scroll down... if you look towards left bottom part you will see a link: APP

Click on that and then click on "view app directory"

Then click on button "get essential apps"

You can see a search place with a magnifying glass

Search "Incoming WebHooks" and then click on incoming webhooks

you are in the "incoming webhooks" home page now - here you can add a new configuration on a slack channel... you can also see existing configurations for the slack channel... here get the incoming webhook url by editing on the required configuration. 

Grab the incoming webhook url and use it to the members of slack channel with the required messages...

For example with http response code - 404/500... you can put the response in a variable and post the variable in the slack channel as an alert in this way - 

curl -X POST -H 'Content-type: application/json' --data '{"text":"ALERT!!! http response for POST </some/api/call/url> :'"$HTTP_RESPONSE"'"}' https://hooks.slack.com/services/ABCDKNWRG/PQRSABCDE/blahBLAHblahBLAHblah

 

Go Back

Comment