Build an SMS auto-reply bot that responds instantly to inbound messages. Keyword routing, business-hours logic, and webhook signature verification with the Telnyx Messaging API.

An SMS auto-reply bot is a webhook-driven service that receives an inbound text, chooses a response, and sends an SMS reply without human action. With the Telnyx Messaging API, Telnyx sends your app a message.received webhook, then your app replies through POST /v2/messages. The SMS API supports global messaging with 10DLC, toll-free, shortcodes, and high throughput, so one bot can handle after-hours, pricing, and support replies.
Use an SMS autoresponder when customers text outside office hours, ask for support, or need a routing answer. The bot can return a text message auto reply, route “hours” to a schedule, route “pricing” to sales, and send “help” to a support path. The logic runs in your app, so rules can match your queue, time zone, and consent process.
An SMS autoresponder listens for incoming text messages and sends back a pre-defined reply based on the content of the message. Telnyx receives the text on your number and sends your application an SMS webhook. Your application inspects the payload, selects the right response, and sends the reply back through the API.
The routing layer has two main jobs. Keyword routing maps words like “help,” “hours,” or “pricing” to specific responses. Business-hours logic changes the reply based on whether your team is available. During the day, the reply can point to a live support path. At night, it can set a clear response window.
An inbound SMS automation flow has three steps.
message.received webhook event. The payload includes the sender’s phone number, your Telnyx number, and the message text.POST /v2/messages with the sender’s number as the destination, your Telnyx number as the sender, and the generated response as the message body.No polling. No message queues. One webhook in, one API call out.
SMS auto-reply bot flow
There are three common ways to answer inbound SMS. The right fit depends on how much control you need over routing, timing, consent, and handoff.
| Approach | How it responds | Best fit |
|---|---|---|
| Manual inbox | An agent replies after opening the queue. | Low volume and staffed hours. |
| Fixed SMS autoresponder | Every inbound text gets the same reply. | Simple acknowledgments. |
| Telnyx webhook bot | Your app routes by keyword, consent state, and business hours. | Support, sales, and operations workflows. |
Everything below works with any language or framework. Your app needs to receive HTTP requests and make HTTP requests.
When a customer texts your Telnyx number, Telnyx sends a POST request to your configured webhook URL. The payload looks like this.
{
"data": {
"event_type": "message.received",
"payload": {
"direction": "inbound",
"type": "SMS",
"from": {
"phone_number": "+12125551234"
},
"to": [
{ "phone_number": "+13105559876" }
],
"text": "What are your hours?"
}
}
}
Your webhook handler should verify the request signature, check that the event_type is message.received, and extract the from.phone_number and text fields.
Once you have determined the response, send it back with a single API call.
curl -X POST https://api.telnyx.com/v2/messages \
-H "Authorization: Bearer YOUR_TELNYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "+13105559876",
"to": "+12125551234",
"text": "We'\''re open Monday-Friday 9 AM to 5 PM EST. Weekend hours: Saturday 10 AM - 2 PM. Closed Sundays."
}'
The from field is your Telnyx phone number. The to field is the customer’s number from the inbound webhook. A 200 response means the message has been accepted for delivery.
Telnyx signs every webhook request with an Ed25519 signature. Your application should verify this signature before processing the event to confirm the request came from Telnyx. The Telnyx SDKs handle this automatically. In Python, call client.webhooks.unwrap() with the raw request body and headers.
Start with deterministic rules. Normalize the inbound text, trim whitespace, and compare lower-case content against your routing table. Keep SMS auto reply copy direct. State the answer, the next step, and when a human will respond if one is needed.
Map high-intent words to specific replies. “Hours” can return the operating schedule. “Pricing” can return a sales link or sales phone number. “Help” can send a support path that changes by time of day. “Stop” and “Start” should update consent state before any other routing logic runs.
Use one source of truth for your business hours and time zone. If your team is open, the bot can point to a live queue or a phone number. If your team is closed, the bot can set a response window and capture the customer's message for follow-up the next business day.
When a customer texts your Telnyx number, Telnyx sends a POST request to your configured webhook URL. The payload includes the sender's phone number, your Telnyx number, and the message text.
{
"data": {
"event_type": "message.received",
"payload": {
"direction": "inbound",
"type": "SMS",
"from": {
"phone_number": "+12125551234"
},
"to": [
{ "phone_number": "+13105559876" }
],
"text": "What are your hours?"
}
}
}
Your webhook handler should verify the request signature, check that the event_type is message.received, and extract the from.phone_number and text fields.
Once your application determines the right response, send it back with a single API call.
curl -X POST https://api.telnyx.com/v2/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "+13105559876",
"to": "+12125551234",
"text": "We are open Monday-Friday 9 AM to 5 PM EST. Saturday 10 AM - 2 PM. Closed Sundays."
}'
The from field is your Telnyx phone number. The to field is the customer's number from the inbound webhook. A 200 response means the message has been accepted for delivery.
That is the entire round trip. Receive a webhook, send a reply.
client.webhooks.unwrap() with the raw request body and headers. Every event is signed with Ed25519. Cryptographically verify inbound messages with public-key verification built into the SDK.
The Messaging API delivers the complete message to your webhook. You own keyword routing, STOP/START handling, and business-hours logic.
Telnyx operates a private global IP network. Messages avoid unnecessary public internet hops, reducing latency and improving delivery reliability.
Pay for what you use. No inflated per-message fees or hidden platform surcharges.
| Feature | SMS autoresponder | Manual queue |
|---|---|---|
| Response time | Instant | Hours to overnight |
| After hours | Automated acknowledgment | No response until morning |
| Keyword routing | Yes, programmable | Manual triage |
| Compliance | STOP/START handled in code | Manual process |
Telnyx provides a working Python Flask example that implements keyword routing, business-hours logic, webhook signature verification, and opt-in/opt-out handling. Clone the sms-auto-reply-bot-python example from GitHub.
The example includes a webhook endpoint at /webhooks/sms, contextual response generation based on message keywords, and proper error handling for Telnyx API errors.
/webhooks/sms endpointTELNYX_API_KEY, TELNYX_PUBLIC_KEY, and TELNYX_PHONE_NUMBER environment variablesFull API documentation is available at developers.telnyx.com. For more on verification flows, see the WhatsApp OTP and SMS 2FA guides.
Build your SMS auto-reply bot todayOne webhook in, one API call out. No polling, no queues, no human in the loop.
Get started freeRelated articles