Configuration
Relevant source files
The following files were used as context for generating this wiki page:
Configuration for the Inbox Zero project is managed primarily through environment variables. These variables control everything from database connections and third-party API keys to application behavior and feature flags. For local development, these variables are defined in an .env file, which is a copy of .env.example.
The project uses Zod in files like apps/web/env.ts to validate and type-safe the environment variables at runtime, ensuring that the application starts with the necessary configuration. This documentation outlines the key configuration areas, required variables, and setup procedures for self-hosting the application.
Sources: README.md:120-125, ARCHITECTURE.md:128-142
Environment Variables
Environment variables are the primary method of configuring the Inbox Zero applications. The main web application (apps/web) and the unsubscriber service (apps/unsubscriber) each have their own set of variables.
Core Application Variables (apps/web)
These variables are essential for the basic operation of the main web application. They are defined in apps/web/.env.
| Variable | Description | Required |
|---|---|---|
AUTH_SECRET | A random string for session encryption. | Yes |
EMAIL_ENCRYPT_SECRET | A secret key for encrypting OAuth tokens. | Yes |
EMAIL_ENCRYPT_SALT | A salt for encrypting OAuth tokens. | Yes |
NEXT_PUBLIC_BASE_URL | The public URL where the app is hosted (e.g., http://localhost:3000). | Yes |
INTERNAL_API_KEY | A secret key for securing internal API calls. | Yes |
DATABASE_URL | Connection string for the PostgreSQL database. | Yes |
UPSTASH_REDIS_URL | URL for the Upstash Redis instance. | Yes (or use Docker) |
UPSTASH_REDIS_TOKEN | Token for the Upstash Redis instance. | Yes (or use Docker) |
ADMINS | Comma-separated list of admin email addresses. | No |
MAX_DURATION | Sets the Vercel function duration limit. | No |
Sources: README.md:127-142
Third-Party Service Keys
Inbox Zero integrates with various external services for authentication, analytics, email sending, and more.
| Variable | Service | Purpose |
|---|---|---|
GOOGLE_CLIENT_ID | Google Cloud | OAuth for user authentication and Gmail API access. |
GOOGLE_CLIENT_SECRET | Google Cloud | OAuth for user authentication and Gmail API access. |
MICROSOFT_CLIENT_ID | Microsoft Azure | OAuth for user authentication and Outlook API access. |
MICROSOFT_CLIENT_SECRET | Microsoft Azure | OAuth for user authentication and Outlook API access. |
GOOGLE_PUBSUB_TOPIC_NAME | Google Cloud | Pub/Sub topic for real-time email notifications. |
GOOGLE_PUBSUB_VERIFICATION_TOKEN | Google Cloud | Verification token for the Pub/Sub webhook. |
LEMON_SQUEEZY_* | Lemon Squeezy | Payment processing and license keys. |
RESEND_API_KEY | Resend | Transactional email sending. |
TINYBIRD_* | Tinybird | Real-time analytics. |
POSTHOG_* | PostHog | Product analytics and feature flags. |
AXIOM_* | Axiom | Log management. |
SENTRY_DSN | Sentry | Error tracking. |
NEXT_PUBLIC_GTM_ID | Google Tag Manager | Website analytics. |
Sources: ARCHITECTURE.md:131-142, README.md:146-162, 190-221, apps/web/app/layout.tsx:150-152
LLM Provider Configuration
The application supports multiple Large Language Model (LLM) providers. You must configure at least one. The model can be selected by the user in the application settings.
| Variable | Provider | Description |
|---|---|---|
ANTHROPIC_API_KEY | Anthropic | API key for Anthropic models. |
OPENAI_API_KEY | OpenAI | API key for OpenAI models. |
AWS_BEDROCK_* | AWS Bedrock | Credentials for using Anthropic on AWS Bedrock. |
GOOGLE_AI_API_KEY | Google AI | API key for Gemini models. |
GROQ_API_KEY | Groq | API key for Groq models. |
OLLAMA_BASE_URL | Ollama | Base URL for a local Ollama instance (e.g., http://localhost:11434/api). |
NEXT_PUBLIC_OLLAMA_MODEL | Ollama | The default Ollama model to use (e.g., phi3). |
DEFAULT_LLM_PROVIDER | - | Sets the default LLM provider if using a local one like Ollama. |
ECONOMY_LLM_PROVIDER | - | Must be set if DEFAULT_LLM_PROVIDER is used. |
Sources: README.md:225-251, ARCHITECTURE.md:131, apps/web/utils/ai/assistant/chat.ts:1003-1007
OAuth Configuration
Setting up OAuth is a critical step for allowing users to connect their Google or Microsoft email accounts.
Google OAuth Setup
The process involves creating credentials in the Google Cloud Console, configuring the consent screen, and adding the necessary API scopes.
The following diagram illustrates the setup flow for Google OAuth.
This diagram shows the required steps to configure Google OAuth credentials and scopes.
Sources: README.md:146-188
Microsoft OAuth Setup
The process for Microsoft involves registering an application in the Azure Active Directory portal, setting redirect URIs, creating a client secret, and configuring API permissions.
A detailed list of required delegated permissions for Microsoft Graph includes:
openid,profile,email,User.Read,offline_accessMail.ReadWrite,Mail.Send,Mail.ReadBasic,Mail.Read,Mail.Read.SharedMailboxSettings.ReadWrite,Contacts.ReadWrite
Sources: README.md:190-221
Docker Configuration
When building the application as a Docker image, it's crucial to handle environment variables correctly, especially those prefixed with NEXT_PUBLIC_.
Build-Time Variables
Variables like NEXT_PUBLIC_BASE_URL are embedded into the JavaScript bundles at build time. This means their value cannot be changed at runtime by setting an environment variable on the container. You must provide them as build arguments when creating the image.
The following diagram shows how build arguments are passed to the Docker build process.
This diagram illustrates that NEXT_PUBLIC_ variables must be injected at build time and cannot be overridden at runtime.
Example Build Command:
docker build \
--build-arg NEXT_PUBLIC_BASE_URL="https://your-domain.com" \
-t inbox-zero \
-f docker/Dockerfile.prod .
All other secrets and runtime configurations (like DATABASE_URL or OPENAI_API_KEY) should be provided as environment variables when running the container.
Sources: docker/DOCKER_BUILD_GUIDE.md, README.md:308-330
Cron Jobs & Webhooks
To handle emails in real-time and perform scheduled tasks, the application relies on webhooks and cron jobs.
Google Pub/Sub for Real-Time Updates
For real-time email processing, you must set up Google Pub/Sub. This involves:
- Creating a Pub/Sub topic.
- Creating a push subscription for that topic.
- Granting Gmail permission to publish notifications to your topic.
The subscription's push endpoint should point to your application's webhook handler: https://<your-domain>/api/google/webhook?token=<YOUR_TOKEN>.
The following environment variables are required:
GOOGLE_PUBSUB_TOPIC_NAME: The name of your Pub/Sub topic.GOOGLE_PUBSUB_VERIFICATION_TOKEN: The secure token (<YOUR_TOKEN>) used in the webhook URL.
Sources: README.md:270-289
Scheduled Tasks
The application requires cron jobs for periodic maintenance and functionality.
| Path | Schedule | Description |
|---|---|---|
/api/watch/all | 0 1 * * * | Renews the watch on all connected Gmail accounts. This is necessary. |
/api/resend/summary/all | 0 16 * * 1 | Sends a weekly digest email to users. Optional. |
/api/reply-tracker/disable-unused-auto-draft | 0 3 * * * | Disables auto-drafting for unused reply tracking. Optional. |
These can be configured using a service like Upstash Cron or any other cron job provider.
Sources: README.md:291-306