Complete guide for setting up the TutorBot environment variables and configuration.
This guide covers all environment variables needed for TutorBot, including Chatwoot integration, Stripe payments, Google Calendar, and OpenAI services.
Before configuring environment variables, ensure you have:
Copy the example file and configure your values:
cp env_example.txt .env
Required for core functionality:
# Chatwoot instance URL
CW_URL=https://crm.stephenadei.nl
# Account ID (usually 1 for single-tenant)
CW_ACC_ID=1
# Bot token for sending messages
CW_TOKEN=your_bot_token_here
# Admin token for API operations
CW_ADMIN_TOKEN=your_admin_token_here
# HMAC secret for webhook verification
CW_HMAC_SECRET=your_hmac_secret_here
How to get these values:
Required for payment processing:
# Webhook secret from Stripe
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret_here
# Price IDs for different segments
STANDARD_PRICE_ID_60=price_your_standard_60min_price_id
STANDARD_PRICE_ID_90=price_your_standard_90min_price_id
WEEKEND_PRICE_ID_60=price_your_weekend_60min_price_id
WEEKEND_PRICE_ID_90=price_your_weekend_90min_price_id
How to get these values:
https://your-domain.com/webhook/paymentsRequired for scheduling functionality:
# Service account JSON file path
GCAL_SERVICE_ACCOUNT_JSON=/app/config/gcal-service-account.json
# Calendar ID (usually 'primary')
GCAL_CALENDAR_ID=primary
How to get these values:
config/gcal-service-account.jsonRequired for message analysis and prefill:
# OpenAI API key
OPENAI_API_KEY=sk-proj-your_openai_api_key_here
# Model to use (recommended: gpt-4o-mini)
OPENAI_MODEL=gpt-4o-mini
How to get these values:
General system settings:
# Timezone for scheduling
TZ=Europe/Amsterdam
# Flask environment
FLASK_ENV=production
.env file to version control.env.example for templateschmod 600 .env# Export environment variables
source scripts/dev/export_env.sh
# Validate configuration
python3 scripts/validate_structure.py
# Test connections
python3 scripts/test_chatwoot_api.py
# Development
FLASK_ENV=development
DEBUG_MODE=console
# Production
FLASK_ENV=production
DEBUG_MODE=disabled
# Development
CW_URL=https://dev-chatwoot.example.com
STRIPE_WEBHOOK_SECRET=whsec_dev_secret
# Production
CW_URL=https://crm.stephenadei.nl
STRIPE_WEBHOOK_SECRET=whsec_prod_secret
# Update environment variables
source scripts/dev/export_env.sh
# Restart application
docker-compose restart tutorbot
# Verify changes
docker-compose logs tutorbot
# Check if variables are set
env | grep CW_
env | grep STRIPE_
env | grep OPENAI_
# Export if missing
source scripts/dev/export_env.sh
# Test Chatwoot connection
curl -H "api_access_token: $CW_ADMIN_TOKEN" \
"$CW_URL/api/v1/accounts/$CW_ACC_ID/contacts"
# Test OpenAI connection
curl -H "Authorization: Bearer $OPENAI_API_KEY" \
"https://api.openai.com/v1/models"
# Check webhook endpoint
curl -X POST https://your-domain.com/cw \
-H "Content-Type: application/json" \
-d '{"test": "webhook"}'
# Verify HMAC signature
# (Check Chatwoot webhook logs)
# Enable debug mode
./scripts/debug_toggle.sh on
# Check debug status
./scripts/debug_toggle.sh status
# View debug logs
docker-compose logs -f tutorbot
# Backup environment file
cp .env .env.backup.$(date +%Y%m%d)
# Restore from backup
cp .env.backup.20250806 .env
Last Updated: August 2025
Version: 2.0
Maintainer: Stephen Adei