Autostage Telegram sales leads

This commit is contained in:
Magzhan Zhumabayev
2026-05-12 19:41:04 +05:00
parent fbc77ba8a7
commit 5236ee74ac
2 changed files with 168 additions and 12 deletions
+38
View File
@@ -223,6 +223,44 @@ def test_sales_internal_telegram_sync_auto_creates_workspace():
assert workspace["messages"][0]["external_message_id"] == "ext_tg_auto_01"
def test_sales_internal_telegram_sync_moves_pipeline_every_three_customer_messages():
client = TestClient(sales_module.app)
tenant_id = "tenant_tg_autostage"
def post_message(index: int) -> dict:
response = client.post(
"/internal/sales-sync/telegram",
json={
"thread_id": "tg-thread-autostage-01",
"chat_id": "tg-chat-autostage-01",
"interaction_id": "int_tg_autostage_01",
"display_name": "Autostage Prospect",
"message_id": f"msg_tg_autostage_{index}",
"external_message_id": f"ext_tg_autostage_{index}",
"text": f"Сообщение клиента {index}",
"direction": "inbound",
"author_type": "customer",
"author_id": "tg-user-autostage",
},
headers=_headers(tenant_id),
)
assert response.status_code == 200
return response.json()
stage_codes = [post_message(index)["stage"]["code"] for index in range(1, 7)]
assert stage_codes[0] == "new_qualified_lead"
assert stage_codes[1] == "new_qualified_lead"
assert stage_codes[2] == "warm_lead"
assert stage_codes[3] == "warm_lead"
assert stage_codes[4] == "warm_lead"
assert stage_codes[5] == "hot_lead"
duplicate = post_message(6)
assert duplicate["stage"]["code"] == "hot_lead"
assert len(duplicate["messages"]) == 6
def test_sales_internal_voice_sync_creates_call_and_transcript():
client = TestClient(sales_module.app)