The prefill confirmation flow is a critical component of TutorBot that ensures users can verify and confirm information extracted from their initial messages. This flow was recently fixed to properly display interactive menu buttons in WhatsApp.
User sends message โ OpenAI extracts info โ Show confirmation menu โ User confirms โ Show action menu
prefill_intake_from_message() extracts structured datashow_prefill_action_menu() shows extracted info + menushow_prefill_action_menu_after_confirmation() shows next stepsshow_prefill_action_menu(cid, contact_id, lang) - modules/handlers/intake.py:64Purpose: Primary entry point for prefill confirmation flow (moved to modular architecture)
Current Location: modules/handlers/intake.py
Imported via: main.py:105 โ re-exported from intake handler
What it does:
pending_intent to "prefill_action"Current Implementation:
def show_prefill_action_menu(cid, contact_id, lang):
"""Show action menu after prefill confirmation"""
try:
set_conv_attrs(cid, {"pending_intent": "prefill_action"})
except Exception:
pass
# Show tariffs if we have school level info
contact_attrs = get_contact_attrs(contact_id)
school_level = contact_attrs.get("school_level", "")
is_adult = contact_attrs.get("is_adult", False)
if school_level:
age_over_20 = is_adult or ("university" in str(school_level).lower())
tariffs_key = get_appropriate_tariffs_key(school_level, age_over_20)
if tariffs_key:
send_text_with_duplicate_check(cid, t(tariffs_key, lang), persist=False)
# Show action menu
action_menu_options = [
(t("prefill_action_trial_first", lang), "plan_trial_lesson"),
(t("prefill_action_urgent_session", lang), "urgent_session"),
(t("prefill_action_main_menu", lang), "go_to_main_menu"),
(t("prefill_action_handoff", lang), "handoff"),
]
send_input_select_only(cid, action_menu_title, action_menu_options)
send_input_select_only(conversation_id, text, options) - modules/utils/text_helpers.py:74Purpose: Send interactive menu buttons in WhatsApp (moved to utility module)
Current Location: modules/utils/text_helpers.py
Imported via: Multiple handlers import this utility function
Critical Features:
ChatwootAPI.send_message() for proper SSL handlingCurrent Implementation:
def send_input_select_only(cid, text, options):
"""Send interactive menu using ChatwootAPI for SSL safety"""
try:
content_attributes = {
"items": [{"title": title, "value": value} for title, value in options]
}
# CRITICAL: Use ChatwootAPI instead of direct HTTP requests
success = ChatwootAPI.send_message(
cid,
text,
"input_select",
content_attributes
)
return success
except Exception as e:
print(f"โ Error sending input_select: {e}")
return False
ChatwootAPI.send_message()send_input_select_only() is called for menu displayThe correct flow is now:
show_prefill_action_menu() โ send_input_select_only() โ WhatsApp displays buttons
NOT:
show_prefill_action_menu() โ text message only โ No buttons displayed
โ
"Ja, klopt!" (confirm_all)
โ "Nee, aanpassen" (correct_all)
๐ค "Deels correct" (correct_partial)
For New Customers:
plan_trial_lesson)go_to_main_menu)handoff)For Existing Customers:
plan_all_lessons)plan_trial_lesson)go_to_main_menu)handoff)CW_URL=https://crm.stephenadei.nl
CW_ACC_ID=1
CW_ADMIN_TOKEN=your_admin_token
modules/utils/cw_api.py - ChatwootAPI class for SSL-safe requestsmodules/handlers/intake.py - Core prefill flow functionsmodules/utils/text_helpers.py - Menu and messaging utilitiesmodules/utils/mapping.py - Tariff and segment mappingt() function) for multilingual supporttry:
set_conv_attrs(cid, {"pending_intent": "prefill_confirmation"})
except Exception as e:
print(f"โ ๏ธ SSL error setting pending_intent: {e}")
# Continue anyway - not critical
Look for these log messages:
๐ฏ Showing prefill confirmation menu in nl
๐ค Sending input_select menu with 3 items...
โ
Chatwoot input_select sent successfully (3 options)
๐ฏ Prefill confirmation menu send result: True
send_input_select_only() is being calledChatwootAPI.send_message() is being usedLast Updated: December 2024
Status: Fully Implemented and Tested