DEV Community

anusha
anusha

Posted on

I Gave My SIM Card a Say in My Data Plan

The text arrived at 11:47 PM on a Sunday: "You have exceeded your monthly data allowance." Not a warning. A receipt. The threshold had been crossed sometime that afternoon — the network knew the exact minute — and the alert showed up nine hours later, after the overage was already on my bill.

I've built enough against telecom APIs to know that latency isn't technical. The usage counters exist. The SMS pipe exists. What's missing is an actor: something that lives close enough to the SIM to see usage as it happens, remembers what it promised you last cycle, and is allowed to actually do something — not just notify.

So I built that actor. It's called SIMAgent, and the design constraint is right in the one-line pitch: the actor IS the SIM.

The most informed party in the room can't speak

Think about who knows what in a data plan:

  • The SIM knows its usage in real time — it's the thing being metered.
  • The carrier knows the plan, the thresholds, and the pricing.
  • You know none of the above until someone tells you — usually too late.

The fix isn't a better dashboard. Dashboards still require you to look. The fix is giving the SIM itself a durable agent: memory (usage counters, plan, alert history), a schedule (check thresholds hourly, reset on the billing boundary), a voice (SMS, and even phone calls), and hands (the ability to provision a plan upgrade through the Wireless API when you confirm).

What it actually does

SIMAgent is a TypeScript class — SIMAgent extends Agent — running on the Telnyx Edge runtime, one instance per SIM. Telnyx Wireless usage webhooks stream into it and update durable state. An hourly schedule checks the numbers; at 80% of the plan it texts you, not the other way around. When you text back asking whether an upgrade makes sense, it calls Telnyx Inference and answers in plain language, grounded in your real usage — not a marketing page. When you confirm, it calls the Wireless API itself and raises the data limit, then texts the confirmation. On the billing boundary it resets the counters and sends a summary. And if you'd rather talk than text, it answers the call through Call Control and speaks your usage history to you.

All of it ships in demo mode by default. Every SMS, call action, and provisioning call is simulated and logged, so the first time you run it, nothing costs anything.

Why Telnyx

I've built versions of this shape before, and the hard part was never the LLM. It was the plumbing around it: a database for state, a scheduler for the checks, a queue for the webhooks, separate API clients for messaging, voice, and SIM management, and signature verification bolted on at the end when someone remembered to ask about it.

On Telnyx, the agent runtime collapses most of that. this.getState() and this.setState() give me durable state with no database. this.every() gives me schedules that survive cold starts. this.env.TELNYX exposes messaging, wireless provisioning, and inference as one surface — that's what Telnyx means by AI Communications Infrastructure: the communications primitives and the AI primitives live in the same runtime, so one agent can perceive (webhooks), remember (durable state), decide (LLM), and act (SMS, voice, provisioning) in a single place.

The trust details are handled at the platform level too. In live mode, every inbound webhook is verified with an Ed25519 signature before the agent touches its state, and every action lands in a durable event log I can replay when something looks wrong. For something that can spend your money by upgrading your plan, that audit trail isn't a nice-to-have.

Demo first, live second

The whole thing is reproducible in about five minutes: clone the repo, copy the .env example, npm install, npm start, then npm run smoke. The smoke test exercises the full demo flow — usage ingest, threshold breach, alert, plan comparison, upgrade — and prints the simulated events as it goes. When you're ready for real behavior, set DEMO_MODE=false, add your API key, public key, and sender number from the Telnyx Portal, and restart.

What I'd build next

Three things, in order: fleet mode, where one agent class is activated per SIM across an entire deployment; anomaly detection on the usage stream, so the agent texts you when your pattern changes, not just your total; and voice-first escalation, where the agent calls you at 100% instead of waiting to be called.

The broader idea is bigger than SIMs. Any network endpoint with state — a number, a trunk, a room, a device — can be a durable agent that watches its own telemetry and acts on its own behalf. The SIM was just the endpoint whose neglect I'd personally paid for.

Repo is here: https://github.com/team-telnyx/telnyx-code-examples/tree/main/sim-agent — run the smoke test and see what your SIM would say if it could talk.

Top comments (0)