<?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: amitbhakt</title>
    <description>The latest articles on DEV Community by amitbhakt (@amitbhakt).</description>
    <link>https://dev.to/amitbhakt</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%2F4184425%2F15d74d5f-a655-4ee7-b160-f10f065ae47d.jpg</url>
      <title>DEV Community: amitbhakt</title>
      <link>https://dev.to/amitbhakt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amitbhakt"/>
    <language>en</language>
    <item>
      <title>How to Build a Real-Time WhatsApp Voice AI Agent in 90 Seconds</title>
      <dc:creator>amitbhakt</dc:creator>
      <pubDate>Wed, 14 Oct 2026 10:38:34 +0000</pubDate>
      <link>https://dev.to/amitbhakt/how-to-build-a-real-time-whatsapp-voice-ai-agent-in-90-seconds-1bg4</link>
      <guid>https://dev.to/amitbhakt/how-to-build-a-real-time-whatsapp-voice-ai-agent-in-90-seconds-1bg4</guid>
      <description>&lt;p&gt;Connecting a real-time voice AI agent to WhatsApp usually sounds simple until you actually try to build it.&lt;/p&gt;

&lt;p&gt;Within minutes, you run into the reality of Meta's telephony plumbing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Digging through Meta Business Manager for obscure IDs.&lt;/li&gt;
&lt;li&gt;Manually spinning up tunnels and pasting verification tokens.&lt;/li&gt;
&lt;li&gt;Enabling voice calling flags via Graph API endpoints.&lt;/li&gt;
&lt;li&gt;Handling WebRTC SDP offer/answer exchanges and SRTP audio.&lt;/li&gt;
&lt;li&gt;Diagnosing weird 5-second ringing delays before a call even connects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I got tired of repeating this setup for every voice experiment, so I built an open-source CLI called &lt;strong&gt;WAVoice&lt;/strong&gt; to collapse the entire setup into a single command.&lt;/p&gt;

&lt;p&gt;Here is how to get a live WhatsApp AI agent answering calls in under 90 seconds.&lt;/p&gt;




&lt;h3&gt;
  
  
  What You Need
&lt;/h3&gt;

&lt;p&gt;You only need 3 credentials:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Meta System User Access Token&lt;/strong&gt; (with &lt;code&gt;whatsapp_business_messaging&lt;/code&gt; and &lt;code&gt;whatsapp_business_management&lt;/code&gt; permissions)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Meta App Secret&lt;/strong&gt; (from your Meta App Basic Settings)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Gemini API Key&lt;/strong&gt; (or your own custom LLM key)&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Step 1: Run the Setup Command
&lt;/h3&gt;

&lt;p&gt;If you have &lt;code&gt;uv&lt;/code&gt; installed, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uvx wavoice init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Or via pip: &lt;code&gt;pip install wavoice &amp;amp;&amp;amp; wavoice init&lt;/code&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The wizard prompts for your 3 keys and automatically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Starts an ephemeral Cloudflare Quick Tunnel (public HTTPS URL, zero accounts needed).&lt;/li&gt;
&lt;li&gt;Auto-discovers your WABA ID and Phone Number ID from your access token.&lt;/li&gt;
&lt;li&gt;Programmatically turns on WhatsApp Voice Calling via Graph API.&lt;/li&gt;
&lt;li&gt;Configures webhook subscriptions.&lt;/li&gt;
&lt;li&gt;Launches the local WebRTC runtime.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✓ Found WhatsApp Business Account (WABA ID): 2349713195497707
✓ Found Phone Number: +1 555-188-2279 (Verified)
✓ WhatsApp Voice Calling is ENABLED
🚀 WhatsApp Voice Server is live!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 2: Test the Call
&lt;/h3&gt;

&lt;p&gt;Open WhatsApp on your phone and tap the call button on your business number.&lt;/p&gt;

&lt;p&gt;Your AI voice agent answers immediately. By default, it runs &lt;strong&gt;Gemini 2.0 Flash Live&lt;/strong&gt; with sub-second (~300ms) speech-to-speech response times.&lt;/p&gt;




