Voximplant Integration for Voice AI Voximplant is a Russian cloud telephony platform with a built-in Java
Script engine (VoxEngine) for call management. Advantages: infrastructure in Russia, excellent integration with Russian operators, no issues with cross-border data transfer. ### Architecture with VoxEngine Voximplant runs a JavaScript script for every call. From the script, we communicate with the AI backend via WebSocket:```javascript // VoxEngine сценарий (JavaScript) VoxEngine.addEventListener(AppEvents.CallAlerting, (e) => { const call = e.call; call.answer();
// Создаём WebSocket соединение с нашим AI-бэкендом
const wsConn = VoxEngine.createWSClient(`wss://api.yourapp.com/voxi-stream`);
// Привязываем аудио звонка к WebSocket
call.sendMediaTo(wsConn);
wsConn.sendMediaTo(call);
wsConn.addEventListener(WSClientEvents.ConnectionClosed, () => {
call.hangup();
});
call.addEventListener(CallEvents.Disconnected, () => {
wsConn.close();
});
});
Python backend for audio processingpython
from fastapi import FastAPI, WebSocket
import asyncio
@app.websocket("/voxi-stream") async def voximplant_stream(websocket: WebSocket): await websocket.accept() session = VoiceSession()
# Отправляем приветствие
greeting_audio = await tts.synthesize("Здравствуйте! Чем могу помочь?")
await websocket.send_bytes(greeting_audio)
audio_buffer = bytearray()
silence_frames = 0
async for chunk in websocket.iter_bytes():
audio_buffer.extend(chunk)
silence_frames = 0 # сбрасываем при получении аудио
# Обрабатываем каждые 1.5 секунды накопленного аудио
if len(audio_buffer) >= 24000 * 2: # 1.5 sec @ 16kHz 16-bit
response = await process_utterance(bytes(audio_buffer), session)
if response:
audio_response = await tts.synthesize(response)
await websocket.send_bytes(audio_response)
audio_buffer = bytearray()
### Outgoing calls via Voximplantpython
import requests
def start_outbound_campaign(contacts: list[dict]): """Запускаем массовый обзвон через Voximplant API""" for contact in contacts: response = requests.post( "https://api.voximplant.com/platform_api/StartScenarios/", data={ "account_name": VOXI_ACCOUNT, "api_key": VOXI_API_KEY, "rule_name": "outbound_bot", "script_custom_data": json.dumps({ "phone": contact["phone"], "customer_name": contact["name"], "context": contact.get("context", {}) }), "reference_to_call_id": contact["phone"] } )







