This project demonstrates a simple Node.js application that integrates with Slack to send messages to a specified Slack channel. It exposes a single API endpoint that can be hit to send a message.
- Send messages to a Slack channel via a GET request.
- Easy-to-configure environment variables for Slack integration.
Follow these steps to set up and run the project:
-
Clone the Repository:
git clone <repository_url> cd <repository_name>
-
Install Dependencies: Ensure you have Node.js installed, then run:
npm install
-
Configure Environment Variables: Create a
.envfile in the root directory and add the following variables:SLACK_TOKEN=<your_slack_token> SLACK_CHANNEL_ID=<your_slack_channel_id> SLACK_USERNAME=<your_slack_username>
-
Run the Application:
npm start
To send a message to the Slack channel, make a POST request to the following endpoint:
Endpoint: /
Example Using cURL:
curl -X POST http://localhost:3000/ \
-H "Content-Type: application/json" \To update the environment variables for Slack integration:
- Open the
.envfile located in the root directory of the project. - Update the values of the following variables as needed:
SLACK_BOT_TOKEN: Your Slack Bot User OAuth Token.SLACK_CHANNEL: The Name of the Slack channel where messages should be sent.SLACK_SIGNING_SECRET: The signing secret that will appear when app was created.
- Save the file and restart the server to apply the changes:
npm start
- Ensure the Slack bot has the necessary permissions to send messages to the specified channel.
- If you encounter any issues, double-check the environment variables and the Slack app configuration.
Happy Coding! 🚀