If you were able to join us for Astricon in February 2025, you may have caught a Voice AI demo using external media given by the Asterisk Development team. Good news, the source code for the application used in that demo is now available here!
So how does it work? The AsteriskVoiceBridge is an ARI application written in Go that connects Asterisk, Deepgram and OpenAI to create a real time voice application. The basic structure of the application looks like this:
When a call is placed into stasis, the ARI controller builds the following call structure within Asterisk:
Once the above call structure is built, the Voice Business Logic Controller then sends a GET message to a local http server to retrieve a json configuration file that provides instructions and tools for the AI service that determines how to set up the parameters for the session.
The AsteriskVoiceBridge then takes the RTP stream from Asterisk, converts it into audio segments and then sends those segments to Deepgram to perform Speech to Text on the incoming call. That text is then sent to an AI Agent created using OpenAI. As the AI Agent responds, the text of those responses is sent to Deepgram for Text to Speech conversion, which is then sent back to Asterisk as RTP.
Once the AI Agent determines which tool best matches the caller’s intent, it will send that choice to the Voice Business Logic Controller (VBLC). The VBLC will then ‘use’ that tool by issuing a subsequent GET to the local http server that matches the chosen tool to retrieve either a new set of instructions and tools for the AI and/or local commands to execute via the ARI controller.
The AsteriskVoiceBridge includes an example demo IVR that lets the user choose between support, sales and accounts, then transfers the call to the corresponding destination in dialplan.
Our hope is that this demonstrates a model for how to build a voice service using Asterisk, but please note that the AsteriskVoiceBridge is intended for educational purposes only and should not be used as the basis for any production service.