A modern Flask web application for managing SMS messages stored by Gammu in a MySQL database. Features a real-time, responsive dashboard and optional Telegram notifications.
- Modern UI: Responsive interface built with Tailwind CSS.
- Real-Time Notifications: Instant browser notifications for new SMS.
- Live UI Updates: Message list updates automatically.
- Bulk Actions: Mark as read or delete multiple messages at once.
- Easy Setup: Minimal dependencies, single-file application.
- Custom Modals: Polished dialogs for confirmations.
- Python 3.13.1+
- GSM modem or compatible mobile device (e.g., SIM800 Module)
- MySQL server
- Poetry (dependency management)
- asdf (optional)
sudo apt-get update
sudo apt-get install gammu gammu-smsdConnect your modem (e.g., /dev/ttyUSB0). Create /etc/gammu-smsdrc:
[gammu]
device = /dev/ttyUSB0
connection = at115200
[smsd]
service = sql
driver = native_mysql
host = localhost
user = gammu_user
password = <password>
database = gammu_db
logfile = syslog
loglevel = debugStart and enable the service:
sudo systemctl start gammu-smsd
sudo systemctl enable gammu-smsd
sudo systemctl status gammu-smsdCREATE DATABASE gammu_db;
$ CREATE USER 'gammu_user'@'localhost' IDENTIFIED BY 'your_secret_password';
GRANT ALL PRIVILEGES ON gammu_db.* TO 'gammu_user'@'localhost';
FLUSH PRIVILEGES;Import Gammu's SQL schema (path may vary):
mysql -u gammu_user -p gammu_db < /usr/share/doc/gammu/examples/sql/mysql.sqlgit clone git@github.com:mohammad-ahmadi1/sms-dashboard.git
cd sms-dashboard
poetry installGenerate a secure SECRET_KEY:
python -c "import secrets; print(secrets.token_hex(32))"Create a .env file (see example below):
DB_HOST=localhost
DB_USER=gammu_user
DB_PASSWORD=your_secret_password
DB_NAME=gammu_db
SECRET_KEY=<random_string>
FLASK_ENV=development
# Telegram (optional)
TELEGRAM_BOT_TOKEN=123456:ABC-YourBotToken
TELEGRAM_CHAT_ID=123456789
APP_PUBLIC_URL=http://127.0.0.1:5000
SERVER_IP=192.168.1.100-
Create a bot via BotFather.
-
Add
TELEGRAM_BOT_TOKENto.env. -
Get your chat ID by messaging your bot and visiting:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
-
Add
TELEGRAM_CHAT_IDto.env.
Run the dashboard and bot separately:
poetry run python -m sms-dashboard.app
poetry run python -m sms-dashboard.botOr run both with one command (process manager):
poetry run sms-devOpen your browser at http://127.0.0.1:5000.
Important: Gunicorn should be pointed directly at the Flask app instance, not at the process manager script.
Run with Gunicorn:
poetry run sms-prodIf your Flask app uses a different entrypoint, adjust sms-dashboard.app:app accordingly.
Create /etc/systemd/system/gammu-sms-web.service:
[Unit]
Description=Gammu SMS Web Manager (Gunicorn)
After=network.target
[Service]
User=<your-user>
Group=www-data
WorkingDirectory=/home/<your-user>/<your-repository-directory>
Restart=on-failure
Environment=POETRY_VIRTUALENVS_IN_PROJECT=true
ExecStart=/usr/bin/poetry run sms-prod
[Install]
WantedBy=multi-user.targetReload and start:
sudo systemctl daemon-reload
sudo systemctl start gammu-sms-web
sudo systemctl enable gammu-sms-web
sudo systemctl status gammu-sms-webMIT License. See LICENSE.
- Control the IP shown in Telegram welcome via
SERVER_IPin.env. - If unset, falls back to
APP_PUBLIC_URLor active interface IP.