> ## Documentation Index
> Fetch the complete documentation index at: https://docs.callintel.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Configure CallIntel for your environment. Comprehensive guide to configuring CallIntel for your deployment.

## Environment Variables

All configuration is managed through environment variables. Create a `.env` file in the project root:

```env theme={null}
# Required: Environment type
Environment=local  # or production
Queue_Environment=local

# AI Provider APIs
GEMINI_API_KEY=your_gemini_key
OPENAI_API_KEY=your_openai_key

# Hume AI (Emotional Intelligence)
HUME_CONFIG_ID=your_config_id
HUME_API_KEY=your_hume_key
HUME_SECRET_KEY=your_hume_secret

# Telephony Providers
TWILIO_ACCOUNT_ID=your_twilio_sid
TWILIO_AUTH_TOKEN=your_twilio_token

# Alternative: Plivo
PLIVO_AUTH_ID=your_plivo_id
PLIVO_AUTH_TOKEN=your_plivo_token

# Database
SUPABASE_URL=https://xxx.supabase.co
SUPABASE_KEY=your_supabase_key

# MCP Service URLs (Docker)
WHATSAPP_MCP_SERVER_URL=http://whatsapp_mcp:8102
TELE_MCP_SERVER_URL=http://tele_mcp:8100
GMAIL_MCP_SERVER_URL=http://gmail_mcp:8101

# Server Configuration
PORT=8010
SERVER_DOMAIN=localhost:8010
SECURE_HEADERS=false
CORS_ORIGINS=*

# Logging
LOG_LEVEL=INFO

# Optional: LiveKit (for real-time communication)
LIVEKIT_URL=ws://livekit:7880
LIVEKIT_API_KEY=your_livekit_key
LIVEKIT_API_SECRET=your_livekit_secret
```

## Configuration Files

### Local Configuration

File: `configure/local_config.py`

```python theme={null}
import os
from dotenv import load_dotenv

load_dotenv()

# Logging
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")

# API Configuration
API_HOST = os.getenv("SERVER_DOMAIN", "localhost:8010")
API_PORT = int(os.getenv("PORT", 8010))

# Database
SUPABASE_URL = os.getenv("SUPABASE_URL")
SUPABASE_KEY = os.getenv("SUPABASE_KEY")

# AI Providers
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")

# Telephony
TWILIO_ACCOUNT_ID = os.getenv("TWILIO_ACCOUNT_ID")
TWILIO_AUTH_TOKEN = os.getenv("TWILIO_AUTH_TOKEN")

# MCP Services
MCP_SERVICES = {
    "telegram": os.getenv("TELE_MCP_SERVER_URL", "http://localhost:8100"),
    "gmail": os.getenv("GMAIL_MCP_SERVER_URL", "http://localhost:8101"),
    "whatsapp": os.getenv("WHATSAPP_MCP_SERVER_URL", "http://localhost:8102"),
}
```

### Production Configuration

File: `configure/production_config.py`

Similar structure but with production-specific settings:

* Disabled API documentation (docs\_url=None)
* Stricter CORS configuration
* Enhanced logging for monitoring
* Database connection pooling

## AI Provider Configuration

### Google Gemini

```python theme={null}
from bridges.gemini_bridge_base import GeminiBridgeBase

agent = GeminiBridgeBase(
    api_key="your_gemini_key",
    model="gemini-2.0-flash-exp",  # Latest model
    system_prompt="Your custom system prompt",
    temperature=0.7,
    max_tokens=1024
)
```

**Required Settings:**

* `GEMINI_API_KEY`: From Google Cloud Console
* Model selection: gemini-2.0-flash-exp, gemini-pro, etc.

### OpenAI

```python theme={null}
from bridges.open_ai import OpenAIBridge

agent = OpenAIBridge(
    api_key="your_openai_key",
    model="gpt-4",
    system_prompt="Your custom system prompt",
    temperature=0.7
)
```

**Required Settings:**

* `OPENAI_API_KEY`: From OpenAI API dashboard
* Model: gpt-4, gpt-3.5-turbo, gpt-4-turbo, etc.

### Hume AI (Emotional Intelligence)

```python theme={null}
from bridges.hume_bridge import HumeBridge

agent = HumeBridge(
    config_id="your_config_id",
    api_key="your_hume_key",
    secret_key="your_hume_secret"
)
```

**Required Settings:**

* `HUME_CONFIG_ID`: Configuration ID from Hume AI
* `HUME_API_KEY`: Public API key
* `HUME_SECRET_KEY`: Secret key for authentication

## Telephony Configuration

### Twilio

```python theme={null}
from twilio.rest import Client

client = Client(
    account_sid=os.getenv("TWILIO_ACCOUNT_ID"),
    auth_token=os.getenv("TWILIO_AUTH_TOKEN")
)
```

**Setup Steps:**

1. Create Twilio account at twilio.com
2. Get Account SID and Auth Token
3. Purchase phone number or verify test number
4. Configure webhook URL for incoming calls

### Plivo

```python theme={null}
from plivo import RestClient

client = RestClient(
    auth_id=os.getenv("PLIVO_AUTH_ID"),
    auth_token=os.getenv("PLIVO_AUTH_TOKEN")
)
```

**Setup Steps:**

1. Create Plivo account
2. Get Auth ID and Token
3. Purchase DID number
4. Set up message URL

## Database Configuration

### Supabase

