DEV Community

Sonam
Sonam

Posted on

Build an SMS Support Agent with Follow-Up on Telnyx Edge Compute

A lot of AI support demos stop after one reply.

Customer asks a question. Model answers. Demo done.

Real support usually needs a little more than that. You need message history, background processing, a way to send the reply, and sometimes a follow-up if the customer goes quiet.

This example builds that flow as an SMS support agent on Telnyx Edge Compute.

Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/sms-support-agent-with-followup

What it does

The app receives inbound SMS messages, routes each sender to a durable Agent SDK actor, calls Telnyx AI Inference, sends a reply through Telnyx Messaging, and schedules a 24-hour follow-up.

The flow:

Inbound SMS
  -> /webhooks/sms
  -> SupportAgent.receive()
  -> this.messages.add()
  -> this.queue("process")
  -> Telnyx AI Inference
  -> Telnyx Messaging reply
  -> this.schedule(24h, "followup")
Enter fullscreen mode Exit fullscreen mode

The important part is that the webhook does not need to wait on the LLM. It stores the message and queues the work, so the webhook can acknowledge quickly.

Agent SDK primitives used

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

It uses:

  • this.messages.add() for durable conversation history
  • this.messages.toOpenAI() to format history for the model
  • this.queue("process") for background AI processing
  • this.schedule(86400, "followup") for the next-day check-in
  • this.setState() and this.getState() for sender/recipient state
  • this.env.TELNYX for zero-credential Telnyx API access

The [telnyx] binding in telnyx.toml handles API auth:

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

Then the agent can call:

await this.env.TELNYX.ai.openai.chat.createCompletion(...)
await this.env.TELNYX.messages.send(...)
Enter fullscreen mode Exit fullscreen mode

No API key is hardcoded in the application code.

The main routes

  • POST /webhooks/sms receives Telnyx message.received webhooks
  • POST /debug/message simulates an inbound SMS for testing
  • GET /debug/state inspects an actor state for a sender
  • GET /health/liveness and GET /health/readiness are health checks

Try the debug route

After deploying, you can simulate an inbound SMS:

curl -X POST https://sms-support-agent-<id>.telnyxcompute.com/debug/message \
  -H "Content-Type: application/json" \
  -d '{
    "from":"+15551230000",
    "to":"+15559870000",
    "text":"How do I send an SMS?"
  }'
Enter fullscreen mode Exit fullscreen mode

Response:

{
  "action": "queued",
  "from": "+15551230000",
  "to": "+15559870000"
}
Enter fullscreen mode Exit fullscreen mode

For real SMS, set your Telnyx Messaging Profile webhook URL to:

https://sms-support-agent-<id>.telnyxcompute.com/webhooks/sms
Enter fullscreen mode Exit fullscreen mode

Then text the Telnyx number.

The follow-up logic

The follow-up task runs 24 hours later.

It checks the last message in the durable conversation history. If the last message is still from the assistant, the customer has not replied since the AI answer, so the agent sends:

Did that solve your problem? Reply yes or no, or ask for a human.
Enter fullscreen mode Exit fullscreen mode

If the customer already replied, it skips the nudge.

That is the piece I like. The agent is not just a stateless webhook. It has memory and scheduled work.

Production notes

Before shipping this pattern in a real support workflow, I would add:

  • webhook signature verification
  • opt-out handling for SMS
  • idempotent outbound sends
  • rate limiting per phone number
  • human handoff rules
  • message retention policy
  • monitoring for queued and scheduled tasks

But as a starter pattern, this is a clean way to build an AI support agent that can answer, remember, and follow up.

Resources:

Top comments (0)