Skip to main content
Product••7 min read

We Built Real-Time Voice AI: Here's How It Works

A deep dive into Mujib's native real-time Voice AI stack — secure WebSockets, SIP bridging, quota enforcement, and low-latency conversations.

M
Mujib Engineering Team
Engineering
المنتج• •7 دقائق قراءة

بنينا وكلاء الصوت بالذكاء الاصطناعي — إليك كيف يعمل

نظرة معمّقة على منظومة الصوت الأصلية في مُجيب — WebSocket آمن، وربط SIP، وتطبيق الحصص، ومحادثات بزمن استجابة منخفض.

ف
فريق هندسة مُجيب
الهندسة
We Built Real-Time Voice AI: Here's How It Works

The Problem We Set Out to Solve

Chatbots are powerful — but they're still chatbots. They require the user to type, wait, read, and type again. For many industries — call centers, healthcare reception, government services, and retail — voice is the primary way people expect to interact. We decided to bridge that gap.

Today, we're pulling back the curtain on how we built Mujib's real-time Voice AI system: a full-stack feature that lets you deploy conversational voice agents powered by your own knowledge base, with quota controls, usage tracking, and multilingual support — all in production.

The Architecture: What Powers a Voice Agent

Mujib runs a native real-time voice bridge for browser WebSockets and SIP/PBX calls. The backend authenticates the session, connects it to the live voice model, and keeps knowledge, tools, quotas, transcripts, and analytics under one platform:

  • RAG-powered responses: When a caller asks a question, our engine retrieves the most relevant chunks from your knowledge base and feeds them as context to the LLM — just like our chat agents.
  • Secure realtime transport: Browser and SDK clients exchange their API key for a short-lived, single-use stream token before opening the WebSocket.
  • Native SIP bridge: Asterisk AudioSocket connects phone and PBX calls to the same Mujib voice engine without an external call-orchestration platform.
  • Interruptible, natural turns: the caller can cut in at any moment; the assistant stops, listens and answers, so the call feels like a real conversation.
"We didn't want to add a voice feature. We wanted to make voice a first-class citizen of our platform — with the same quota controls, analytics, and reliability as our chat system."

How We Enforce Voice Quotas

One challenge unique to voice is billing. Unlike chat messages where you count discrete events, voice usage is measured in minutes. Every plan now includes a voice_minutes_per_month field, and we track usage in a dedicated voice_usage_logs table at the second-level granularity.

Before Mujib starts a WebSocket or SIP voice session, the server checks how many minutes the account has consumed that month. If the plan limit is exhausted, the session is rejected before provider usage begins. No surprises, no unexpected bills.

Building for Arabic-First

Most voice AI solutions are English-first and Arabic-later. We built Mujib's voice system Arabic-first. Our voice agents detect the caller's language automatically and respond naturally in Arabic or English — with proper RTL awareness in the portal UI and Arabic phonetics handled by ElevenLabs' dedicated Arabic models.

What You Get Today

  • ✅ Real-time voice conversations with your AI agent
  • ✅ Powered by your knowledge base (RAG)
  • ✅ Arabic & English language support
  • ✅ Per-plan voice minute quotas with enforcement
  • ✅ Monthly call minutes visible in the console, next to your plan's limit
  • ✅ Create and manage voice agents from the portal

What's Next

Customers can also reach your voice agent on a real phone number: connect your PBX or carrier line over SIP, or take WhatsApp calls. No widget, no embed, just a phone call.

We're also building voice analytics: call duration heatmaps, most-asked questions by voice, and sentiment tracking per call. Stay tuned.

المشكلة التي أردنا حلها

الشات بوتات قوية — لكنها لا تزال شات بوتات. تتطلب من المستخدم الكتابة، والانتظار، والقراءة، ثم الكتابة مجدداً. في كثير من القطاعات — مراكز الاتصال، الرعاية الصحية، الخدمات الحكومية، والتجزئة — الصوت هو الطريقة الأساسية التي يتوقع بها الناس التفاعل. قررنا سد هذه الفجوة.

اليوم، نكشف الستار عن كيفية بناء نظام Voice AI لحظي في مُجيب: ميزة متكاملة تتيح لك نشر وكلاء صوتيين تحادثيين مدعومين بقاعدة معرفتك الخاصة، مع ضوابط الحصص، وتتبع الاستخدام، ودعم متعدد اللغات — كل ذلك في بيئة الإنتاج.

