Back to all posts
EngineeringJuly 22, 202610 min readUpdated October 13, 2026

Inside the engine behind Aiva Chat's two-way SMS AI agent

Voice and chat live inside a session. SMS doesn't. Here's how our two-way SMS engine keeps a thread's context for hours or days, with nothing to hold onto.

AI
The Aiva Chat team
Aiva Chat
Person typing a text message on a smartphone
Photo by Priscilla Du Preez on Unsplash

Every other channel Aiva Chat runs on has a session. A phone call is a continuous connection: you hang up, it's over. A web widget conversation lives inside a browser tab. SMS has neither.

A customer can text a question, put their phone away, and reply six hours later from a different place, having forgotten they were mid-conversation. Whoever answers has to remember for them, and so does any AI helping them write the reply.

Language understanding we already had from voice and chat. The engineering problem behind two-way SMS AI is state: how do you hold a conversation with no connection to hold it on?

If you're deciding whether to let customers text your business number, the design choice that matters most is this one: by default, the AI drafts and a person on your team sends. Letting the AI handle appointment texts itself, through Booking by text, is something you opt into. Everything else here, from how threads are stored to how opt-outs and late-night texts are handled, was built around that default, and it shapes what you can and can't expect from texting in Aiva Chat.

What is Aiva Chat's two-way SMS engine?

It's the part of Aiva Chat that runs business texting on your own Twilio number. Customers text your number, the messages land in the same Conversations inbox as your calls, and your team replies from there.

The AI's role is specific. When a team member clicks Suggest a reply, Aiva Chat reads the thread and writes a draft, labelled for review. The person edits it if needed and sends it. A draft never goes out without that click.

The one exception is Booking by text, a per-assistant setting in Booking setup that's off until you turn it on. With it on, the AI replies to appointment texts on its own (or to every text, if you pick that option): it books, moves and cancels, says when an appointment is, offers open times, and adds people to the waitlist. A customer who asks for a person, is upset, or needs something it can't do is handed to your team with a notification. A reply from your team pauses the AI on that thread for 2, 12 or 24 hours, its replies are capped at 480 characters, and there are daily limits per customer and per assistant.

Around that, the engine does the work a business would otherwise forget:

  • It matches numbers to saved contacts, so a thread shows a name rather than digits.
  • It handles opt-out keywords like STOP and START and keeps a do-not-contact list.
  • It reads images and transcribes voice notes customers send.
  • It holds late-night texts until a reasonable hour for the recipient.

With Booking by text off, the SMS channel can't book, reschedule, or look up appointments; booking happens on calls and in website chat. Booking confirmations and appointment reminders go out by text automatically either way, from your own Twilio number. A customer can reply C to a reminder to confirm, and each reminder carries a link where they can move or cancel the appointment themselves. Apart from those and Booking by text replies, every conversational reply is a draft a person sends.

It suits businesses where customers already text: clinics, salons, home services, and anyone whose customers prefer a quick message to a call. Our post on why SMS still reaches customers chat can't covers the reach side.

How the SMS engine handles a thread

Step 1: A text arrives as a standalone event

On Twilio, every inbound message is a separate webhook. There's no connection between the text sent at 2:14 PM and the reply at 8:30 PM. As far as the transport layer is concerned, they could be from two different people. More on that layer in our post on the Twilio integration.

Step 2: It's stored against the business and the number

Each message is saved with the business it belongs to and the customer's number. A thread isn't a separate object with a timer; it's simply every message between that business and that number, in order. That's why there's no expiry: if the messages exist, the thread exists.

Step 3: The inbox shows the whole history

Opening a thread shows the full message history, the contact's name if they're saved, and any photos or files. If the sender isn't saved yet, the thread says so, and naming them once names them everywhere.

Step 4: A person asks for a draft

When a team member clicks Suggest a reply, Aiva Chat reads a window of the most recent messages, roughly the last twenty, plus the assistant's business details. It writes a short draft that continues the business's side of the conversation in the customer's language.

Step 5: The person reviews and sends

The draft is labelled "AI draft — read it before sending." The person edits and sends it. If the send fails, the draft stays in the box so it isn't lost.

Design choices that make the drafts useful

Read recent history, not everything

A customer who asked "anything tomorrow morning?" at lunch and replies "actually let's do afternoon instead" after dinner needs a draft that knows what "instead" refers to. A window of recent messages covers that. Bounding it keeps a years-long thread from swamping the draft or inflating OpenAI usage.

Never invent facts

The drafting instructions forbid prices, times, availability, or policies that don't already appear in the conversation or the business details. If the customer asks something the AI can't answer from what it knows, the draft says a colleague will confirm shortly rather than guessing.

Keep it short

Drafts are capped at about 320 characters. Longer texts split into multiple carrier segments and read like marketing. A short, plain reply is what customers expect from a business they text.

Answer what was actually sent

If the message being answered includes a photo or voice note, Aiva Chat describes the image or transcribes the audio and folds that into what the draft reads. A photo-only text would otherwise be invisible to the AI.

Flag risky drafts rather than block them

Because a person always reads the draft before sending, the right response to questionable content is a warning, not silent blocking. The human stays in charge of the final words.

