A simple, self-hosted Go application that provides a universal HTTP endpoint to send messages to a specific Telegram chat. This is ideal for sending notifications, logs, or alerts from various services within a home network or cluster.
- Single, lightweight Go file with no external dependencies.
- Listens on
0.0.0.0to be accessible from any node on the network. - Simple query parameter-based API (
/sendMessage?message=...&code=...). - Placeholder for simple secret code authentication.
- Go (version 1.18 or later recommended).
- A Telegram account.
-
Create a Telegram Bot:
- Open Telegram and start a chat with @BotFather.
- Send the
/newbotcommand and follow the instructions. - BotFather will give you a Bot Token. Keep this safe.
-
Get your Chat ID:
- Start a chat with your new bot.
- Then, start a chat with a bot like @userinfobot.
- It will immediately reply with your user information, including your Chat ID.
-
Configure the Application:
- Copy paste
.env.exampleto.env. - FIll the values for
TELEGRAM_BOT_TOKEN,TELEGRAM_CHAT_ID,SECRET_CODE, andHTTP_PORTwith your actual credentials.
- Copy paste
To send a message, make an HTTP GET request to the /sendMessage endpoint from any service or client on your network.
GET /sendMessage
message(string, required): The text message you want to send.code(string, optional): The secret authentication code.
Replace <YOUR_SERVER_IP> with the IP address of the machine running the bot.
curl "http://<YOUR_SERVER_IP>:8080/sendMessage?message=Disk%20space%20is%20getting%20low%20on%20server-01&code=a-very-strong-and-secret-password"If the message is sent successfully, you will receive a "Message sent successfully." response.