Seeking Ideas for Real-Time Two-Way AI Calls in Asterisk

Hi everyone,
I’m currently building an AI-driven voice system using Asterisk and AGI scripts. The system can successfully initiate calls, and once the user picks up, the AI agent plays the assigned instructions or messages. The current call flow works like this:

Model → Asterisk → TTS → User

After completing the message, the call ends politely, and the full recording is saved for transcription and summary generation.

The issue I’m facing is with real-time two-way communication. While the agent can speak to the user based on predefined scripts, it does not yet process the user’s speech input in real time.

In other words, I’m still developing this flow:

User → Asterisk → STT → Model → User

I’m looking for ideas, best practices, or examples on how to implement real-time streaming of user audio to a model and get instant responses back during the call. Any pointers on integrating STT with AGI scripts or handling real-time audio streams efficiently would be highly appreciated.

Thanks in advance for your suggestions!

1 Like

I would suggest reading some of the other posts in the AI category:

Likewise and I’m looking for a free solutions

Hi there! :waving_hand:

Nice work on your project — I’ve been in a very similar situation in the past.

When I was trying to move from AGI-driven playback to real-time interaction, one of the solutions I adopted was using Asterisk’s AudioSocket module. It allows you to stream audio both ways between Asterisk and your AI stack (STT → LLM → TTS), making real-time conversation possible.

If you’d like a reference implementation, take a look at AgentVoiceResponse (AVR) — an open-source project that’s already built around AudioSocket and supports providers like OpenAI, Deepgram, Gemini, and ElevenLabs.

Here’s a guide for connecting it with Asterisk:

:link: https://wiki.agentvoiceresponse.com/en/external-asterisk

Feel free to join our Discord community — we often share examples, discuss architectures, and help each other with AI + Asterisk setups:

:speech_balloon: https://discord.gg/MUd3y7eGVF

Would be great to have you with us! :rocket:

In my previous comment, I forgot to mention something important :grinning_face_with_smiling_eyes:

The solution is completely free and open-source — you can find all the GitHub repositories here:

:link: https://github.com/agentvoiceresponse

You can run everything locally with Docker and connect it to Asterisk via AudioSocket.

If you integrate local AI providers, you only pay for your own hardware resources.

If you prefer cloud providers, you’ll just pay for the API usage directly to them.

Here’s the guide for running AVR with local AI providers:

:link: https://wiki.agentvoiceresponse.com/en/running-avr-with-local-ai-providers

1 Like