Six hours is just the gap in our examples. A thread can pick back up after days just the same; the only bound is on how much recent history a draft reads.

What happens around every send

Opt-outs are automatic

A customer who texts exactly STOP, UNSUBSCRIBE, CANCEL, END, QUIT, or STOPALL gets one confirmation and goes on the do-not-contact list. START, YES, or UNSTOP reverses it. "Stop texting me" doesn't count, because carriers only recognize the exact keyword, so staff add those numbers by hand.

The do-not-contact list is checked every time

Aiva Chat checks the list before every text it sends. If the check can't run, the text isn't sent, and the person is asked to try again. Failing closed is the safe default for messaging rules.

Late-night texts are held, not dropped

Texts outside 8 AM to 9 PM in the recipient's time are held and sent when the window opens. A replying customer, a booking confirmation, or a person typing by hand after seeing a warning are exempt. Appointment reminder texts follow the same 8 AM to 9 PM window.

Two-way SMS AI use cases

The reply six hours later

Problem: A customer asks about weekend availability at lunch, then replies "afternoon works better" at 8 PM. How Aiva Chat handles it: The front desk opens the thread in the morning, clicks Suggest a reply, and gets a draft that knows the question was about the weekend. Outcome: A reply in seconds, without scrolling back or re-asking.

The photo of the problem

Problem: A home services customer texts a photo of a leak with "how bad is this?" How Aiva Chat handles it: The image is described for the draft, which acknowledges the leak and offers to have someone call to schedule a visit. Outcome: The customer feels heard, and the booking happens on a call.

The confirmation that gets a question back

Problem: A customer replies to a booking confirmation with "can we push this to 5?" How Aiva Chat handles it: The reply lands in the same thread as the confirmation. With Booking by text on, the AI checks 5 o'clock and moves the appointment in the thread. Otherwise, the draft points them to the self-service link in their confirmation or reminder, or asks them to call so Aiva Chat can move it, or staff change it in the dashboard. Outcome: The change is handled without anyone treating the reply as a dead-end notification. See our confirmation and follow-up SMS flow.

The accidental opt-out

Problem: A customer texts "STOP texting me please." How Aiva Chat handles it: It isn't an exact keyword, so it's not automatic. The team sees it and adds the number to the do-not-contact list by hand. Outcome: The customer's wish is respected without guessing at ambiguous messages.

Aiva Chat texting vs. auto-reply bots vs. manual texting

Manual texting from a phoneFully automated SMS botAiva Chat (drafts by default, opt-in Booking by text)
Who sends each messageA personThe botA person, after reviewing a draft; the AI for appointment texts if Booking by text is on
Speed of composing a replySlow on busy daysInstantFast, a draft in one click
Risk of a wrong or invented answerLowHigher, nobody checksLow: drafts are read first, and the booking AI only uses appointment tools
Replies at 3 AM without staffNoYesOnly with Booking by text on
Opt-out and quiet-hours handlingUp to the personDepends on the toolBuilt in
Shared inbox with callsNoRarelyYes
Books appointments by textIf the person does itSome doYes, with Booking by text on

Manual texting from a staff phone is personal and low-risk, but it's slow, scattered across devices, and leaves opt-outs and late-night sends to memory.

A fully automated bot is the right fit if you need instant replies with no staff at all. The trade-off is that nobody reads what it sends, and a confident wrong answer in writing is hard to take back.

Aiva Chat's approach sits between them. Drafting removes most of the typing, built-in rules handle compliance chores, and a person owns every word the AI drafts. The cost is that those texts aren't answered when nobody is around to send. Booking by text narrows that gap for appointments only: the AI answers them on its own, with the same booking rules as calls and website chat, and anything else still waits for your team.

How to set up two-way SMS in Aiva Chat

Step 1: Connect a Twilio number that can text

Texting runs on your own Twilio number, connected during Aiva Chat's six guided setup steps. See connecting Twilio and a number.

Step 2: Register for A2P 10DLC if you're in the US or Canada

US carriers require registration for business texting over standard local numbers. Twilio's A2P 10DLC guide explains the brand and campaign steps, and Aiva Chat has a registration tab in AI Training.

Step 3: Teach your assistant the business

Drafts use your assistant's business details, so hours, services, and policies should be in place. That's the same information your calls and chat use.

Step 4: Decide who answers the inbox

Unless Booking by text is handling them, a person sends every text, so decide who checks the Conversations inbox and how often. If you want the AI to answer appointment texts, turn on Booking by text in Booking setup. Filter by Text and Unread to find what needs a reply.

Step 5: Test it with your own phone

Text your number, ask for a draft, send a photo, try STOP and START, and send a text late at night to see the hold-and-send behavior. The SMS replies and opt-outs guide lists every keyword and setting.

Common business texting mistakes

Expecting texts to answer themselves

Aiva Chat only replies to texts on its own when Booking by text is on, and even then only about appointments by default. If nobody checks the inbox, other customers wait. Assign an owner and a response time, and point after-hours customers toward calls or website chat.

Sending drafts without reading them

The draft is a starting point. It won't invent facts, but it may be vaguer than you'd like or miss context you know. Read it, adjust it, then send.

