Environment Variables
Haggle uses environment variables for configuration. Create aconfig.py file in the project root or use .env files.
The
config.py file is gitignored for security. You’ll need to create it manually with your credentials.Backend Configuration
Creating config.py
Create aconfig.py file in the root directory:
config.py
Alternative: Using .env File
You can also create a.env file in the project root:
.env
Required API Keys
Get xAI API Key
Haggle uses Grok LLM for task inference and question generation.
- Visit x.ai and sign up for an account
- Navigate to the API section
- Generate a new API key
- Copy the key to your
config.pyor.envfile
If no
XAI_API_KEY is provided, Haggle will use fallback logic (rule-based task inference and default questions).Get Supabase Credentials
Supabase provides your PostgreSQL database.
- Go to your Supabase Dashboard
- Select your project
- Navigate to Settings → API
- Copy the following:
- Project URL →
SUPABASE_URL - anon public key →
SUPABASE_KEY
- Project URL →
Use the
anon key for development. For production, consider using the service_role key with proper security measures.Configuration Reference
Core Settings
API key for xAI’s Grok LLM. Used for:
- Task inference from user queries
- Generating clarifying questions
- Formatting problem statements
- Extracting negotiated prices from call transcripts
Your Supabase project URL (format:
https://[project-id].supabase.co)Example: https://podtjfttutrybvotsduh.supabase.coSupabase anon/public API key for database operationsLocation: Dashboard → Settings → API → anon public
Optional Settings
Maximum number of service providers to return from searchRange: 1-20 recommended
URL of the voice calling backend serviceUsed by:
/api/start-calls/{job_id} endpoint in main.py:381Voice Calling Configuration
Twilio account identifier for voice calling
Twilio authentication token
Your Twilio phone number (E.164 format: +1234567890)
Public domain for TwiML webhooks (required for voice calling)Example:
your-app.ngrok.io or api.yourdomain.comDatabase Schema
Theproviders table stores service provider information:
| Column | Type | Description |
|---|---|---|
id | BIGSERIAL | Primary key |
service_provider | TEXT | Provider name (NOT NULL) |
phone_number | TEXT | Contact phone |
context_answers | TEXT | Formatted Q&A paragraph |
house_address | TEXT | Full customer address |
zip_code | TEXT | ZIP code for location |
max_price | NUMERIC(10,2) | Customer’s budget |
job_id | TEXT | Associated job ID (NOT NULL) |
minimum_quote | NUMERIC(10,2) | Initial quote |
problem | TEXT | Problem statement |
negotiated_price | NUMERIC(10,2) | Final agreed price |
call_status | TEXT | Status: pending/in_progress/completed/failed |
call_transcript | TEXT | Full call transcript |
created_at | TIMESTAMPTZ | Creation timestamp |
Verifying Configuration
Test your configuration with the CLI demo:- ✅ Supabase connection established
- ✅ Grok LLM API working (or fallback active)
- ✅ Database schema correct
You should see output like:
Next Steps
Running Locally
Start the development servers
API Reference
Explore the API endpoints