This is a project created using React.js, Vite, Typescript, and Slack Webhooks. This project is used to send error messages on Slack whenever API returns an error. The project is currently setup to handle the following HTTP Status Codes:
- 400 (Bad Request)
- 403 (Forbidden)
- 404 (Not Found)
- 422 (Unprocessable Content)
- 429 (Too Many Requests)
- 500 (Internal Server Error)
- 503 (Service Unavailable)
The backend code is deployed on Vercel and is available on Github:
- Github Repo - slackerrorsim
- Backend URL - https://slackerrorsim.vercel.app/
Follow these steps to create a Slack webhook using "Incoming Webhooks" and integrate it with your application:
- Go to Slack API Apps
- Click "Create New App"
- Choose "From scratch"
- Enter your app name (e.g., "Error Notification Bot")
- Select your workspace
- Click "Create App"
- In your app dashboard, navigate to "Features" → "Incoming Webhooks"
- Toggle "Activate Incoming Webhooks" to ON
- Click "Add New Webhook to Workspace"
- Select the channel where you want to receive error notifications (e.g.,
#errors-stg) - Click "Allow" to grant permissions
- Your webhook URL will be generated automatically
- Copy the webhook URL that looks like:
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX - Keep this URL secure as it provides access to post messages to your channel
- Open the Slack-Error-Sim application
- In the "Slack Configuration" section:
- Channel Name: Enter your channel name (e.g.,
#errors-stg) - Webhook URL: Paste the webhook URL from step 4
- Channel Name: Enter your channel name (e.g.,
- Click "Save Configuration"
- You should see a green checkmark indicating "Slack configuration is active"
-
Click any of the error buttons (400, 403, 404, etc.) in the application
-
Check your Slack channel for the error notification message
-
The message will include:
- Error status code and type
- API endpoint that was called
- Request method (GET, POST, PUT, etc.)
- Timestamp
- Full request curl command
- Response data
The webhook sends rich formatted messages with the following information:
🔵 *Page Name*
🟣 *Error Code - SlackError-Sim*
🟡 *API CALL*: `/api/v1/error/400`
🔴 *PANEL PAGE URL*: `/`
⚫ *METHOD*: `POST`
🟤 *TIMESTAMP*: `2025-01-31T10:30:00.000Z`
Request Curl:
curl -X POST 'https://slackerror-sim.vercel.app/api/v1/error/400' \
-H 'Content-Type: application/json' \
-d '{"user_name":"Himanshu Kumar","email":"himanshu064@gmail.com"}'
Response:
{
"status": "error",
"statusCode": 400,
"message": "Bad request: Invalid input data!",
"data": []
}- Keep webhook URLs private: Never commit webhook URLs to public repositories
- Use environment variables: Store webhook URLs in environment variables for production
- Rotate webhooks regularly: Generate new webhook URLs periodically for security
- Monitor usage: Check Slack app metrics to monitor webhook usage
Webhook not working?
- Verify the webhook URL is correct and active
- Check that the channel name includes the
#symbol - Ensure your Slack app has permissions to post to the channel
- Check browser console for any error messages
Messages not appearing in Slack?
- Verify you're looking in the correct channel
- Check if the bot was added to a private channel
- Ensure the webhook URL hasn't expired
slack-error-sim/
├── src/
│ ├── components/
│ │ └── RenderAPIs.tsx # Main component with Slack configuration
│ ├── core/
│ │ └── infrastructure/
│ │ └── http.ts # Axios interceptor with webhook logic
│ └── ...
├── package.json
└── README.md
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
