Cookbook¶
Worked, copy-pasteable recipes for building real things on siphon-smpp. Each recipe is pure SMPP (ESME ↔ SMSC) and uses only the Script API.
- Building an SMSC gateway — the headline recipe. A
commodity store-and-forward SMS gateway: credential-checked binds, prefix
routing to upstream binds, delivery-receipt correlation routed back to the
originating ESME, mobile-originated replies, and
alert_notificationhandling — all in ~200 lines of Python.
The two starting points in the repo¶
| Example | What it is |
|---|---|
examples/echo.py |
The hello-world: accept any bind, ack every submit_sm. Covered in the Quickstart. |
examples/gateway.py |
The full store-and-forward gateway. Walked through in Building an SMSC gateway. |
Patterns you'll reuse¶
These show up in every non-trivial script; the gateway recipe uses all of them.
- Closed-by-default auth — no
@smpp.on_bindmeans every bind is rejected; opt ESMEs in explicitly, and return a reason on reject so it's logged. See@smpp.on_bind. - Session maps in shared state — track
system_id → session_idinsiphon.cache, not a module dict, so it survives hot-reload and is shared across workers/replicas. - Your own id space — hand the ESME your
message_id, keep a correlation from the upstream id to it, and rewrite receipts on the way back. This is what makes DLRs routable regardless of what upstream assigns. - Translate outbound failures into a reply status — wrap
*_viasends intry/exceptand map failures toESME_RSUBMITFAIL(etc.) for the originating ESME, rather than letting the handler throw.
Start with Building an SMSC gateway.