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

Aiva Chat + Twilio: what's actually happening under the hood

How the Aiva Chat Twilio integration works: Twilio carries calls and texts, Aiva Chat runs the conversation on your OpenAI key. Here's the split, step by step.

AI
The Aiva Chat team
Aiva Chat
Close-up of server cooling fans in a data center
Photo by Winston Chen on Unsplash

On our integrations page, Twilio gets one line: phone numbers, inbound and outbound calls, SMS, recording, and transfers. That's true, and it's also easy to misread as "Twilio runs the AI." It doesn't.

The Aiva Chat Twilio integration is a division of labour. Twilio is the phone company layer: it owns the numbers, connects to carrier networks, and carries audio and text in both directions. Aiva Chat owns the conversation: it decides whether to answer, listens, thinks, talks back, books appointments, and decides when a person should take over.

The most useful thing to understand is the handover point: the moment a ringing phone on Twilio's network becomes a live audio stream that Aiva Chat is talking into. Most of what follows hangs off that moment.

You don't need to know any of this to use Aiva Chat. Once your Twilio account is connected, you rarely open Twilio's console. But if you're evaluating Aiva Chat against building something yourself, or you just like knowing what you're paying for, this is the actual split.

What is the Aiva Chat Twilio integration?

The Aiva Chat Twilio integration connects your own Twilio account to Aiva Chat so that calls and texts to your Twilio numbers are handled by your AI assistant.

You add your Twilio Account SID and Auth Token in the dashboard. From there Aiva Chat can list numbers you already own on Twilio, buy new ones, and point each number's settings at Aiva Chat when you link it to an assistant. Linking does the Twilio configuration for you, so you never edit webhook URLs by hand unless you want to route calls through another system.

It's built this way, on your account rather than ours, for two reasons:

  • Billing transparency. Twilio bills you directly at its published rates. Aiva Chat adds no markup and no usage fees of its own; you pay Aiva Chat only for your plan.
  • Ownership. The numbers are yours. If you stop using Aiva Chat, they stay active in your Twilio account.

The integration covers phone calls and SMS. The website widget's voice mode is different: it connects the visitor's browser to the AI model directly over WebRTC, with no phone network involved, so Twilio isn't part of it.

How a call travels through Twilio and Aiva Chat

Here's one inbound call, end to end.

Step 1: The call reaches Twilio

A customer dials your number. Their carrier hands the call to Twilio, which owns the number. Twilio then sends Aiva Chat a webhook saying a call has arrived, signed with your account's credentials.

Step 2: Aiva Chat checks the request and decides how to answer

Aiva Chat verifies Twilio's request signature, then runs admission checks: is the plan or trial active, is your OpenAI key present and working, and is the call within your plan's concurrent-call limit? It also applies your routing, such as ringing desk phones first during business hours or sending after-hours calls to voicemail.

Step 3: Recording notice, then a live audio stream

If recording is on, Twilio plays a spoken notice before recording starts. Aiva Chat then tells Twilio to open a live, two-way audio stream to Aiva Chat's servers using Twilio's Media Streams, which carries raw call audio over WebSockets in near real time.

Step 4: The conversation runs on your OpenAI key

Aiva Chat bridges that audio straight to OpenAI's real-time voice model on your API key. The phone audio format and the model's audio format match, so there's no conversion step in between. Aiva Chat handles interruptions, keeps the transcript, and runs tools such as checking availability or booking.

Step 5: The call ends and Aiva Chat writes it up

When the call ends, Aiva Chat saves the transcript, writes a summary with sensitive details scrubbed, sets the outcome, and fires any webhooks you've set up. Twilio prices the call shortly afterwards, which is why a brand-new call may show no cost for a few minutes.

What Twilio handles

Phone numbers

Every number in Aiva Chat is a Twilio number underneath, whether you bought it in the dashboard, synced it from your account, or had it ported in. Twilio charges the monthly rental.

Carrying the audio

Twilio connects to carrier networks and streams the caller's audio to Aiva Chat and Aiva Chat's audio back, for as long as the call lasts. It doesn't interpret any of it.

Recording

When recording is on, Twilio captures the audio. Aiva Chat plays it back in the dashboard through short-lived links, so a copied URL stops working.

Transfers and phone keys

When Aiva Chat decides a call should go to a person, Twilio performs the transfer. When the assistant needs to get through another business's phone menu, Twilio sends the key presses.

SMS delivery

The same number can carry texts. Twilio delivers messages to and from carrier networks. Remembering the conversation between messages is Aiva Chat's job, and so is deciding when to send: booking confirmations and appointment reminders go out from your Twilio number automatically, within 8 AM to 9 PM quiet hours, and a customer who replies "C" confirms the appointment. With Booking by text on, Aiva Chat also answers appointment texts itself; replies to other incoming texts stay as drafts a staff member sends.

