<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rubarajan</title>
    <description>The latest articles on DEV Community by Rubarajan (@rubarajan).</description>
    <link>https://dev.to/rubarajan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F147488%2F9d879572-2931-4711-aba4-18182008499f.jpg</url>
      <title>DEV Community: Rubarajan</title>
      <link>https://dev.to/rubarajan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rubarajan"/>
    <language>en</language>
    <item>
      <title>Build Your Own AI Answering Machine</title>
      <dc:creator>Rubarajan</dc:creator>
      <pubDate>Sun, 02 Aug 2026 18:36:40 +0000</pubDate>
      <link>https://dev.to/rubarajan/build-your-own-ai-answering-machine-1cg</link>
      <guid>https://dev.to/rubarajan/build-your-own-ai-answering-machine-1cg</guid>
      <description>&lt;p&gt;AI can answer the phone on your behalf. When you can't pick up, it takes the call, greets the caller by introducing itself, and holds a natural voice conversation — following a &lt;strong&gt;persona you define in plain instructions&lt;/strong&gt;: how it should sound, what it should ask, and what it's allowed to do. You can join the call and take over from it at any moment.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Powers It
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Twilio&lt;/strong&gt; | &lt;strong&gt;Deepgram&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's the whole hardware-free stack: Twilio owns the phone line, Deepgram&lt;br&gt;
owns the voice conversation.&lt;/p&gt;

&lt;p&gt;A large portion of this can be built with open-source freeware and trial&lt;br&gt;
accounts. The bridge itself runs entirely on open-source tooling, and both&lt;br&gt;
paid services are free to try — a Twilio trial account comes with &lt;strong&gt;$15&lt;/strong&gt; in&lt;br&gt;
credit and a Deepgram trial with &lt;strong&gt;$200&lt;/strong&gt;, which is more than enough to build&lt;br&gt;
and test everything in this post end to end.&lt;/p&gt;


&lt;h2&gt;
  
  
  How Can We Do It?
&lt;/h2&gt;

&lt;p&gt;The entire answering machine is a bridge between two websockets: Twilio&lt;br&gt;
streaming the call audio to you, and the Deepgram Voice Agent doing the&lt;br&gt;
listening, thinking, and speaking.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Twilio takes the call
&lt;/h3&gt;

&lt;p&gt;Buy a Twilio phone number and point its incoming-call webhook at your server.&lt;br&gt;
When a call comes in you respond with TwiML — Twilio's XML instructions. The&lt;br&gt;
key instruction is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;Connect&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;Stream&lt;/span&gt; &lt;span class="na"&gt;url=&lt;/span&gt;&lt;span class="s"&gt;"wss://your-server/ws/screening"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/Connect&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;&amp;lt;Connect&amp;gt;&amp;lt;Stream&amp;gt;&lt;/code&gt; opens a &lt;strong&gt;bidirectional&lt;/strong&gt; websocket: Twilio sends you the&lt;br&gt;
caller's audio as base64-encoded μ-law frames, and any audio you send back is&lt;br&gt;
played to the caller. From this point the phone call is just a websocket.&lt;/p&gt;

&lt;p&gt;You decide &lt;em&gt;when&lt;/em&gt; to hand the call to the AI. Three natural triggers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ring the human first (&lt;code&gt;&amp;lt;Dial timeout="20"&amp;gt;&lt;/code&gt;) and fall through to the AI
when nobody answers.&lt;/li&gt;
&lt;li&gt;Answer with the AI immediately when nobody is available at all.&lt;/li&gt;
&lt;li&gt;Let a human click a "screen this call" button and redirect a ringing call
to the AI on demand.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Deepgram has the conversation
&lt;/h3&gt;

