AI Webchat 404 Fix Guide¶
Problem¶
~/dashboard/user/openai/webchat returns 404 error
Root Cause¶
The middleware CheckTemplateTypeAndPlan is checking for:
1. A feature_ai_webchat column in the settings table (doesn't exist yet - migration not run)
2. An ai_webchat entry in the openai table (may not exist)
Solution: Run SQL Manually¶
Since the migration can't be run via php artisan migrate in this environment, you need to run SQL directly on your database.
Quick Fix (3 SQL Statements)¶
Connect to your database and run these 3 commands:
1. Add the feature flag column¶
2. Insert the ai_webchat entry (if it doesn't exist)¶
INSERT INTO openai (title, description, slug, active, questions, image, premium, type, created_at, updated_at, color, filters)
VALUES (
'AI Web Chat',
'Analyze web page content with url',
'ai_webchat',
1,
'[{"name":"your_description","type":"textarea","question":"Description","select":""}]',
'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" stroke-width="2" stroke="black" fill="none" viewBox="0 0 24 24"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 4l6 16l6 -16" /></svg>',
0,
'text',
NOW(),
NOW(),
'#A3D6C2',
'blog'
);
3. Insert the chat category (if it doesn't exist)¶
INSERT INTO openai_chat_category (name, slug, role, human_name, helps_with, color, created_at, updated_at)
VALUES (
'AI Web Chat',
'ai_webchat',
'You are an AI Web Content Analyzer. You help users understand and extract insights from web pages.',
'Web Chat',
'Analyzing web page content, answering questions about websites, extracting key information from URLs',
'#A3D6C2',
NOW(),
NOW()
);
Verification¶
After running the SQL, verify with these queries:
-- 1. Check feature flag exists and is enabled
SELECT feature_ai_webchat FROM settings LIMIT 1;
-- Expected: 1
-- 2. Check openai entry exists
SELECT id, slug, active FROM openai WHERE slug = 'ai_webchat';
-- Expected: 1 row with active = 1
-- 3. Check chat category exists
SELECT id, slug FROM openai_chat_category WHERE slug = 'ai_webchat';
-- Expected: 1 row
Still Getting 404?¶
Check Your User Account¶
The middleware checks:
1. If you're an admin → Bypasses all checks (line 17 of middleware)
2. If you're a free user → Checks if ai_webchat is in free_open_ai_items setting
3. If you have a plan → Checks if ai_webchat is in your plan's open_ai_items
Option A: Make yourself admin (easiest)¶
-- Replace YOUR_EMAIL with your actual email
UPDATE users SET user_type = 'admin' WHERE email = 'YOUR_EMAIL';
Option B: Add ai_webchat to your plan¶
-- First, find your plan ID
SELECT u.id, u.email, u.plan_id, p.name as plan_name, p.open_ai_items
FROM users u
LEFT JOIN plans p ON u.plan_id = p.id
WHERE u.email = 'YOUR_EMAIL';
-- Then add ai_webchat to the plan's allowed features
-- (Assumes MySQL 5.7+ with JSON functions)
UPDATE plans
SET open_ai_items = JSON_ARRAY_APPEND(COALESCE(open_ai_items, '[]'), '$', 'ai_webchat')
WHERE id = YOUR_PLAN_ID;
Option C: Add ai_webchat to free user items¶
-- This allows all free users to access webchat
UPDATE settings
SET free_open_ai_items = JSON_ARRAY_APPEND(COALESCE(free_open_ai_items, '[]'), '$', 'ai_webchat');
Alternative: Run Migration on Server¶
If you have SSH access to your server:
# SSH into your server
ssh user@your-server.com
# Navigate to project directory
cd /path/to/vell-main
# Run migrations
php artisan migrate
# Clear caches
php artisan cache:clear
php artisan config:clear
php artisan route:clear
Environment-Specific Instructions¶
Local Development (Docker/XAMPP/MAMP)¶
- Access phpMyAdmin
- Select your database
- Go to SQL tab
- Paste and run the 3 SQL statements above
AWS RDS (MySQL/PostgreSQL)¶
- Connect via MySQL Workbench or pgAdmin
- Run the SQL statements
- Alternatively, use AWS Console → RDS → Query Editor
Laravel Forge/Envoyer¶
- Use the web-based database manager
- Or SSH and run:
php artisan migrate
Heroku¶
Complete SQL Script¶
See docs/WEBCHAT_FIX_SQL.sql for the complete script with all verification and troubleshooting queries.
After Fixing¶
Once the 404 is resolved, refer to docs/WEBCHAT_PDF_STRATEGY.md for:
- How to repurpose AI Webchat into "Partner Intel Assistant"
- Integration with AgentCore for automated prospect research
- Knowledge base implementation roadmap
Toggle Feature On/Off¶
After the fix is applied, you can control webchat visibility:
Admin UI¶
- Go to:
/dashboard/admin/config/ai-tools - Find "AI Web Chat" toggle
- Enable/disable as needed
Database (Manual)¶
-- Enable
UPDATE settings SET feature_ai_webchat = 1;
-- Disable (returns 404)
UPDATE settings SET feature_ai_webchat = 0;
Questions?¶
See the middleware logic in:
- app/Http/Middleware/CheckTemplateTypeAndPlan.php:110-138 (feature flag mapping)
- app/Http/Middleware/CheckTemplateTypeAndPlan.php:92-105 (access control logic)