Spaces:
Running
Running
axeronis commited on
Commit ·
8b679a2
1
Parent(s): e454398
fix: instant /start welcome with template, fewer qualification fields, remove emoji
Browse files
backend/app/api/playbook.py
CHANGED
|
@@ -701,14 +701,15 @@ async def generate_funnel_with_ai(
|
|
| 701 |
- exit_criteria — список полей которые нужно собрать чтобы перейти на следующий этап
|
| 702 |
|
| 703 |
Для ПОЛЕЙ КВАЛИФИКАЦИИ (qualification_fields):
|
| 704 |
-
|
| 705 |
-
|
|
|
|
| 706 |
|
| 707 |
ВАЖНО:
|
| 708 |
- ai_goal должен быть очень подробным (минимум 2-3 предложения)
|
| 709 |
- Включи конкретные техники продаж в ai_goal
|
| 710 |
-
- exit_criteria
|
| 711 |
-
- qualification_fields
|
| 712 |
|
| 713 |
Верни JSON объект в формате:
|
| 714 |
{{
|
|
@@ -835,9 +836,12 @@ async def generate_funnel_with_ai(
|
|
| 835 |
# Sync all exit criteria to tenant qualification fields
|
| 836 |
await sync_tenant_qualification_fields(session, current_user.tenant_id)
|
| 837 |
|
|
|
|
|
|
|
|
|
|
| 838 |
return GenerateFunnelResponse(
|
| 839 |
success=True,
|
| 840 |
-
message=f"Сгенерировано {len(created_stages)} этапов воронки" + (f" и {
|
| 841 |
stages=[
|
| 842 |
SalesStageResponse(
|
| 843 |
id=stage.id,
|
|
|
|
| 701 |
- exit_criteria — список полей которые нужно собрать чтобы перейти на следующий этап
|
| 702 |
|
| 703 |
Для ПОЛЕЙ КВАЛИФИКАЦИИ (qualification_fields):
|
| 704 |
+
Только САМЫЕ ВАЖНЫЕ поля для CRM карточки клиента (3-5 полей, НЕ БОЛЬШЕ!).
|
| 705 |
+
Обязательно: "Имя", "Контакт" (телефон или email).
|
| 706 |
+
Дополнительно 1-3 поля под конкретный бизнес.
|
| 707 |
|
| 708 |
ВАЖНО:
|
| 709 |
- ai_goal должен быть очень подробным (минимум 2-3 предложения)
|
| 710 |
- Включи конкретные техники продаж в ai_goal
|
| 711 |
+
- exit_criteria — 1-2 ключевых критерия на этап (НЕ БОЛЬШЕ!)
|
| 712 |
+
- qualification_fields — ТОЛЬКО 3-5 самых важных полей
|
| 713 |
|
| 714 |
Верни JSON объект в формате:
|
| 715 |
{{
|
|
|
|
| 836 |
# Sync all exit criteria to tenant qualification fields
|
| 837 |
await sync_tenant_qualification_fields(session, current_user.tenant_id)
|
| 838 |
|
| 839 |
+
# Count actual qualification fields saved
|
| 840 |
+
qual_fields_count = len(generated_qualification_fields) if generated_qualification_fields else 0
|
| 841 |
+
|
| 842 |
return GenerateFunnelResponse(
|
| 843 |
success=True,
|
| 844 |
+
message=f"Сгенерировано {len(created_stages)} этапов воронки" + (f" и {qual_fields_count} полей квалификации" if qual_fields_count > 0 else ""),
|
| 845 |
stages=[
|
| 846 |
SalesStageResponse(
|
| 847 |
id=stage.id,
|
backend/app/api/webhook.py
CHANGED
|
@@ -635,29 +635,37 @@ async def telegram_webhook(
|
|
| 635 |
# Extract text (or caption from media) or transcribe voice
|
| 636 |
user_text = message.get("text") or message.get("caption") or ""
|
| 637 |
|
| 638 |
-
# 👋 HANDLE /start COMMAND - Send welcome message
|
| 639 |
if user_text.strip().lower() == '/start':
|
|
|
|
|
|
|
|
|
|
| 640 |
welcome_message = getattr(tenant, 'telegram_welcome_message', None)
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
|
|
|
| 657 |
logger.info(
|
| 658 |
-
"👋
|
|
|
|
| 659 |
tenant_id=str(tenant_id)
|
| 660 |
)
|
|
|
|
|
|
|
|
|
|
| 661 |
return {"ok": True, "status": "welcome_sent"}
|
| 662 |
|
| 663 |
# Handle reply_to_message - include context of quoted message
|
|
|
|
| 635 |
# Extract text (or caption from media) or transcribe voice
|
| 636 |
user_text = message.get("text") or message.get("caption") or ""
|
| 637 |
|
| 638 |
+
# 👋 HANDLE /start COMMAND - Send welcome message instantly
|
| 639 |
if user_text.strip().lower() == '/start':
|
| 640 |
+
from app.services.telegram_service import telegram_service
|
| 641 |
+
|
| 642 |
+
# Get custom welcome message or build template
|
| 643 |
welcome_message = getattr(tenant, 'telegram_welcome_message', None)
|
| 644 |
+
|
| 645 |
+
if not welcome_message:
|
| 646 |
+
# Build template: "Здравствуйте! Я [AI_NAME], чем могу помочь?"
|
| 647 |
+
ai_identity = tenant.ai_identity or {}
|
| 648 |
+
ai_name = ai_identity.get('name', '').strip()
|
| 649 |
+
|
| 650 |
+
if ai_name:
|
| 651 |
+
welcome_message = f"Здравствуйте! Я {ai_name}, чем могу помочь?"
|
| 652 |
+
else:
|
| 653 |
+
welcome_message = "Здравствуйте! Чем могу помочь?"
|
| 654 |
+
|
| 655 |
+
try:
|
| 656 |
+
await telegram_service.send_message(
|
| 657 |
+
token=tenant.telegram_bot_token,
|
| 658 |
+
chat_id=chat_id,
|
| 659 |
+
text=welcome_message
|
| 660 |
+
)
|
| 661 |
logger.info(
|
| 662 |
+
"👋 Welcome message sent",
|
| 663 |
+
chat_id=chat_id,
|
| 664 |
tenant_id=str(tenant_id)
|
| 665 |
)
|
| 666 |
+
except Exception as e:
|
| 667 |
+
logger.error(f"❌ Failed to send welcome message: {e}")
|
| 668 |
+
|
| 669 |
return {"ok": True, "status": "welcome_sent"}
|
| 670 |
|
| 671 |
# Handle reply_to_message - include context of quoted message
|
frontend/app/settings/brain/page.tsx
CHANGED
|
@@ -1045,7 +1045,7 @@ export default function BrainSettingsPage() {
|
|
| 1045 |
<textarea
|
| 1046 |
value={welcomeMessage}
|
| 1047 |
onChange={(e) => setWelcomeMessage(e.target.value)}
|
| 1048 |
-
placeholder="Привет!
|
| 1049 |
rows={3}
|
| 1050 |
className="w-full px-4 py-3 bg-white/5 border border-white/10 rounded-lg text-white placeholder:text-slate-600 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500/20 transition-all outline-none resize-none"
|
| 1051 |
/>
|
|
|
|
| 1045 |
<textarea
|
| 1046 |
value={welcomeMessage}
|
| 1047 |
onChange={(e) => setWelcomeMessage(e.target.value)}
|
| 1048 |
+
placeholder="Привет! Я AI-ассистент. Чем могу помочь?"
|
| 1049 |
rows={3}
|
| 1050 |
className="w-full px-4 py-3 bg-white/5 border border-white/10 rounded-lg text-white placeholder:text-slate-600 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500/20 transition-all outline-none resize-none"
|
| 1051 |
/>
|