What Aiva Chat handles

Deciding whether and how to answer

Admission checks, business hours, desk-phone ringing, and voicemail routing all happen in Aiva Chat before the AI says a word. A declined call is logged with its reason, such as a missing OpenAI key.

The real-time conversation

Listening, understanding, replying, and handling interruptions run through Aiva Chat's bridge to the OpenAI model. This is the part that has to feel like a normal phone conversation, where people take turns quickly and cut in on each other.

Actions mid-call

Booking into Aiva Chat's appointment book and your Google Calendar, looking up a returning caller, calling your own systems through custom actions, transferring, and ending the call are all decided on Aiva Chat's side.

Everything after the call

Transcripts, summaries, PII scrubbing, topic tagging, call quality flags, incident alerts, and webhooks are Aiva Chat's work. Twilio has finished its job once the audio stops.

Why we built our own bridge

An earlier version of Aiva Chat ran calls through a third-party hosted voice platform that sat between Twilio and the AI. It worked, but every call depended on a system we didn't control, and when something went wrong, the cause was hidden inside someone else's pipeline.

We replaced it with our own bridge: Twilio's audio stream in, OpenAI's real-time model, audio back out. That gave us a few things that matter to customers:

  • Fewer moving parts per call. One service between Twilio and the model, so there are fewer places for a call to fail silently.
  • Visibility. When a call has a problem, we can see where, and raise an incident alert instead of guessing.
  • Clean failure handling. If a tool fails mid-call, the model still gets an answer so the caller isn't left in silence. If a caller hangs up during setup, no AI connection is opened for a call that's already gone.
  • Live controls. Supervisors can listen in on a live call and transfer it by hand, because the audio passes through Aiva Chat.

Twilio gets the call to us and the audio back to the caller. Everything that happens in between is ours, which is exactly why we wanted to own it.

Building on raw Twilio vs. using Aiva Chat

Building on raw Twilio yourselfAiva Chat on your Twilio account
Phone numbers and call audioYes, from TwilioYes, same Twilio account
Real-time AI conversationYou build and host the bridgeIncluded
Interruptions and turn-takingYou tune itHandled
Booking, transfers, take-a-messageYou write each oneBuilt in, configured in the dashboard
Transcripts, summaries, analyticsYou build storage and reportingIncluded
FlexibilityUnlimited, it's your codeLimited to what Aiva Chat supports plus custom actions and webhooks
Ongoing costEngineering time plus Twilio and AI usagePlan from $49 a month plus Twilio and OpenAI usage

Building on raw Twilio makes sense if you have engineers, unusual requirements, and the appetite to maintain a real-time audio system. You get total control, and nothing a product team decides can get in your way.

What Twilio gives you is the phone call. It doesn't give you the conversation, the booking flow, the handoff rules, the transcripts, or the analytics. Those are where most of the work lives, and they don't stay finished: models change, edge cases appear, and someone has to keep it all running. Our write-up on building vs. buying voice AI goes through the trade-offs in more depth.

For a small business without an engineering team, the honest comparison is usually between Aiva Chat and not answering the phone, not between Aiva Chat and a custom build.

How to connect Twilio to Aiva Chat

Step 1: Create or open your Twilio account

You need a Twilio account with its Account SID and Auth Token, both shown in the Twilio Console. Keep the Auth Token private; it works like a password.

Step 2: Add your credentials in Aiva Chat

Open Communication, then My Numbers, click Config Twilio, and paste both values. Each Twilio account can be linked to only one Aiva Chat account. Our guide to connecting Twilio and a phone number has the exact steps.

Step 3: Get a number

Buy a US, Canada, UK, or Australia number from inside Aiva Chat, or sync numbers you already own on Twilio. For other countries, get the number in Twilio first, then sync it.

A number answers only once it's linked. Linking also points the number's Twilio settings at Aiva Chat. Each assistant links to one number.

Step 5: Register for US texting if you need SMS

US and Canadian business texting, including reminder texts, needs carrier registration before messages go out. Follow the A2P 10DLC registration guide; calls work in the meantime.

Step 6: Test and watch the costs

Have the assistant call your phone, then check the call in your logs. Turn on the Cost column to see each call's Twilio and AI parts, as explained in OpenAI and Twilio usage.

Common Twilio setup mistakes

Editing webhook URLs by hand

Aiva Chat sets each number's Twilio webhooks when you link it. Changing them in Twilio's console breaks the connection. If you've changed them, use "Reset to Aiva Chat's default" in the number's panel.

Forgetting the OpenAI key

Calls are declined if no working OpenAI key is connected, because there's nothing to run the conversation. Connect the key first; the setup checklist lists it first for that reason.

