THE CHALLENGE
What had to remain reliable.
The difficult part was coordinating streaming audio and unpredictable human dialogue. The system needed to distinguish caller speech from its own playback, recover from interruptions, separate a callback from a consultation booking, prevent duplicate CRM activity, and preserve an outcome after a partial failure.
THE SOLUTION
How the system was designed.
Critical intents are deterministic, while the LLM operates inside a constrained state machine. Call state persists independently of the live audio connection. Barge-in cancels synthesis and rejects self-echo, retry limits respect calling windows, and CRM checks prevent duplicate outreach.
ARCHITECTURE
The main system boundaries and data flow.
[ Bitrix24 funnel / missed leads ]
| eligibility checks
v
[ HTTP webhooks / call queue ]
|
[ Dialer + retry policy ] ---> [ persistent call state ]
| AMI
v
[ Asterisk / SIP ] <----------> [ customer phone ]
| AudioSocket
v
[ VAD + streaming speech-to-text ]
v
[ intent rules + state machine + LLM + RAG ]
v
[ streaming TTS + barge-in ]
After call: facts + transcript + recording -> Bitrix24
OUTCOMES
What the architecture enables.
01Missed leads returned to a managed calling workflow
02Natural interruption without losing dialogue state
03Conservative retry and concurrency controls
04Complete CRM context after every completed or failed call
STACKPythonAsteriskAudioSocketDeepgramOpenAIElevenLabsBitrix24SQLiteDocker