Implementation of an AI voice bot for processing incoming requests. The incoming request bot is the first line of customer support. It independently resolves typical requests (status, balance, schedule), and, if necessary, escalates with full context to an operator. Target Containment Rate: 60–75%. ### Typology of incoming requests | Type | Share | Automation | |-----|------|-------------------| | Status check | 35% | 95% | | Data change | 20% | 75% | | FAQ / information | 25% | 90% | | Complaints | 10% | 20% | | Urgent questions | 10% | 40% | ### Multi-scenario bot
from typing import Callable
@dataclass
class DialogScenario:
name: str
triggers: list[str] # фразы для определения сценария
handler: Callable
priority: int = 0
SCENARIOS = [
DialogScenario(
name="order_status",
triggers=["заказ", "статус", "где посылка", "когда доставят"],
handler=handle_order_status_scenario,
priority=10
),
DialogScenario(
name="account_balance",
triggers=["баланс", "остаток", "сколько денег", "счёт"],
handler=handle_balance_scenario,
priority=10
),
DialogScenario(
name="technical_issue",
triggers=["не работает", "ошибка", "сломалось", "проблема"],
handler=handle_tech_support_scenario,
priority=5
),
]
async def route_to_scenario(user_text: str) -> DialogScenario:
# Используем LLM для точной маршрутизации
response = await client.chat.completions.create(
model="gpt-4o-mini",
messages=[{
"role": "system",
"content": f"Определи сценарий из: {[s.name for s in SCENARIOS]}. JSON: {{'scenario': '...'}}"
}, {"role": "user", "content": user_text}],
response_format={"type": "json_object"}
)
scenario_name = json.loads(response.choices[0].message.content)["scenario"]
return next((s for s in SCENARIOS if s.name == scenario_name), SCENARIOS[-1])
```### Passing context to the operator```python
async def transfer_to_agent(session: CallSession, reason: str):
"""Эскалируем с полным контекстом диалога"""
context = {
"call_id": session.call_id,
"phone": session.phone,
"customer": await lookup_customer(session.phone),
"dialog_summary": await summarize_dialog(session.history),
"intent": session.current_intent,
"escalation_reason": reason,
"timestamp": datetime.utcnow().isoformat()
}
await crm.create_case(context)
await telephony.transfer_call(session.call_id, agent_queue="support")
```### Operator notification before connection```python
AGENT_BRIEFING_TEMPLATE = """
Переключаю клиента {phone}.
Причина обращения: {intent}.
Клиент уже сообщил: {summary}.
Не нужно спрашивать: номер заказа и имя — уже получены.
"""
```Timeframe: A bot for a single request category takes 2 weeks. A fully functional multi-scenario bot takes 2–3 months.