Overview
The Lead Intelligence Engine uses a combination of environment variables (.env file) and JSON configuration files to customize behavior. This guide covers all configuration options.
Environment Variables
All sensitive credentials and service endpoints are stored in a.env file in the project root.
Creating .env File
Create a new file named.env in the source/ directory:
.env
Required Variables
These variables are mandatory for basic CLI functionality:GROQ_API_KEY
Purpose: Authenticates with Groq’s LLM API for business analysis How to obtain:- Sign up at groq.com
- Navigate to API Keys section
- Create a new API key
- Copy the key (starts with
gsk_)
gsk_... (string)
Example:
Groq offers a generous free tier. Monitor usage at console.groq.com to avoid rate limits.
CODA_API_TOKEN
Purpose: Authenticates with Coda’s API to read/write CRM data How to obtain:- Go to coda.io/account
- Scroll to “API Settings”
- Click “Generate API token”
- Copy the token
CODA_DOC_ID
Purpose: Identifies which Coda document contains your CRM table How to obtain:- Open your Coda CRM document
- Look at the URL:
https://coda.io/d/_dABCDEFGHI/... - The Doc ID is the part after
/d/:ABCDEFGHI
CODA_TABLE_ID
Purpose: Identifies which table within the Coda document to write leads to How to obtain:- Open your Coda document
- Right-click the table
- Select “Copy table link”
- The Table ID is the part after
/table/:grid-abc123
grid-
Example:
Optional Variables
These variables are only needed for specific features:TELEGRAM_BOT_TOKEN
Purpose: Enables the Telegram bot interface Required for: Runningtelegram_bot.py only (not needed for CLI)
How to obtain:
- Message @BotFather on Telegram
- Send
/newbotand follow instructions - Copy the token provided
<bot_id>:<token>
Example:
If you only use the CLI (
main.py), you can omit this variable.FACEBOOK_APP_ID
Purpose: Facebook App ID for Graph API access to extract public page data Required for: Analyzing Facebook page URLs (e.g.,facebook.com/BusinessPage)
How to obtain:
- Create a Facebook app at developers.facebook.com
- Navigate to Settings → Basic
- Copy the App ID
If both
FACEBOOK_APP_ID and FACEBOOK_APP_SECRET are provided, an access token is automatically generated. Alternatively, you can provide FACEBOOK_ACCESS_TOKEN directly.FACEBOOK_APP_SECRET
Purpose: Facebook App Secret for access token generation Required for: Analyzing Facebook page URLs (works withFACEBOOK_APP_ID)
How to obtain:
- Same Facebook app from above
- Navigate to Settings → Basic
- Click Show next to “App Secret”
- Copy the secret
FACEBOOK_ACCESS_TOKEN
Purpose: Pre-generated Facebook Graph API access token (alternative to App ID/Secret) Required for: Analyzing Facebook page URLs (alternative to using App ID + Secret) How to obtain:- Use Graph API Explorer
- Select your app
- Generate a token with public page permissions
- Copy the token
Auto-generation: If
FACEBOOK_ACCESS_TOKEN is not provided but both FACEBOOK_APP_ID and FACEBOOK_APP_SECRET are set, the engine automatically generates a token in the format {APP_ID}|{APP_SECRET}. This is suitable for accessing public page data.Service Configuration
The engine’s service offerings are defined inservices/services.json. This file controls which services the AI can recommend.
File Structure
services/services.json
Customizing Services
Edit services.json
Add, remove, or modify service definitions. Each service requires:
name: Unique service identifier (used in AI output)categoryorfocus: Service classificationideal_for: Target customer typesuse_case_signals: Keywords the AI uses to match businesses
Adding New Services
Example: Adding a “Maintenance Package”:Knowledge Base Setup
Theknowledge/ directory contains RAG (Retrieval-Augmented Generation) context files that enrich AI analysis.
Directory Structure
How RAG Works
- Website content is extracted
- RAG system searches
knowledge/for relevant context - Context is injected into the AI prompt
- AI uses both website content + knowledge base to make decisions
Adding Knowledge Files
System Prompt Configuration
The system prompt (prompts/system_prompt.md) defines how the AI evaluates businesses.
Default Prompt
prompts/system_prompt.md
Customizing the Prompt
Example: Adjusting Exclusion Rules
Example: Adjusting Exclusion Rules
prompts/system_prompt.md
Example: Adding Scoring Criteria
Example: Adding Scoring Criteria
prompts/system_prompt.md
Prompt Injection Guards
The prompt includes guardrails to prevent hallucinations:Model Configuration
The LLM model is hardcoded inevaluator.py but can be changed:
Current Model
evaluator.py
Changing the Model
Editevaluator.py:23:
llama-3.3-70b-versatile(default, best balance)llama-3.1-70b-versatile(faster, slightly less accurate)mixtral-8x7b-32768(larger context window)gemma2-9b-it(smaller, faster, lower cost)
Validation
Verify your configuration is correct:Environment Variables
validate_env.py
Service Configuration
Full System Test
Troubleshooting
”GROQ_API_KEY not found in environment variables”
Your.env file is missing or not being loaded:
- Verify
.envexists in the same directory asmain.py - Check file contents (should have
GROQ_API_KEY=...) - Ensure no extra spaces around
=sign - Restart your terminal/IDE to reload environment
”Coda configuration is incomplete”
One or more Coda variables are missing:True.
”Failed to load services from services/services.json”
- Verify file exists:
ls services/services.json - Check for JSON syntax errors:
python -m json.tool services/services.json - Ensure file is readable:
cat services/services.json
”Selected primary service ‘X’ is not in the approved list”
The AI tried to suggest a service not inservices.json. This indicates:
- The system prompt references services not in
services.json - The AI hallucinated a service name
prompts/system_prompt.md exist in services/services.json with exact name matches.
Next Steps
CLI Usage
Start analyzing leads with the command-line interface
Coda Integration
Set up your CRM to receive analyzed leads