# F5 — Qualification Chatbot (Website Widget)

_Lead Generation_

Extends the existing CRMown chat widget (ChatWidget model) with AI-driven lead qualification. The bot asks 3-5 configurable questions (BANT-style or custom), scores the visitor against your ICP, and auto-creates a Contact + optional pipeline placement when a visitor qualifies. Distinct from the older "AI Chat Agent" — this one is purpose-built for lead capture.

## Steps
1. Go to Tools > Chat Lead Widget (/dashboard/leadgen/chat-widget). Pick the chat widget you want to extend (or create a new one).
2. Enable Qualification mode. The bot now follows a 2-track flow: friendly greeting → qualifying questions → either "qualified" outcome (book a meeting / capture details) or "unqualified" (graceful exit).
3. Configure your qualifying questions: budget, timeline, team size, role, etc. The bot weaves them naturally into conversation rather than asking robotically.
4. Set the qualification threshold (default 60/100). Above the threshold = qualified. The bot uses the ICP + qualification answers to score.
5. Configure qualified-lead actions: create a Contact (always), optionally drop them into a specific pipeline stage, optionally assign to a user, optionally fire a notification.
6. The chat widget itself is embedded via the Web Studio chat-widget snippet — no new install needed if your site already has the widget.

## Tips
- The bot uses the CRMown AI light tier for response generation (fast + cheap). Logged via logAiAction so you see usage in Settings > AI Usage.
- Qualification scoring: each answer gets weighted by relevance to your ICP. Fields the visitor refuses or fudges are discounted. Final score is the sum normalized to 0-100.
- Pipeline placement: works against any existing PipelineStage (uses stageId + stageName). No PipelineContact join — it creates a PipelineItem directly.
- AI Memory: the bot reads recent contact notes, prior chat transcripts, and tags. A returning visitor isn't re-qualified from scratch.

## Example
A SaaS sales team turns their generic "Need help?" chatbot into a qualifier. Visitor lands on /pricing → bot says "Hi! Most teams here are evaluating us against [competitor] or [other competitor] — happy to help, what brings you in?". 3 questions later (team size, current tool, evaluation timeline) the bot has scored 78/100. Auto-creates Contact, drops them in pipeline at Discovery stage, assigns to the inbound AE on duty, fires a Slack ping. AE has the conversation transcript + qualification data ready before they pick up the chat.

## Troubleshooting
- **Bot ignores qualification mode and just greets visitors generically** — Qualification mode toggle is off on the widget config, or no qualifying questions are defined. Fix: /dashboard/leadgen/chat-widget > pick the widget > toggle "Qualification mode" ON > define at least 3 questions. Save.
- **Visitor qualified but no Contact was created** — Visitor never provided an email — the bot can't create a Contact without one. Fix: Add an email-capture question (e.g. "Where should I send the follow-up?") as one of your qualifying questions. The bot asks it whenever it senses qualification is imminent.
- **Pipeline placement isn't happening** — No pipeline + stage selected in the qualified-lead actions, or the picked stage was deleted from the pipeline. Fix: Reconfigure under Qualified-lead actions. The dropdown lists current pipelines and stages — pick a fresh one.
