ai_lead_chatbot
The AI Chatbot module provides an intelligent, automated chat widget that engages website visitors and captures leads using OpenAI's GPT language models.
Unlike traditional contact forms, this chatbot conducts natural conversations to understand visitor needs, collect contact information, and qualify leads—all
while providing instant responses to common questions.
Perfect for businesses, agencies, and organizations looking to improve visitor engagement and automate lead generation without requiring visitors to fill out
lengthy forms.
Features
Core Functionality:
- AI-Powered Conversations: Uses OpenAI GPT models (gpt-4, gpt-4o-mini, etc.) for natural, context-aware conversations
- Automated Lead Capture: Conversational flow automatically collects service interest, name, and contact information
- Floating Chat Widget: Non-intrusive chat button appears on all pages with expandable chat window
- Session Management: Tracks conversation state using Drupal's tempstore for seamless multi-message interactions
- Lead Storage: Captured leads saved as custom Drupal entities with full CRUD operations
Unique Features:
- Configurable Personality: Set chatbot tone (Friendly, Professional, Casual, Formal) to match your brand
- Custom FAQ Integration: Define frequently asked questions the bot can answer during lead capture
- RESTful API: Headless-ready with JSON endpoints for external frontend integration
- Real-time Feedback: Special tag system allows AI to signal captured information and conversation completion
- Views Integration: Leads are entities, so you can create custom Views, exports, and reports
When to Use This Module:
- You want to qualify leads before they reach your sales team
- Traditional contact forms have low conversion rates
- You need 24/7 visitor engagement without live chat staff
- You want to provide instant answers to common questions while capturing contact info
- You're building a headless Drupal site and need a conversational API
Use Cases:
- Service-based businesses (web design, consulting, legal, etc.)
- E-commerce sites with complex product catalogs
- Educational institutions answering admissions questions
- SaaS companies qualifying trial signups
- Event websites capturing registrations
Post-Installation
Initial Setup:
- Add OpenAI API Key
Edit yoursettings.phpfile and add:
$settings['ai_lead_chatbot_openai_api_key'] = 'sk-your-api-key-here';Get your API key from https://platform.openai.com/api-keys
- Configure the Chatbot
Navigate to: Configuration → Services → AI Lead Chatbot (/admin/config/services/ai-chatbot)
Configure:- Business Name: Your company/organization name
- Chatbot Tone: Choose the conversation style
- FAQ: Add frequently asked questions (one per line)
- OpenAI Model: Select GPT model (gpt-4o-mini recommended for cost/performance)
- Temperature: Control response creativity (0.7 default)
- Max Tokens: Set response length limit (150 default)
- Enable Widget: Check to show the chat button on all pages
- Set Permissions
Go to: People → Permissions (/admin/people/permissions)
Grant these permissions to appropriate roles:- Administer AI Lead Chatbot: For site admins configuring the chatbot
- View chatbot leads: For marketing/sales teams viewing captured leads
- Manage chatbot leads: For users who can edit/delete leads
- View Captured Leads
Access leads at: Content → Chatbot Leads (/admin/content/ai-chatbot-leads)
Configuration Tips:
- Start with
gpt-4o-minifor lower costs while testing - Use Temperature 0.7 for balanced responses; lower for more consistent, higher for more creative
- Add 5-10 key FAQs that align with your services
- Test the conversation flow before going live
Widget Behavior:
The floating chat button appears in the bottom-right corner of every page. When clicked, it initiates a conversation that:
- Greets the visitor and asks about their service interest
- Collects their name
- Requests contact information (email or phone)
- Confirms submission and thanks them
Leads are automatically saved when all three pieces of information are collected.
Additional Requirements
Required:
- Drupal Core: 11.x
- PHP: 8.3 or higher
- OpenAI API Account: Sign up at https://platform.openai.com
- OpenAI API Key: Requires active credits/billing on OpenAI account
- Guzzle HTTP Client: Included with Drupal core (no additional installation)
Cost Considerations:
- This module uses the OpenAI API which charges per token (input + output)
- Typical conversation costs $0.001 - $0.01 USD depending on model and length
gpt-4o-miniis recommended for production use (significantly cheaper than gpt-4)- Monitor usage in your OpenAI dashboard: https://platform.openai.com/usage