Problem
When creating a new Telegram bot instance via admin panel, the bot inherits hardcoded sales funnel behavior, TZ quiz, news broadcast, and default action buttons — even if the bot is intended as a simple AI assistant. This causes confusing behavior: users see marketing quiz prompts, main menu reply buttons from other bots, and the bot may write kanban tasks or broadcast news as if it were the primary marketing bot.
Root Cause
1. sales_funnel_enabled defaults to True
db/models.py:809:
sales_funnel_enabled: Mapped[bool] = mapped_column(Boolean, default=True, server_default="1")
Every new bot gets full sales funnel handlers registered by default (telegram_bot/handlers/__init__.py:97-99), including:
- Welcome quiz flow (
handlers/sales/welcome.py, quiz.py)
- DIY / Basic / Custom sales paths (
handlers/sales/diy.py, basic.py, custom.py)
- FAQ inline keyboards with hardcoded product-specific answers (
sales/texts.py)
- Reply keyboard action buttons (
DEFAULT_ACTION_BUTTONS from sales/keyboards.py)
2. TZ quiz and News broadcast always registered
telegram_bot/handlers/__init__.py:100-109:
# These are ALWAYS included, regardless of skip_sales:
main_router.include_router(tz_router) # TZ spec generator
main_router.include_router(news_router) # GitHub news handler
Even with sales_funnel_enabled=False, every bot gets TZ quiz handlers and news commands.
3. News broadcast scheduler runs on all sales bots
telegram_bot/bot.py:105-106:
should_broadcast = not instance_id or (
_bot_config is not None and _bot_config.sales_funnel_enabled
)
Every bot with sales_funnel_enabled=True (the default) starts a news broadcast scheduler, potentially sending duplicate broadcasts.
4. DEFAULT_ACTION_BUTTONS are marketing-specific
telegram_bot/state.py:15:
_action_buttons: list[dict[str, Any]] = DEFAULT_ACTION_BUTTONS
The default buttons (from sales/keyboards.py) include marketing-specific items like "Wiki", payment links, GitHub links, support — inappropriate for a generic assistant bot.
5. Agent prompts / quiz questions empty but funnel active
When a new bot is created, the bot_agent_prompts, bot_quiz_questions, bot_segments tables are empty for this bot_id (no seeding). But the sales funnel handlers are still registered with hardcoded fallback texts in sales/texts.py, so the bot shows generic sales flow with stale content.
Expected Behavior
- New bot should default to
sales_funnel_enabled=False (simple assistant mode)
- TZ quiz and news broadcast should be opt-in per bot instance (new boolean fields or tied to
sales_funnel_enabled)
- Action buttons should default to empty
[] for non-sales bots
- Admin panel should clearly show which features are active per bot
- Creating a new bot should NOT register any marketing handlers unless explicitly enabled
Affected Files
| File |
Issue |
db/models.py:809 |
sales_funnel_enabled defaults to True |
db/repositories/bot_instance.py:172 |
sales_funnel_enabled=kwargs.get("sales_funnel_enabled", True) |
telegram_bot/handlers/__init__.py:100-109 |
TZ + news routers always included |
telegram_bot/bot.py:105-106 |
Broadcast scheduler on all sales bots |
telegram_bot/state.py:15 |
Marketing action buttons as global default |
telegram_bot/sales/keyboards.py |
DEFAULT_ACTION_BUTTONS is marketing-specific |
Proposed Fix
- Change default
sales_funnel_enabled to False in model and repository
- Add
tz_quiz_enabled and news_broadcast_enabled boolean fields to BotInstance (default False)
- Gate TZ router and news router inclusion on per-instance config in
get_main_router()
- Change
DEFAULT_ACTION_BUTTONS to [] for new instances; keep marketing buttons only when sales_funnel_enabled=True is explicitly set
- Only start broadcast scheduler for the ONE designated primary bot (not all sales bots)
- Add migration script for existing bots (preserve current behavior for already-created instances)
Problem
When creating a new Telegram bot instance via admin panel, the bot inherits hardcoded sales funnel behavior, TZ quiz, news broadcast, and default action buttons — even if the bot is intended as a simple AI assistant. This causes confusing behavior: users see marketing quiz prompts, main menu reply buttons from other bots, and the bot may write kanban tasks or broadcast news as if it were the primary marketing bot.
Root Cause
1.
sales_funnel_enableddefaults toTruedb/models.py:809:Every new bot gets full sales funnel handlers registered by default (
telegram_bot/handlers/__init__.py:97-99), including:handlers/sales/welcome.py,quiz.py)handlers/sales/diy.py,basic.py,custom.py)sales/texts.py)DEFAULT_ACTION_BUTTONSfromsales/keyboards.py)2. TZ quiz and News broadcast always registered
telegram_bot/handlers/__init__.py:100-109:Even with
sales_funnel_enabled=False, every bot gets TZ quiz handlers and news commands.3. News broadcast scheduler runs on all sales bots
telegram_bot/bot.py:105-106:Every bot with
sales_funnel_enabled=True(the default) starts a news broadcast scheduler, potentially sending duplicate broadcasts.4.
DEFAULT_ACTION_BUTTONSare marketing-specifictelegram_bot/state.py:15:The default buttons (from
sales/keyboards.py) include marketing-specific items like "Wiki", payment links, GitHub links, support — inappropriate for a generic assistant bot.5. Agent prompts / quiz questions empty but funnel active
When a new bot is created, the
bot_agent_prompts,bot_quiz_questions,bot_segmentstables are empty for this bot_id (no seeding). But the sales funnel handlers are still registered with hardcoded fallback texts insales/texts.py, so the bot shows generic sales flow with stale content.Expected Behavior
sales_funnel_enabled=False(simple assistant mode)sales_funnel_enabled)[]for non-sales botsAffected Files
db/models.py:809sales_funnel_enableddefaults toTruedb/repositories/bot_instance.py:172sales_funnel_enabled=kwargs.get("sales_funnel_enabled", True)telegram_bot/handlers/__init__.py:100-109telegram_bot/bot.py:105-106telegram_bot/state.py:15telegram_bot/sales/keyboards.pyDEFAULT_ACTION_BUTTONSis marketing-specificProposed Fix
sales_funnel_enabledtoFalsein model and repositorytz_quiz_enabledandnews_broadcast_enabledboolean fields toBotInstance(defaultFalse)get_main_router()DEFAULT_ACTION_BUTTONSto[]for new instances; keep marketing buttons only whensales_funnel_enabled=Trueis explicitly set