SMS Gateway
Interact with a local sms-gate.app instance to send and receive SMS through an Android device.
Setup
Requires environment variables:
- -
SMS_GATE_URL — Your gateway URL (e.g., http://192.168.50.69:8080) - INLINECODE2 — HTTP Basic Auth username
- INLINECODE3 — HTTP Basic Auth password
Quick Start
Send an SMS:
CODEBLOCK0
Check delivery status:
CODEBLOCK1
List recent messages:
CODEBLOCK2
Operations
Sending SMS
Use scripts/send_sms.py:
CODEBLOCK3
Phone numbers can include + prefix (will be normalized). Delivery report is true by default.
Checking Status
Use scripts/check_status.py with the message ID returned from send:
CODEBLOCK4
States: Pending → Sent → Delivered (or Failed)
Listing Messages
Use scripts/list_messages.py:
CODEBLOCK5
Shows both sent (📤) and received (📥) messages with their current state.
Managing Webhooks
Use scripts/manage_webhooks.py:
CODEBLOCK6
API Reference
See references/api.md for complete endpoint documentation.
Common Patterns
Send with status check:
CODEBLOCK7
Health check:
CODEBLOCK8
Receiving SMS (Incoming)
The sms-gate.app API doesn't store message content - it only delivers via webhooks. To receive incoming SMS:
Option 1: Webhook Server + ngrok (Recommended)
1. Start the webhook receiver:
CODEBLOCK9
2. Expose via ngrok:
CODEBLOCK10
3. Configure webhook:
CODEBLOCK11
Now incoming SMS will be printed to the webhook server console.
Option 2: Local Network (Same WiFi)
If Pixel 3 and Mac are on same network:
CODEBLOCK12
Notes
- - The Android device must have SMS capability and be on the same network (or accessible via tunnel like Cloudflare)
- Webhooks require HTTPS for remote access (ngrok provides this)
- Message content is only available via webhooks, not stored in
/messages API - Message IDs are URL-safe strings returned after sending
SMS 网关
通过本地 sms-gate.app 实例与 Android 设备交互,实现短信的发送与接收。
环境配置
需要设置以下环境变量:
- - SMSGATEURL — 网关地址(例如:http://192.168.50.69:8080)
- SMSGATEUSER — HTTP 基本认证用户名
- SMSGATEPASS — HTTP 基本认证密码
快速上手
发送短信:
bash
python3 scripts/send_sms.py +41787008998 来自 OpenClaw 的问候!
查询投递状态:
bash
python3 scripts/check_status.py VdHHQ3nlNwDZ-W9SNuLzm
查看最近消息:
bash
python3 scripts/list_messages.py 20
操作指南
发送短信
使用 scripts/send_sms.py:
bash
python3 scripts/send_sms.py <电话号码> <消息内容> [投递报告]
电话号码可包含 + 前缀(系统会自动规范化)。投递报告默认值为 true。
查询状态
使用 scripts/check_status.py,传入发送时返回的消息 ID:
bash
python3 scripts/check_status.py <消息ID>
状态流转:待发送 → 已发送 → 已送达(或 发送失败)
查看消息列表
使用 scripts/list_messages.py:
bash
python3 scripts/list_messages.py [数量限制]
显示已发送(📤)和已接收(📥)的消息及其当前状态。
管理 Webhook
使用 scripts/manage_webhooks.py:
bash
查看已配置的 webhook
python3 scripts/manage_webhooks.py list
添加入站短信 webhook
python3 scripts/manage_webhooks.py add sms:received https://your-server.com/sms
添加投递确认 webhook
python3 scripts/manage_webhooks.py add sms:delivered https://your-server.com/delivered
删除 webhook
python3 scripts/manage_webhooks.py delete sms:received
API 参考文档
完整接口文档请参阅 references/api.md。
常见模式
发送并查询状态:
bash
发送并获取消息 ID
MSG
ID=$(python3 scripts/sendsms.py +41787008998 测试 2>&1 | grep ID: | awk {print $3})
等待几秒后查询状态
sleep 5
python3 scripts/check
status.py $MSGID
健康检查:
bash
python3 scripts/health.py
接收短信(入站)
sms-gate.app API 不存储消息内容,仅通过 webhook 进行投递。接收入站短信的方法如下:
方案一:Webhook 服务器 + ngrok(推荐)
1. 启动 webhook 接收器:
bash
python3 scripts/webhook_server.py 8787
2. 通过 ngrok 暴露服务:
bash
ngrok http 8787
复制 https://xxxx.ngrok-free.app 地址
3. 配置 webhook:
bash
python3 scripts/manage_webhooks.py add sms:received https://xxxx.ngrok-free.app/sms-received
现在,入站短信将显示在 webhook 服务器控制台中。
方案二:本地网络(同一 WiFi)
如果 Pixel 3 和 Mac 处于同一网络:
bash
获取 Mac IP 地址
ipconfig getifaddr en0
直接配置 webhook(如果网关允许 HTTP)
python3 scripts/manage_webhooks.py add sms:received http://
:8787/sms-received
注意事项
- - Android 设备需具备短信功能,并与网关处于同一网络(或可通过 Cloudflare 等隧道访问)
- Webhook 需要 HTTPS 进行远程访问(ngrok 可提供此功能)
- 消息内容仅通过 webhook 获取,不会存储在 /messages API 中
- 消息 ID 是发送后返回的 URL 安全字符串