このプロジェクトは、Soracom Onyx LTE USBドングルを通じて受信したSMSメッセージを、Slackに自動で転送するPythonツールです。Raspberry Piを活用することで、IoTデバイスからの通知や重要なメッセージをリアルタイムでチームに共有できます。
- SMSの自動転送: USBドングルが受信したSMSメッセージを検知し、設定済みのSlackチャンネルに瞬時に転送します。
- シンプルなセットアップ: 依存パッケージのインストールと、簡単な設定ファイル (
config.json) の編集だけで動作します。 - Raspberry Pi対応: Raspberry Pi 4B+での動作を想定しており、省電力かつコンパクトな環境で運用可能です。
-
ハードウェア
- Raspberry Pi (4B+ 推奨)
- Soracom Onyx - LTE™ USB ドングル (SC-QGLC4-C1)
- nano SIMカード
-
ソフトウェア
- Network Manager
- Modem Manager
-
依存パッケージのインストール: 必要なパッケージをインストールします。
# 必要に応じて、OSとパッケージリストを更新 sudo apt update sudo apt upgrade -y # Network Manager, Modem Manager, pipをインストール sudo apt install network-manager modemmanager python3-pip -y # Pythonの依存パッケージをインストール pip3 install -r requirements.txt
-
セルラーネットワークの設定: Network ManagerとModem Managerを使用して、USBドングルがセルラーネットワークに接続できるよう設定します。
-
設定ファイルの準備:
config_sample.jsonをconfig.jsonとしてコピーし、SlackトークンとチャンネルIDを設定します。cp config_sample.json config.json # config.json を編集して slack.token と slack.channel を設定する chmod 600 config.json # 他ユーザーから保護
キー 説明 slack.tokenSlack Bot Token ( xoxb-...)slack.channel転送先チャンネル (例: #alerts)general.intervalドングルのポーリング間隔 (秒) -
パスのカスタマイズ:
sms2slack.serviceおよびwwan_reconnect.service内のExecStartパスを、実際のインストール先に合わせて変更します。デフォルトは/opt/sms-transfer/を想定しています。また、
wwan_reconnect.serviceが参照する環境ファイルを作成します。sudo mkdir -p /etc/sms-transfer echo "CONNECTION_NAME=<your-connection-name>" | sudo tee /etc/sms-transfer/env sudo chmod 600 /etc/sms-transfer/env # 接続名の確認: nmcli c show
-
サービスの構成: systemdサービスファイルをコピーし、デーモンをリロードします。
sudo cp sms2slack.service /etc/systemd/system/ sudo cp wwan_reconnect.service /etc/systemd/system/ sudo systemctl daemon-reload
注意:
sms2slack.serviceはデフォルトでUser=piで動作します。異なるユーザーで実行する場合はサービスファイルを編集してください。 -
ハードウェアの接続: Soracom Onyx LTE USBドングルにnano SIMカードを挿入し、Raspberry Piに接続します。
-
サービスの開始とテスト: サービスを開始し、動作を確認します。
sudo systemctl start sms2slack.service sudo journalctl -u sms2slack.service -f
-
サービスの有効化: システム起動時にサービスが自動で開始されるように設定します。
sudo systemctl enable sms2slack.service sudo systemctl enable wwan_reconnect.service
| 症状 | 確認コマンド |
|---|---|
| SMSが届かない | mmcli -L でモデムが認識されているか確認 |
| Slackに転送されない | journalctl -u sms2slack -f でエラーを確認 |
| 接続が切れる | nmcli c show で接続名を確認し、/etc/sms-transfer/env の CONNECTION_NAME と一致しているか確認 |
| サービスが起動しない | systemctl status sms2slack.service で詳細を確認 |
このプロジェクトは、株式会社システムゼウスが公開しているSMSForwardingBotを参考にさせていただきました。心より感謝申し上げます。
本プロジェクトはMITライセンスのもとで公開されています。詳細はLICENSE.txtファイルをご覧ください。
This project is a Python tool that automatically relays SMS messages received via a Soracom Onyx LTE USB dongle to Slack. By using a Raspberry Pi, you can share notifications and important messages from IoT devices with your team in real time.
- Automatic SMS Forwarding: Detects SMS messages received by the USB dongle and instantly forwards them to a configured Slack channel.
- Easy Setup: The tool is operational with a simple installation of dependencies and a quick edit of the configuration file (
config.json). - Raspberry Pi Compatibility: Designed for use with a Raspberry Pi 4B+, offering a low-power and compact solution.
-
Hardware
- Raspberry Pi (4B+ Recommended)
- Soracom Onyx - LTE™ USB Dongle (SC-QGLC4-C1)
- nano SIM card
-
Software
- Network Manager
- Modem Manager
-
Install Dependencies: Install the necessary packages.
# Update the OS and package lists as needed sudo apt update sudo apt upgrade -y # Install Network Manager, Modem Manager, and pip sudo apt install network-manager modemmanager python3-pip -y # Install Python dependencies pip3 install -r requirements.txt
-
Configure Cellular Network: Use Network Manager and Modem Manager to configure the USB dongle to connect to the cellular network.
-
Prepare the Configuration File: Copy
config_sample.jsontoconfig.jsonand fill in your Slack token and channel.cp config_sample.json config.json # Edit config.json to set slack.token and slack.channel chmod 600 config.json # Protect from other users
Key Description slack.tokenSlack Bot Token ( xoxb-...)slack.channelTarget channel (e.g. #alerts)general.intervalDongle polling interval in seconds -
Customize Paths: Update the
ExecStartpath in bothsms2slack.serviceandwwan_reconnect.serviceto match your installation directory. The default assumes/opt/sms-transfer/.Also create the environment file used by
wwan_reconnect.service:sudo mkdir -p /etc/sms-transfer echo "CONNECTION_NAME=<your-connection-name>" | sudo tee /etc/sms-transfer/env sudo chmod 600 /etc/sms-transfer/env # Check your connection name: nmcli c show
-
Configure Services: Copy the service files and reload the daemon.
sudo cp sms2slack.service /etc/systemd/system/ sudo cp wwan_reconnect.service /etc/systemd/system/ sudo systemctl daemon-reload
Note:
sms2slack.serviceruns asUser=piby default. Edit the service file if your deployment user is different. -
Connect Hardware: Insert a nano SIM card into the Soracom Onyx LTE USB dongle and connect it to a USB port on the Raspberry Pi.
-
Start and Test the Service: Once configured, start the service and check its operation.
sudo systemctl start sms2slack.service sudo journalctl -u sms2slack.service -f
-
Enable the Service: Configure the service to start automatically on system boot.
sudo systemctl enable sms2slack.service sudo systemctl enable wwan_reconnect.service
| Symptom | Command |
|---|---|
| No SMS detected | mmcli -L — check modem is recognized |
| Not forwarding to Slack | journalctl -u sms2slack -f — check for errors |
| Connection drops | nmcli c show — verify connection name matches CONNECTION_NAME in /etc/sms-transfer/env |
| Service won't start | systemctl status sms2slack.service — check detailed status |
This project was inspired by the SMSForwardingBot published by System Zeus Inc.. We extend our sincere gratitude for their excellent tool.
This project is licensed under the MIT License. See the LICENSE.txt file for details.