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")
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()andthis.getState()for sender/recipient state -
this.env.TELNYXfor zero-credential Telnyx API access
The [telnyx] binding in telnyx.toml handles API auth:
[telnyx]
binding = "TELNYX"
Then the agent can call:
await this.env.TELNYX.ai.openai.chat.createCompletion(...)
await this.env.TELNYX.messages.send(...)
No API key is hardcoded in the application code.
The main routes
-
POST /webhooks/smsreceives Telnyxmessage.receivedwebhooks -
POST /debug/messagesimulates an inbound SMS for testing -
GET /debug/stateinspects an actor state for a sender -
GET /health/livenessandGET /health/readinessare 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?"
}'
Response:
{
"action": "queued",
"from": "+15551230000",
"to": "+15559870000"
}
For real SMS, set your Telnyx Messaging Profile webhook URL to:
https://sms-support-agent-<id>.telnyxcompute.com/webhooks/sms
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.
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:
- Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/sms-support-agent-with-followup
- Agent SDK docs: https://developers.telnyx.com/docs/agent-sdk
- Agent SDK quickstart: https://developers.telnyx.com/docs/agent-sdk/quickstart
- Edge Compute docs: https://developers.telnyx.com/docs/edge-compute
- Messaging docs: https://developers.telnyx.com/docs/messaging
- Telnyx AI Inference docs: https://developers.telnyx.com/docs/inference
- Telnyx AI skills and toolkits: https://github.com/team-telnyx/ai
Top comments (0)