```python theme={null}
from Service.Supabase import get_supabase_client

supabase = get_supabase_client()

# Tables are auto-created on first run
# Tables include:
# - organizations
# - agents
# - calls
# - contact_forms
# - scheduled_calls
# - batch_calls
```

**Setup Steps:**

1. Create Supabase project
2. Copy Project URL and API Key
3. Set `SUPABASE_URL` and `SUPABASE_KEY`

## Server Configuration

### Port Configuration

```env theme={null}
PORT=8010
SERVER_DOMAIN=localhost:8010
```

### CORS Configuration

```python theme={null}
# In app.py
app.add_middleware(
    CORSMiddleware,
    allow_origins=os.getenv("CORS_ORIGINS", "*").split(","),
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)
```

### API Documentation

**Local Environment:**

* Swagger UI: `/docs`
* ReDoc: `/redoc`
* OpenAPI: `/openapi.json`

**Production Environment:**

* Documentation disabled (docs\_url=None)
* Use external tools like Postman for API testing

## Logging Configuration

### Log Levels

```env theme={null}
LOG_LEVEL=INFO  # DEBUG, INFO, WARNING, ERROR, CRITICAL
```

### Log Output

```python theme={null}
from utils.logger import logger

logger.debug("Debug message")
logger.info("Info message")
logger.warning("Warning message")
logger.error("Error message")
logger.critical("Critical message")
```

Logs are written to:

* Console (stdout)
* File: `logs/app.log` (if configured)

## MCP Service Configuration

MCP (Model Context Protocol) services handle external integrations:

### Telegram MCP

```env theme={null}
TELE_MCP_SERVER_URL=http://tele_mcp:8100
```

Configuration file: `integrations/mcp_tele/config.json`

### Gmail MCP

```env theme={null}
GMAIL_MCP_SERVER_URL=http://gmail_mcp:8101
```

OAuth credentials: `integrations/mcp_gmail/credentials.json`

### WhatsApp MCP

```env theme={null}
WHATSAPP_MCP_SERVER_URL=http://whatsapp_mcp:8102
```

Database configuration: `integrations/mcp_whatsapp/database.py`

## Agent Configuration

### System Prompts

```python theme={null}
DEFAULT_PROMPT_TEMPLATE = """
Assistant Design: "{initial_message}"

Core Identity & Purpose:
    Primary Mission: To be a helpful, human-like voice assistant

Interaction Style:
    - Professional and friendly
    - Natural conversation flow
    - Problem-solving focused
"""
```

### Voice Configuration

```python theme={null}
voice_config = {
    "provider": "twilio",  # or "elevenlabs", "google"
    "voice_id": "en-US",
    "speed": 1.0,
    "pitch": 1.0,
}
```

## Security Configuration

### API Keys

Best practices:

* Use environment variables, never commit keys
* Rotate keys regularly
* Use different keys for dev/prod
* Store in `.env` file (add to .gitignore)

### CORS

```python theme={null}
CORS_ORIGINS = [
    "https://yourdomain.com",
    "https://app.yourdomain.com",
]
```

### Authentication

```python theme={null}
from utils.auth import verify_supabase_token

@app.get("/api/protected")
async def protected_route(user: AuthenticatedUser = Depends(verify_supabase_token)):
    return {"user": user.id}
```

## Performance Tuning

### Worker Configuration

```env theme={null}
# Gunicorn (if using production server)
WORKERS=4
WORKER_CLASS=uvicorn.workers.UvicornWorker
WORKER_CONNECTIONS=1000
```

### Database Connection Pooling

```python theme={null}
SUPABASE_POOL_SIZE = 10
SUPABASE_MAX_OVERFLOW = 20
```

### Cache Configuration

```python theme={null}
REDIS_URL=redis://localhost:6379
CACHE_TTL=3600
```

## Integration Configuration

### Shopify

```env theme={null}
SHOPIFY_API_KEY=your_shopify_key
SHOPIFY_API_SECRET=your_shopify_secret
SHOPIFY_STORE_URL=your-store.myshopify.com
```

### Payment Provider

```env theme={null}
STRIPE_API_KEY=your_stripe_key
STRIPE_WEBHOOK_SECRET=your_webhook_secret
```

## Environment-Specific Configs

### Development

```env theme={null}
Environment=local
LOG_LEVEL=DEBUG
CORS_ORIGINS=*
DEBUG=true
```

### Staging

```env theme={null}
Environment=production
LOG_LEVEL=INFO
CORS_ORIGINS=https://staging.yourdomain.com
DEBUG=false
```

### Production

```env theme={null}
Environment=production
LOG_LEVEL=WARNING
CORS_ORIGINS=https://yourdomain.com
DEBUG=false
SECURE_HEADERS=true
```

## Validation

Verify your configuration:

```bash theme={null}
# Check if all required environment variables are set
python -c "from configure.local_config import *; print('Configuration loaded successfully')"

# Test API connectivity
curl http://localhost:8010/health

# Test database connection
python -c "from Service.Supabase import get_supabase_client; print(get_supabase_client())"
```

## Common Issues

### Missing API Keys

```bash theme={null}
# Generate .env from example
cp .env.example .env

# Check required variables
grep "TODO\|CHANGE_ME" .env
```

### Connection Failures

```bash theme={null}
# Test Supabase
curl https://your-project.supabase.co/health

# Test Twilio
python -c "from twilio.rest import Client; Client('sid', 'token').api.accounts.list()"
```

## Next Steps

<Card title="Quick Start" icon="rocket" href="/guides/getting-started/quickstart">
  Start building with the configured platform.
</Card>
