DEV Community

Sonam
Sonam

Posted on

Build an AI Snooze Reminder Agent on Telnyx Edge Compute

Most reminder examples stop at "send this message later."

This one goes a little further.

The scheduled-reminder-agent example sends an SMS reminder, waits for the user's reply, uses Telnyx AI Inference to classify whether the reply means "snooze" or "acknowledged," and then either marks the reminder done or schedules the next reminder with adaptive timing.

Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/scheduled-reminder-agent

What it does

The app runs on Telnyx Edge Compute with the Telnyx Agent SDK.

The flow:

POST /remind
  -> ReminderAgent.scheduleReminder()
  -> this.schedule(delay, "sendReminder")
  -> Telnyx Messaging sends the SMS
  -> user replies by SMS
  -> /webhooks/sms
  -> ReminderAgent.receiveReply()
  -> Telnyx AI Inference classifies intent
  -> reminder is acknowledged or snoozed
Enter fullscreen mode Exit fullscreen mode

One actor instance owns one recipient's reminder state.

That means active reminders, snooze count, reply status, and scheduled work live together instead of being split across a webhook server, queue, scheduler, and database.

Agent SDK primitives used

The ReminderAgent extends the Agent SDK Agent class from @telnyx/edge-runtime.

It uses:

  • this.schedule() for durable reminder delivery and reply timeouts
  • this.setState() and this.getState() for per-phone-number reminder state
  • this.env.TELNYX.messages.send() for SMS
  • this.env.TELNYX.ai.openai.chat.createCompletion() for snooze detection

The [telnyx] binding in telnyx.toml gives the function a pre-authenticated Telnyx client:

[telnyx]
binding = "TELNYX"
Enter fullscreen mode Exit fullscreen mode

So the application code does not hardcode an API key.

Main routes

  • POST /remind schedules a new SMS reminder
  • POST /webhooks/sms receives Telnyx inbound SMS replies
  • POST /cancel cancels a pending reminder
  • POST /debug/remind schedules a short test reminder
  • POST /debug/reply simulates an inbound SMS reply
  • GET /debug/state inspects actor state
  • GET /health/liveness and GET /health/readiness are health checks

Try it

After deploying with telnyx-edge ship, schedule a reminder:

curl -X POST https://scheduled-reminder-agent-<id>.telnyxcompute.com/remind \
  -H "Content-Type: application/json" \
  -d '{
    "to":"+15551230000",
    "from":"+15559870000",
    "message":"Time for your meeting",
    "delay_minutes":5
  }'
Enter fullscreen mode Exit fullscreen mode

Then simulate a snooze reply:

curl -X POST https://scheduled-reminder-agent-<id>.telnyxcompute.com/debug/reply \
  -H "Content-Type: application/json" \
  -d '{
    "from":"+15551230000",
    "text":"snooze for 2 hours"
  }'
Enter fullscreen mode Exit fullscreen mode

Inspect the state:

curl "https://scheduled-reminder-agent-<id>.telnyxcompute.com/debug/state?from=+15551230000"
Enter fullscreen mode Exit fullscreen mode

Adaptive snoozing

If the user says something specific like "snooze for 2 hours," the model extracts that delay.

If the user just says "later" or "not now," the agent uses exponential backoff:

30 minutes -> 1 hour -> 2 hours -> 4 hours -> 8 hours
Enter fullscreen mode Exit fullscreen mode

That makes the reminder less repetitive over time.

Production notes

Before using this in production, I would add:

  • webhook signature verification
  • SMS opt-out and consent handling
  • timezone-aware scheduling
  • idempotency for reminder creation and outbound sends
  • retry handling for failed SMS delivery
  • max snooze and escalation rules
  • PII-safe logs and retention policies

But as a starter pattern, this is a clean way to build scheduled agent workflows on Edge Compute.

Resources:

Top comments (0)