Sep 2026
SMS-to-Telegram gateway
A Raspberry Pi with a 3G modem that forwards every incoming SMS to Telegram
- Automation
- Home lab
- Duration
- 1 month
- Role
- Sole owner; set up in Claude Code sessions
Overview
A Raspberry Pi with a USB 3G modem that forwards every incoming SMS to a Telegram channel. It runs as a self-healing service and can be reached from anywhere over Tailscale, so reading the messages no longer needs the device that holds the SIM.
Tools
- Raspberry Pi
- Python
- systemd
- Telegram
- Tailscale
The modem’s limits
SMS that arrive on a SIM card can only be read on the device that holds it. The Huawei E303 modem in HiLink mode offers only a web API, with no serial mode and no USSD on this firmware. When plugged in, it took over the Pi’s default route and DNS, and after a SIM re-insert it lost the card until restarted.
The service
The Pi runs Debian 13 with key-based SSH over Tailscale. A Python service polls the modem’s HiLink API every 10 seconds, posts each new SMS to a Telegram channel through a bot, marks it as read and keeps a state file so nothing is sent twice. It also works around the modem’s UTF-8/CESU-8 encoding bug, so Georgian text and emoji arrive intact.
Self-healing
When the modem reports a lost SIM, the script restarts it through the modem’s own API, with a 15-minute cooldown. NetworkManager is set so the modem never becomes the default route or DNS, and systemd restarts the service whenever it stops.
Result
Tested end to end on 4 September 2026. After a SIM re-insert it no longer needs a manual restart.