Appearance
AI Setup Guide ​
Overview ​
This guide covers the setup and configuration of the AI Project Analyzer feature, including Mistral AI integration and n8n webhook configuration.
Prerequisites ​
- Supabase project with Edge Functions enabled
- Mistral AI API key
- n8n instance (optional, for admin notifications)
Mistral AI Setup ​
1. Get Mistral API Key ​
- Visit Mistral AI Console
- Sign up or log in to your account
- Navigate to API Keys section
- Create a new API key
- Copy the key for configuration
2. Configure Supabase Secret ​
Add the Mistral API key as a Supabase project secret:
bash
# Using Supabase CLI
supabase secrets set MISTRAL_API_KEY=your_mistral_api_key_here --project-ref nujcbrbtejvhuajfwgeo
# Or via Supabase Dashboard
# Go to Project Settings > Edge Functions > Secrets
# Add: MISTRAL_API_KEY = your_mistral_api_key_here3. Deploy Edge Function ​
Deploy the analyze-project Edge Function:
bash
supabase functions deploy analyze-project --project-ref nujcbrbtejvhuajfwgeo4. Verify Configuration ​
Test the Edge Function:
bash
curl -X POST https://nujcbrbtejvhuajfwgeo.supabase.co/functions/v1/analyze-project \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_SUPABASE_ANON_KEY' \
-d '{"url":"https://example.com"}'n8n Webhook Setup (Optional) ​
1. Create n8n Webhooks ​
Set up webhooks in your n8n instance:
- General Webhook:
https://n8n.10alert.com/webhook/95e9d69b-25c0-4642-bd84-9a52ad68f912 - Chat Webhook:
https://n8n.10alert.com/webhook/64ea74c0-2f7d-46d6-bec8-d988607b951b - Listing Webhook:
https://n8n.10alert.com/webhook/95e9d69b-25c0-4642-bd84-9a52ad68f912
2. Configure Supabase Secrets ​
Add n8n webhook URLs as Supabase secrets:
bash
supabase secrets set N8N_WEBHOOK_URL=https://n8n.10alert.com/webhook/95e9d69b-25c0-4642-bd84-9a52ad68f912 --project-ref nujcbrbtejvhuajfwgeo
supabase secrets set N8N_WEBHOOK_CHAT=https://n8n.10alert.com/webhook/64ea74c0-2f7d-46d6-bec8-d988607b951b --project-ref nujcbrbtejvhuajfwgeo
supabase secrets set N8N_WEBHOOK_LISTING=https://n8n.10alert.com/webhook/95e9d69b-25c0-4642-bd84-9a52ad68f912 --project-ref nujcbrbtejvhuajfwgeo3. Deploy Related Functions ​
Deploy functions that use n8n webhooks:
bash
supabase functions deploy n8n-chat --project-ref nujcbrbtejvhuajfwgeo
supabase functions deploy send-admin-listing-notification --project-ref nujcbrbtejvhuajfwgeoEnvironment Variables ​
Frontend (.env.local) ​
env
# Supabase Configuration
VITE_SUPABASE_URL=https://nujcbrbtejvhuajfwgeo.supabase.co
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
# Other existing variables...Backend (Supabase Secrets) ​
env
# Mistral AI
MISTRAL_API_KEY=your_mistral_api_key
# n8n Webhooks (Optional)
N8N_WEBHOOK_URL=https://n8n.10alert.com/webhook/95e9d69b-25c0-4642-bd84-9a52ad68f912
N8N_WEBHOOK_CHAT=https://n8n.10alert.com/webhook/64ea74c0-2f7d-46d6-bec8-d988607b951b
N8N_WEBHOOK_LISTING=https://n8n.10alert.com/webhook/95e9d69b-25c0-4642-bd84-9a52ad68f912Testing the Setup ​
1. Test AI Project Analysis ​
Start the development server:
bashpnpm devNavigate to
/create-listingLog in with a test account
Enter a project URL (e.g.,
https://windowsreport.com)Click "Analyze Project"
Verify that fields are populated correctly
2. Test Error Handling ​
Test various error scenarios:
- Invalid URL: Enter an invalid URL format
- Rate Limit: Test with multiple rapid requests
- Network Error: Test with offline network
- Authentication: Test without being logged in
3. Verify Logs ​
Check logs for debugging:
- Frontend: Browser console logs
- Backend: Supabase Edge Function logs
- Database: Check for any data inconsistencies
Troubleshooting ​
Common Issues ​
401 Unauthorized
- Ensure user is logged in
- Check JWT token validity
- Verify
verify_jwt = truein config
429 Rate Limit
- Mistral API rate limit exceeded
- Wait 10 minutes before retrying
- Consider upgrading Mistral plan
500 Internal Server Error
- Check Mistral API key validity
- Verify Edge Function deployment
- Check Supabase function logs
JSON Parse Errors
- System automatically attempts recovery
- Check Mistral API response format
- Verify prompt optimization
Debug Steps ​
Check Secrets:
bashsupabase secrets list --project-ref nujcbrbtejvhuajfwgeoTest Edge Function:
bashsupabase functions serve analyze-project --project-ref nujcbrbtejvhuajfwgeoCheck Logs:
bashsupabase functions logs analyze-project --project-ref nujcbrbtejvhuajfwgeo
Production Considerations ​
Security ​
- Never expose API keys in frontend code
- Use Supabase secrets for all sensitive data
- Implement proper rate limiting
- Monitor API usage and costs
Performance ​
- Monitor Mistral API response times
- Implement caching for repeated requests
- Optimize prompts for token efficiency
- Set appropriate timeouts
Monitoring ​
- Set up alerts for API failures
- Monitor Edge Function execution times
- Track AI analysis success rates
- Log user interactions for analytics
Cost Management ​
Mistral AI Costs ​
- Monitor token usage in Mistral dashboard
- Optimize prompts to reduce token consumption
- Implement fallback strategies for rate limits
- Consider usage-based pricing models
n8n Costs ​
- Monitor webhook execution frequency
- Optimize workflow efficiency
- Consider self-hosting for high volume