البنية التقنية: ما الذي يُشغّل وكيل الصوت

يشغّل مُجيب جسراً صوتياً أصلياً لاتصالات WebSocket في المتصفح ومكالمات SIP وPBX. يتولى الخادم التوثيق والاتصال بالنموذج الصوتي الحي، مع إبقاء المعرفة والأدوات والحصص والنصوص والتحليلات داخل منصة واحدة:

  • ردود مدعومة بـ RAG: عندما يطرح المتصل سؤالاً، يسترجع محركنا الأجزاء الأكثر صلة من قاعدة معرفتك ويغذيها كسياق للنموذج اللغوي — تماماً مثل وكلاء الدردشة لدينا.
  • نقل لحظي آمن: يستبدل المتصفح أو SDK مفتاح API برمز بث مؤقت وأحادي الاستخدام قبل فتح WebSocket.
  • ربط SIP أصلي: يربط Asterisk AudioSocket مكالمات الهاتف وPBX بمحرك مُجيب الصوتي نفسه دون منصة خارجية لتنسيق المكالمات.
  • أدوار طبيعية قابلة للمقاطعة: يستطيع المتصل المقاطعة في أي لحظة؛ فيتوقف المساعد ويستمع ويجيب، فتبدو المكالمة محادثة حقيقية.
"لم نرد إضافة ميزة صوتية. أردنا جعل الصوت مواطناً من الدرجة الأولى في منصتنا — بنفس ضوابط الحصص والتحليلات والموثوقية الموجودة في نظام الدردشة لدينا."

كيف نطبق حصص الصوت

أحد التحديات الفريدة في الصوت هو الفوترة. على عكس رسائل الدردشة حيث تعد أحداثاً منفصلة، يُقاس استخدام الصوت بالدقائق. كل خطة الآن تتضمن حقل voice_minutes_per_month، ونتبع الاستخدام في جدول voice_usage_logs مخصص بدقة على مستوى الثانية.

قبل أن يبدأ مُجيب جلسة صوتية عبر WebSocket أو SIP، يفحص الخادم عدد الدقائق التي استهلكها الحساب خلال الشهر. إذا انتهت حصة الخطة، تُرفض الجلسة قبل بدء استخدام مزود الصوت. لا مفاجآت ولا فواتير غير متوقعة.

البناء بالعربية أولاً

معظم حلول الذكاء الاصطناعي الصوتية تُبنى بالإنجليزية أولاً والعربية لاحقاً. بنينا نظام مُجيب الصوتي بالعربية أولاً. يكتشف وكلاؤنا الصوتيون لغة المتصل تلقائياً ويردون بشكل طبيعي بالعربية أو الإنجليزية.

ما تحصل عليه اليوم

  • ✅ محادثات صوتية لحظية مع وكيل الذكاء الاصطناعي
  • ✅ مدعوم بقاعدة معرفتك (RAG)
  • ✅ دعم اللغة العربية والإنجليزية
  • ✅ حصص دقائق صوتية لكل خطة مع تطبيق فوري
  • ✅ تتبع الاستخدام الشهري مرئي على لوحة التحكم
  • ✅ إنشاء وإدارة وكلاء الصوت من البوابة

ما القادم

ويستطيع عملاؤك أيضًا الوصول إلى وكيلك الصوتي عبر رقم هاتف حقيقي: اربط مقسمك أو خط شركة الاتصالات عبر SIP، أو استقبل مكالمات واتساب. بلا نافذة ولا تضمين، مجرد مكالمة هاتفية.

نبني أيضاً تحليلات الصوت: خرائط حرارية لمدة المكالمة، والأسئلة الأكثر شيوعاً بالصوت، وتتبع المشاعر لكل مكالمة. ترقبوا المستجدات.

Build Your AI Agent Today

Join thousands of businesses using Mujib to serve their customers better.

Start Free Trial

ابدأ مع مُجيب اليوم

انضم للشركات التي تستخدم مُجيب لخدمة عملائها بشكل أفضل.

ابدأ تجربة مجانية
Ready to automate your support?Start free — no credit card required
Start Free