Expecting texts to work immediately in the US

Numbers waiting on A2P 10DLC registration show "Texting pending." Calls work, but texts won't go out until registration completes on the carriers' timeline.

Linking one Twilio account to two Aiva Chat accounts

Each Twilio account can be linked to only one Aiva Chat account. If you run two businesses, use a separate Twilio account for each.

Releasing a number you still need

Releasing a number in Aiva Chat permanently releases it from Twilio. If you only want to stop using Aiva Chat, remove the configuration instead; the numbers stay active in your Twilio account.

Twilio and Aiva Chat best practices

  • Let Aiva Chat manage the webhooks. Don't edit number settings in Twilio unless you route calls elsewhere.
  • Set usage alerts in Twilio. Aiva Chat can't cap Twilio spending, but Twilio lets you set alerts on your own account.
  • Release numbers you don't use. Each one has a monthly rental.
  • Start US registration early. Carrier approval takes time, so begin it on day one if you need texting.
  • Check the Cost column weekly at first. It shows which calls and assistants cost more than you expect.
  • Read how texting works. Our look inside Aiva Chat's SMS engine explains why texts behave differently from calls.

Conclusion

The judgement we'd stand behind: Twilio is excellent at the part of a phone call nobody notices, and the part callers do notice, the pause before a reply or a clumsy interruption, lives on the other side of the WebSocket. That's why we replaced a hosted voice platform with our own bridge rather than adding another layer.

For you, the practical decision is whether to own that conversation layer. If you have engineers and requirements Aiva Chat can't meet through custom actions and webhooks, building on raw Twilio is a fair choice. If you don't, the risk to watch is operational: edited webhook URLs, a missing OpenAI key, or US texting registration left until the last week. Those cause most of the failed setups we see.

Ready to put your Twilio number to work?

Hear the stack before you wire anything up: +1 (970) 972-0974 runs on exactly the path described above.

To try it on your own account, start a 14-day free trial with no card. Paste in your Account SID and Auth Token, link a number, and check the Cost column after your first test call to see the Twilio and AI parts split out. Plans run $49 to $199 a month, separate from what Twilio and OpenAI bill you. If you'd like to walk through the architecture against your own requirements first, book a demo.

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

Twilio carries the audio and the SMS text as the transport layer, delivering the call or message to Aiva Chat and carrying replies back. Understanding what's said and deciding how to respond happens on Aiva Chat's side, using OpenAI's real-time voice model on your own OpenAI key. Twilio also stores call recordings when recording is on, since recording is a Twilio feature.

You can, and some teams do. Twilio handles telephony very well: numbers, routing, and streaming call audio. But it gives you raw audio, not a conversation. You'd still need to connect a speech model, handle interruptions, run tools like booking mid-call, write transcripts, and handle every failure case. That conversation layer is the part Aiva Chat builds.

Yes, and that's where Twilio earns its place. Transfers to a department or your desk phones, call recording after a spoken notice, and pressing phone keys to get through another business's menu all run over Twilio. Aiva Chat decides when to do each one, and Twilio carries it out on the real phone line.

Every request Twilio sends Aiva Chat is checked against Twilio's request signature before Aiva Chat acts on it. Twilio signs each webhook with your account's credentials, so a forged request pretending to be a new call or an incoming text fails the check and gets rejected instead of starting a conversation or touching your data.

Yes. Aiva Chat runs on your own Twilio account, so Twilio bills numbers, call minutes, and texts to you directly at its published rates, with no Aiva Chat markup. Once connected, you can buy a US, Canada, UK, or Australia number in the Aiva Chat dashboard, sync numbers you already have on Twilio, or ask our team to port a number from another carrier.

It shares the same Twilio number and account, but it's a different engineering problem. A call is one continuous connection, while texts are separate events that can arrive hours apart. Booking confirmations and reminder texts go out automatically from your number. With Booking by text turned on, the AI also replies to appointment texts on its own, booking, moving, and cancelling for the number that texted in; other texts wait for a staff member, who can click "Suggest a reply", edit, and send. US and Canadian business texting needs A2P 10DLC registration.

Aiva Chat raises incident alerts for problems like dropped calls, tool errors, or AI-provider issues, so you hear about them rather than finding out from a customer. If a transfer goes unanswered, busy, or fails, the call reconnects to the assistant, which offers to take a message and creates a follow-up task instead of leaving the caller on a dead line.

Twilio charges you for each number's monthly rental, call minutes including transferred calls, texts, recordings, and US texting registration fees, at the rates on its own pricing pages. Aiva Chat shows an estimated cost per call in your call logs, split into the Twilio part and the AI part. Your Aiva Chat plan, from $49 a month, is billed separately.

Like this? Get more.

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

4,200+ subscribers. Unsubscribe anytime.