2243f305b87294d072d24491f3fa378b07526c99
Replaces the hardcoded single-extension redirect for AI->human call
escalation with a real Agent Pool + Routing Engine:
- agents/escalations/routing_rules tables (migration 0031), asterisk_call_links
gains tenant_id/current_level/required_skills_json/priority.
- services/routing_service/engine.py: level/tenant/skill filtered agent
selection with atomic (CAS) reservation, no double-booking.
- routing-service: /agents CRUD + /internal/routing/reserve-agent and
/internal/routing/release-agent.
- asterisk-bridge-service: voice_ai.request_handoff now uses the Routing
Engine automatically for any queue_code configured in
ASTERISK_QUEUE_LEVEL_MAP_JSON (all other queue_codes keep the existing
static ASTERISK_TRANSFER_TARGET_MAP_JSON behavior unchanged); new
POST /asterisk/live-calls/{call_id}/escalations entrypoint; agent is
released back to AVAILABLE and the escalation closed when the call ends.
Targets the Tele2 Kazgaz DID +77476456048 (from-tele2-kazgaz context) as the
first queue wired to real L2 routing instead of AI-only.
Known gap (documented in docs/architecture/l1-l2-routing-engine.md):
automatic no-answer retry-to-next-agent needs a small, separately reviewed
dialplan change and is left for a follow-up MR rather than guessed at blind.
Tests: services/routing_service/engine.py covered by
tests/test_routing_engine.py (selection filtering, atomic reservation,
release); existing test_asterisk_bridge_service.py and
test_routing_service_pg_counter.py suites still pass unmodified.
call-center
Омниканальный контакт-центр: телефония (Asterisk), Telegram, WhatsApp, веб-чат, email — плюс встроенный голосовой ИИ-оператор (распознавание речи → LLM → синтез речи). Написан на Python (FastAPI), ~25 сервисов вокруг одной SQLAlchemy-схемы, локально работает на SQLite, в проде — на PostgreSQL.
Документация
| Документ | Про что |
|---|---|
docs/architecture/overview.md |
Обзор микросервисов и их ролей |
docs/architecture/voice-ai.md |
Голосовой ИИ-оператор подробно |
docs/architecture/real-time-voice-service.md |
Рантайм голосового моста (AudioSocket, TTS/ASR) |
docs/architecture/event-schemas.md |
Схемы событий шины (RabbitMQ) |
docs/runbooks/local-setup.md |
Как поднять проект локально (демо-режим и ручной запуск) |
docs/runbooks/deployment.md |
Как разворачивать (Docker Compose / Kubernetes) |
longread.md |
Сквозной архитектурный ревью репозитория — что реально есть, где технический долг |
Быстрый старт
Подробности — в docs/runbooks/local-setup.md. Коротко:
python -m pip install -r requirements.txt
cp .env.example .env # по умолчанию SQLite, без Docker
python scripts/migrate_core_db.py
uvicorn gateway.app:app --reload --port 8080
Точки входа (после старта gateway): /operator, /supervisor, /admin, /analyst на http://localhost:8080.
Демо-режим одной командой (поднимает весь стек + тестовые данные): scripts/prepare_demo.ps1.
Тесты
pytest -q
Частые задачи
- Поменять greeting/system prompt голосового бота Айнур — правится в коде:
services/shared/ai_operator_config.py→ai_operator_default_config(), коммит и деплой; сервис сам синкает значение в БД при старте.
Languages
Python
74.2%
JavaScript
18.8%
HTML
3.4%
CSS
2.9%
PowerShell
0.4%
Other
0.3%