Kali Linux

How to Send a Message to Slack Channel Using Bash

We can transform Slack into a CLI notification panel with the aid of several pull systems. There seems to be a lot you could do with Slack, from basic message streams to bespoke Slack connectors for your program. This type of connection is especially useful for alert activities, such as when anything changes or new material becomes available, and is comparable to how RSS feeds function. You may also create bespoke connections for your programs that leverage the same API, complete with interactive dialogues and options for input data.

Let’s get started with the implementation of today’s article by opening the Kali Linux on your Windows 10 system first. The black screen of Kali Linux will appear, as shown below. After opening it, make sure to update it with the “apt-get” installation command on its Bash shell.

After updating our system, it’s time to install the “npm” registry on our Kali Linux. It is considered the world’s biggest application registry, with about 800,000 code modules stored inside this repository. To share a code,  the open-source developers utilize npm. The “npm” registry is also widely used to handle private development in many enterprises.

We tried the “apt-get” installation instruction on the Kali Linux shell to install the “npm” registry at our end.

Upon installation, it will ask for confirmation. Tap “y” to continue.

Slack provides an API that lets you process many of your workplace connections. This API is accessible from any programming language or Bash code that can make HTTP queries like POST and GET. In all Unix distributions, the curl program is pre-installed. Use Slack’s API gateways to log in, i.e., https://app.slack.com/.

After a successful login, you need to create a new Slack application from the same Slack gateway. Create a new workspace to which our application will belong by adding its name. The image below shows the configuration of a new app by adding the name of a workspace “linuxworkspace” on the Slack gateway. Tap on the “Next” button to continue towards the next step.

After adding a name for a new workspace, it’s time to name the application we are creating within this workspace. We named it “SlackLinux-App”, as shown in the image below. After that, click on the “Next” button to continue going towards the next step of using Slack.

Whatever the other information it requires as a prerequisite, complete it and tap on the Create App button to continue. After that, you’ll be directed to the homepage of your Slack Application where you may customize your bot’s characteristics. There are many great things here, like counting custom instructions and collaborative messages. Then, choose Incoming Webhooks from the drop-down menu. Turn the Toggle button by tapping on it in front of the “Activate Incoming Webhooks” heading. The ”Webhooks URLs for Your Workspace” will open in your desktop browser, as shown in the image below.

Within this screen, you will find the sample curl instruction used by a user to send a message to a Slack channel. You can see the copy button at the left-most corner of this instruction for you to copy this instruction easily. Tap on this button to copy this URL.

Open your Kali Linux Bash shell again and paste the copied command using any of the known methods to copy-paste in the Linux shell. We used the same curl instruction three times at our Kali Linux shell to send a message to our Slack channel name “SlackLinux-App”. Whenever we use this instruction, it yields an “ok” output for this command. This means that the curl command we added has been successfully used to send any random message to the Slack bot channel. This command contains the usage of JSON by implementing the POST method for insertion.

Now, you need to open your Slack channel at the Slack official gateway website, where you created your workspace and application. The conversation area will open for your slack channel on your browser screen, as shown below. You will see that the messages we used in the previous curl instructions are successfully sent to the Slack channel “slacklinux-app” at our Slack bot. This is how we can use the Slack bot and curl instruction to send any type of message from a local Bash CLI Linux system to the remote Slack channel.

In the previous example, we used the same “Hello World!” message from the curl instruction to send the message to the Slack channel without updating. Now, we will update the message that we want to send from the local Bash command line to the remote channel. This time, we use the text “Hi, I am sending my first Slack message!” to the Slack bot channel via the Kali Linux Bash command line. We will use the same curl instruction with a little update in its “text” option, as shown in the image below.

After executing this instruction, we received the message “ok” on our Kali Linux command screen. This means the message has been successfully delivered from the Bash command line to the Slack channel “slacklinux-app” via the curl instruction.

Now, when we open the Slack channel “slacklinux-app” at the Slack homepage, we will know that the message has been successfully delivered from the Bash to Slack.


This article is about using npm and the Kali Linux to send some messages from Bash CLI to the Slack channel. To connect Bash CLI with the remote Slack bot, we need to install npm first on our Linux system. After that, we created an application on the Slack homepage and used the webhooks curl command to perform the transferring of a message from Bash to Slack. Check related Linux Hint articles for more tutorials.

About the author

Omar Farooq

Hello Readers, I am Omar and I have been writing technical articles from last decade. You can check out my writing pieces.