Sending messages to Slack using Incoming Webhook

I am a backend developer with interests in distributed systems, database internals and software architecture.
Search for a command to run...

I am a backend developer with interests in distributed systems, database internals and software architecture.
No comments yet. Be the first to comment.
Introduction: Many a time when working on an application we want to make multiple co-related reads and writes to database to complete a single unit of work. These operations are typically triggered by a single action from an application user. For exa...

Every developer who has used Node.js knows that its runtime, although single-threaded, handles concurrent requests efficiently thanks to asynchronous I/O and the event loop.However, the library powering these features, Libuv often goes undiscussed. W...

Introduction: A few years ago, logs had a simple meaning to me: data written to standard output on the terminal or a file to monitor an application and assist in debugging in case of a crash. This definition of logs was confined to mostly human-reada...

In the world of distributed systems and microservices, we often want to communicate with different services hosted on different servers in various geographical locations. To do this, we need to serialize the payload (in-memory structure to bytes) at ...

Isolation in DynamoDB transactions or any data system for that matter is often an overlooked property but it is very important to understand, as concurrent transactions are almost unavoidable when working on distributed systems. But what is isolation...

If your looking for easy and quick way to send messages to slack channels programmatically then you're at the right place, in this post I will walk you through how you can achieve just that using incoming webhooks, so let's get started.
Once these things are done we can move to our main task i.e incoming webhooks.
Go to slack app directory and search for incoming webhooks.
You'll get an page like this, there click on add to slack

Select the channel where you want Incoming webhook to post messages to for me its test_channel and then click on add button, this will provide us with the webhook url which we can use to send messages to slack it will look to something like this :
https://hooks.slack.com/services/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KL
Now you can use this webhook to send custom messages to slack here's an example using curl
curl -X POST --data-urlencode "payload={\"channel\": \"#test_channel\", \"username\": \"webhookbot\", \"text\": \"This is posted to #test_channel and comes from a bot named ghostfreak.\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/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KL
Replace the the above webhook with your own and your good to go.
This will send the message to your slack channel like this.
Word of caution remember to keep your webhook a secret as anyone with your webhook url will be able to send messages to your channel.
Further more we can also format the message as required more on that here. So using this approach we can send customized message to slack using our favorite http client and achieve cool things.
Until then........
Be Curious