&lt;h3&gt;
  
  
  How It Works
&lt;/h3&gt;

&lt;p&gt;WAVoice decouples the &lt;strong&gt;telephony networking&lt;/strong&gt; from your &lt;strong&gt;AI logic&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Telephony Layer (Automated)&lt;/strong&gt;: Cloudflare tunnel, Meta webhooks, WebRTC SDP handshake, and SRTP audio decryption.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI Layer (Pluggable)&lt;/strong&gt;: 

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mode A (Out-of-the-box)&lt;/strong&gt;: Native Gemini Live S2S (~300ms latency, zero code required).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mode B (Custom Pipeline)&lt;/strong&gt;: Pipecat cascaded stack (STT -&amp;gt; LLM -&amp;gt; TTS).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Using Custom Models (Deepgram, OpenAI, Cartesia)
&lt;/h3&gt;

&lt;p&gt;If you prefer a custom stack (Deepgram STT -&amp;gt; GPT-4o -&amp;gt; Cartesia TTS), WAVoice integrates natively with Pipecat:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;wavoice&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;WhatsAppVoiceApp&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pipecat.pipeline.pipeline&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Pipeline&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pipecat.pipeline.runner&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PipelineRunner&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pipecat.pipeline.task&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PipelineParams&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PipelineTask&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pipecat.services.deepgram&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;DeepgramSTTService&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pipecat.services.openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAILLMService&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pipecat.services.cartesia&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CartesiaTTSService&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;WhatsAppVoiceApp&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nd"&gt;@app.on_call&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;handle_call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transport&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;call_info&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;caller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getattr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;call_info&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;from_&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;caller&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Call received from &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;caller&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Pipeline&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
        &lt;span class="n"&gt;transport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;    &lt;span class="c1"&gt;# Raw WebRTC audio in from WhatsApp
&lt;/span&gt;        &lt;span class="nc"&gt;DeepgramSTTService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DEEPGRAM_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
        &lt;span class="nc"&gt;OpenAILLMService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gpt-4o-mini&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nc"&gt;CartesiaTTSService&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CARTESIA_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;voice_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;transport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;output&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;   &lt;span class="c1"&gt;# Raw WebRTC audio out to WhatsApp
&lt;/span&gt;    &lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PipelineTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;PipelineParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;allow_interruptions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;runner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PipelineRunner&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;runner&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Technical Note: Fixing the 5-Second Ringing Delay
&lt;/h3&gt;

&lt;p&gt;During testing, callers were experiencing 5 to 7 seconds of ringing before the bot picked up.&lt;/p&gt;

&lt;p&gt;Looking into &lt;code&gt;aiortc&lt;/code&gt; and &lt;code&gt;aioice&lt;/code&gt;, we found that macOS creates virtual tunnel interfaces (&lt;code&gt;utun&lt;/code&gt;, common with VPNs and Docker). &lt;code&gt;aioice&lt;/code&gt; was attempting STUN discovery on all interfaces sequentially, timing out for exactly 5,000ms on unreachable virtual interfaces before returning candidates.&lt;/p&gt;

&lt;p&gt;By patching candidate gathering to query the kernel routing table for the primary routable interface (&lt;code&gt;socket.connect(('8.8.8.8', 80))&lt;/code&gt;), candidate gathering dropped from &lt;strong&gt;5,004ms down to ~15ms&lt;/strong&gt;, eliminating the ringing delay completely.&lt;/p&gt;




&lt;h3&gt;
  
  
  Links &amp;amp; Code
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub&lt;/strong&gt;: &lt;a href="https://github.com/amitbhakt/wavoice" rel="noopener noreferrer"&gt;https://github.com/amitbhakt/wavoice&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PyPI&lt;/strong&gt;: &lt;a href="https://pypi.org/project/wavoice/" rel="noopener noreferrer"&gt;https://pypi.org/project/wavoice/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feedback and PRs are welcome!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>whatsapp</category>
      <category>python</category>
      <category>webrtc</category>
    </item>
  </channel>
</rss>
