DEV Community

anusha
anusha

Posted on

Building an SMS Sentiment Escalation Agent on Telnyx Edge Compute

I wanted this demo to show a realistic support workflow: a customer texts in, an agent reads the tone of the message, and a human gets pulled in when the conversation is clearly going badly.

The sample puts the full messaging flow on Telnyx Edge Compute:

  • The request hits a deployed Telnyx Edge function.
  • SentimentAgent handles the message with the Agent SDK.
  • Telnyx AI Inference classifies the sentiment.
  • Actor-local SQL stores the message, score, reply, and escalation state.
  • Negative messages send an SMS alert to the ops number.

Why Put This on the Edge?

Sentiment analysis is often treated like analytics: run a job later, summarize the inbox, and tell the team what happened.

That is useful, but it misses the moment where automation can actually help. If a customer says "this is broken and nobody is helping me, I want a refund," you want the system to know immediately. The reply should be empathetic, the log should be updated, and a person should be alerted before the thread gets worse.

Edge Compute is a good fit because the logic runs where the event arrives. The webhook does not need to bounce through a separate backend before the first decision is made.

The sample flow is:

Inbound SMS
  -> Telnyx Edge Compute
  -> Agent SDK actor
  -> Telnyx AI Inference
  -> SQL sentiment log
  -> auto-reply
  -> human escalation when negative
Enter fullscreen mode Exit fullscreen mode

The Demo Experience

After deployment, you open the telnyxcompute.com URL and use the browser view to test the flow.

Send a positive message:

I love this app, just paid for a year
Enter fullscreen mode Exit fullscreen mode

Send a neutral one:

What are your hours?
Enter fullscreen mode Exit fullscreen mode

Then send a negative message:

this is broken and nobody is helping me, I want a refund
Enter fullscreen mode Exit fullscreen mode

The log updates with the sentiment label and score. Negative sentiment gets marked for escalation, and the UI shows the empathetic response the agent generated.

The escalation path sends SMS alerts through Telnyx Messaging so a human can jump in quickly.

What I Like About This Pattern

This sample is small, but the architecture scales to more serious workflows:

  • Customer support escalation
  • Refund and cancellation saves
  • Abuse or safety triage
  • After-hours monitoring
  • Routing high-value accounts to a human faster

You can also swap the sentiment prompt for another classifier. The same shape works for urgency detection, topic routing, language detection, or structured intake.

The key idea is that the AI decision is not sitting off to the side. It is inside the communication path.

Try It

The sample lives in the Telnyx code examples repo:

https://github.com/team-telnyx/telnyx-code-examples/tree/main/sentiment-analysis-agent

Run the type checks, deploy with telnyx-edge ship, open the deployed URL, and reset the live log before recording if you want a clean demo.

Point your Telnyx Messaging webhook at /webhooks/messaging, send an inbound SMS, and watch the agent classify, log, reply, and escalate from the deployed Edge function.

Top comments (0)