&lt;p&gt;On your server, open a second websocket to the &lt;strong&gt;Deepgram Voice Agent&lt;/strong&gt;&lt;br&gt;
(&lt;code&gt;wss://agent.deepgram.com/v1/agent/converse&lt;/code&gt;). This one service replaces the&lt;br&gt;
whole speech pipeline you'd otherwise assemble yourself — speech-to-text, a&lt;br&gt;
reasoning model, and text-to-speech — behind a single socket. You configure&lt;br&gt;
it with one settings message:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Audio&lt;/strong&gt; — μ-law at 8 kHz in and out, matching Twilio's telephony format
exactly. No transcoding needed: frames pass straight through.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Listen&lt;/strong&gt; — a Deepgram speech-recognition model transcribes the caller in
real time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Think&lt;/strong&gt; — a large language model drives the conversation. This is where
your &lt;strong&gt;persona&lt;/strong&gt; goes: the system prompt is
built from the instructions you wrote — who the AI is covering for, what
tone to take, what to collect, what it may and may not offer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Speak&lt;/strong&gt; — a Deepgram voice speaks the replies. The voice itself is part
of the persona, so different teams can sound different.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Greeting&lt;/strong&gt; — the exact opening line, including the required disclosure
that the caller is speaking with an automated assistant.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. The bridge
&lt;/h3&gt;

&lt;p&gt;Your server's job is now beautifully small: relay audio frames from the&lt;br&gt;
Twilio socket to the Deepgram socket, and relay the agent's audio back. Two&lt;br&gt;
details make it feel human:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Barge-in&lt;/strong&gt; — when the caller starts talking over the AI, send Twilio a
&lt;code&gt;clear&lt;/code&gt; event to flush the audio it hasn't played yet. The AI stops
mid-sentence instead of talking over the caller.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Function calling&lt;/strong&gt; — when the caller asks something that needs real data
("is there a pharmacy near me?"), the Voice Agent sends a function-call
request over the same socket. Your server runs the lookup and returns the
result, and the AI speaks it. Which functions exist is gated by the
persona, so a switched-off capability is never even offered to the model.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. The takeover
&lt;/h3&gt;

&lt;p&gt;Because the AI is just one leg of a normal Twilio call, a human can join it&lt;br&gt;
like any other call. Redirect the call back to an agent's line and the AI&lt;br&gt;
leg ends — same call, no hold music, no transfer, the caller never dials&lt;br&gt;
twice.&lt;/p&gt;




&lt;h2&gt;
  
  
  Here Is an Example
&lt;/h2&gt;

&lt;p&gt;Here's the same integration running inside our web app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The AI answering a live call&lt;/strong&gt; — the caller rang, nobody picked up, and&lt;br&gt;
the assistant took over. Everything the caller says streams onto the screen&lt;br&gt;
in real time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;📸 **&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy5otcygbnvh1v66lx4x7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy5otcygbnvh1v66lx4x7.png" alt="Screen which has a telephony integrated when call comes in with three options Answer, Reject or Screen" width="800" height="1557"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🎬 **&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6jy8lwxvsn2ndilyw0pz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6jy8lwxvsn2ndilyw0pz.gif" alt="A short recording of what it looks like when call comes in" width="700" height="1011"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Setting the persona&lt;/strong&gt; — the AI's greeting, voice, instructions, and&lt;br&gt;
capabilities are a form the user edits, not code. Change the instructions and&lt;br&gt;
the very next call follows them.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;📸 **&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmh6nsso0kf3il8hlfbxf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmh6nsso0kf3il8hlfbxf.png" alt="Option To Add persona description in the screen to control AI Persona" width="800" height="821"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;]**&lt;/p&gt;




&lt;h2&gt;
  
  
  Future Road Map
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Training Simulator for Teams&lt;/strong&gt; — the same voice pipeline pointed
inward: AI personas that play difficult callers so new team members
practice before their first real conversation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transcript Intelligence&lt;/strong&gt; — emotion and compliance tracking over the
live transcript, flagging risky phrases and caller frustration as they
happen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-Time Call Intelligence&lt;/strong&gt; — live coaching and insights driven by the
transcript and the AI's tool usage during the call.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-Filling UI&lt;/strong&gt; — forms that fill themselves from what the caller
says, captured as structured data while the conversation is still going. j&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>twilio</category>
      <category>deepgram</category>
    </item>
  </channel>
</rss>