Leaving booking by text undecided

Customers will ask to book by text. Either turn on Booking by text so the AI handles it, or, if you leave it off, have a standard reply that invites them to call, use website chat, or use the self-service link in their reminder, and keep staff ready to make changes in the dashboard.

Skipping 10DLC registration

Unregistered US business texting gets filtered or blocked by carriers. Register before you rely on SMS for confirmations and reminders.

Treating "stop texting me" as noise

Only exact keywords opt out automatically. Ambiguous requests still matter. Add those numbers to the do-not-contact list by hand.

SMS engine best practices

  • Set an inbox owner. Someone should check text threads several times a day.
  • Keep business details current. Drafts are only as accurate as what the assistant knows.
  • Edit before sending. Treat every draft as a first pass.
  • Decide on Booking by text. Turn it on, or have a line ready inviting customers to call or use website chat for changes.
  • Save contacts. Names make threads easier to scan and drafts more personal.
  • Respect quiet hours. Use "Send anyway" only when you're sure it's welcome.
  • Watch AI usage. Drafts, image reading, and transcription run on your OpenAI key.

Conclusion

We think suggest-a-reply is the right default for a small business, even though it costs you instant replies. A confident wrong answer in writing, sent at 3 AM with nobody watching, is harder to undo than a reply that waits until morning. That's why Booking by text is opt-in and limited to appointments by default, where the AI works from your real booking rules rather than its own guesses.

The trade-off is real, though: if nobody owns the inbox, texts sit unanswered. Before you advertise your number for texting, name the person who checks it and how often, and make sure US numbers have their 10DLC registration approved. The rest of the plumbing, opt-outs and quiet hours included, shares one system with every other channel.

Ready to try two-way texting on your own number?

The best test is the one from step 5: text your own number at lunch, reply after dinner, then click Suggest a reply and see whether the draft knows what you meant. Throw in a photo and a STOP for good measure.

Texting comes with every plan, so the trial includes it; Twilio bills each message to your own account. Read how SMS works in Aiva Chat, then start your 14-day free trial with no card, or book a demo if you want help with 10DLC registration first.

EngineeringVoiceML
Share
AI
Written by
The Aiva Chat team
Aiva Chat

Posts from the people building Aiva Chat in Rajkot — how the product works, what we have learned building it, and guides for getting the most out of an AI receptionist.

Rajkot, India · at Aiva Chat since 2024
More posts

FAQ

Common questions.

Still have questions?Contact us

Every text is stored against the business and the customer's phone number, and that stored history is the thread. There's no session with a timeout to expire. When someone on your team clicks Suggest a reply, Aiva Chat reads the recent messages in that thread, plus your assistant's business details, before drafting, so the draft knows what was already said.

Only if you turn on Booking by text, which is off by default. Then the AI replies on its own to texts about appointments (or to every text, if you choose), books, moves and cancels them, and hands anything it can't handle to your team. Its texts are marked Sent by AI. For every other text, the AI drafts a reply when a person clicks Suggest a reply, the draft is labelled for review, and nothing is sent until that person clicks send. Booking confirmations, appointment reminders, and the required STOP and START confirmations also go out automatically.

There's no cutoff on the thread itself. A conversation can pick back up after days or weeks, and the full history stays visible in the inbox. When drafting, the AI reads a bounded window of the most recent messages, which covers normal back-and-forth while keeping very long threads from overwhelming the draft or running up AI usage.

Yes, if you turn on Booking by text. The AI then books, moves and cancels appointments by text, tells customers when their appointment is, and offers open times, using the same booking rules as calls and website chat. With it off, the SMS channel can't book or reschedule, and booking happens on calls, website chat, and booking pages. Either way, confirmations and reminders go out by text automatically, and replying C to a reminder confirms the appointment.

It runs on the same OpenAI account as everything else, your own API key, and drafts from the same business details your assistant uses on calls and chat. The difference is the job: Suggest a reply produces a short draft for a person to send, under a carrier-friendly length. Booking by text, if you turn it on, does hold the conversation itself, but its only tools are appointment actions and hand-off to your team.

Aiva Chat reads images and transcribes voice notes in the message being answered, then uses that when drafting. A customer who texts a photo of a leaking pipe or a rash gets a draft that responds to what they actually sent. This processing runs on your OpenAI key, so it appears on your OpenAI bill like other AI usage.

Twilio handles delivery to and from carrier networks on your own Twilio number and account, and bills you directly for texts. Aiva Chat handles everything around the conversation: storing threads, matching numbers to contacts, drafting replies, checking the do-not-contact list, holding late-night sends, and processing opt-outs. US and Canadian numbers also need an approved A2P 10DLC registration.

Partly. Calls and texts land in the same Conversations inbox, so whoever replies can look up the earlier call before sending. The AI draft itself reads only the text thread and your business details, not the call. To change the booking itself, the customer can use their self-service link, call back so Aiva Chat can move it during the call, or, with Booking by text on, simply text.

Like this? Get more.

One email a month. Guides, engineering deep-dives and product updates. No fluff.

4,200+ subscribers. Unsubscribe anytime.