Feature: Reply Zero (Follow-up Tracking)
Relevant source files
The following files were used as context for generating this wiki page:- apps/web/app/(app)/[emailAccountId]/reply-zero/page.tsx
- apps/web/utils/reply-tracker/inbound.ts
- apps/web/utils/reply-tracker/outbound.ts
- apps/web/app/api/v1/reply-tracker/route.ts
- apps/web/utils/actions/reply-tracking.ts
- ARCHITECTURE.md
- apps/mcp-server/src/index.ts
- packages/resend/emails/summary.tsx
Reply Zero is a feature designed to help users track emails they need to reply to and conversations where they are awaiting a response. It provides a dedicated user interface to manage these follow-ups, ensuring important conversations are not missed.
Architecturally, Reply Zero is built upon the AI Personal Assistant as a special type of rule. This integration allows it to leverage the existing rule-processing engine to identify emails that require tracking. The system categorizes tracked threads into two main types: NEEDS_REPLY for incoming emails that require user action, and AWAITING for outgoing emails where the user is waiting for a response.
Sources: README.md:19, ARCHITECTURE.md:129-135
Architecture and Core Concepts
The Reply Zero feature is centered around the ThreadTracker database model, which records the state of tracked email threads. The system uses a combination of AI rule matching for inbound emails and logic on outbound (sent) emails to manage the lifecycle of these trackers.
Sources: ARCHITECTURE.md:129-135, apps/web/utils/reply-tracker/inbound.ts, apps/web/utils/reply-tracker/outbound.ts
Database Schema
The core data structure for this feature is the ThreadTracker table in the database.
This diagram shows the ThreadTracker entity and its relationship with the EmailAccount.
Sources: apps/web/utils/actions/reply-tracking.ts:48-55, apps/web/utils/reply-tracker/inbound.ts:68-76, apps/web/utils/reply-tracker/outbound.ts:58-66
Key Components
| Component | Description | Source File |
|---|---|---|
| Inbound Processor | Analyzes incoming emails. If an email matches the "To Reply" AI rule, it creates a ThreadTracker record with type NEEDS_REPLY. It also resolves AWAITING trackers when a reply is received. | apps/web/utils/reply-tracker/inbound.ts |
| Outbound Processor | Analyzes sent emails. When a user replies to a NEEDS_REPLY thread, it resolves that tracker and creates a new AWAITING tracker. | apps/web/utils/reply-tracker/outbound.ts |
| Previous Email Scanner | A process that can be triggered to scan previously sent emails to identify and create AWAITING trackers for conversations that need a follow-up. | apps/web/utils/reply-tracker/outbound.ts |
| Reply Zero UI | A Next.js page that displays tracked emails in "Needs Reply" and "Awaiting Reply" tabs. Allows users to manually resolve trackers. | apps/web/app/(app)/[emailAccountId]/reply-zero/page.tsx |
| API Endpoint | A RESTful API endpoint (/api/v1/reply-tracker) for external services to query tracked emails. | apps/web/app/api/v1/reply-tracker/route.ts |
| Server Actions | A set of Next.js server actions for enabling the feature, resolving threads, and processing historical emails. | apps/web/utils/actions/reply-tracking.ts |
Data Flow
The feature operates through two primary flows: processing inbound emails and processing outbound emails.
Overall Processing Flow
This diagram illustrates how inbound and outbound emails are processed to manage the state of ThreadTracker entries.
Enabling Reply Zero
Users can enable Reply Zero, which triggers a server action to set up the necessary rules and can optionally process past emails.
User Interface
The main user interface for Reply Zero is located at /[emailAccountId]/reply-zero. It consists of two tabs: "Needs Reply" and "Awaiting Reply".
- Data Fetching: The page uses
getPaginatedThreadTrackersto fetch tracked threads from the database for the selected tab. - User Actions: Users can manually mark a thread as resolved using a button, which triggers the
resolveThreadTrackerActionserver action. This updates theresolvedflag on the correspondingThreadTrackerrecord in the database.
Sources: apps/web/app/(app)/[emailAccountId]/reply-zero/page.tsx
API Endpoint
The feature exposes a versioned API endpoint for external integrations, such as the Model Context Protocol (MCP) server.
Endpoint: GET /api/v1/reply-tracker
This endpoint retrieves a list of emails that are being tracked by Reply Zero.
Query Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
type | needs-reply | needs-follow-up | Specifies which type of tracked emails to retrieve. | Yes |
email | string | The user's email address. | Yes |
timeRange | 3d | 1w | 2w | 1m | The time range to look back for tracked emails. | No |
page | number | The page number for pagination. | No |
Response Body
The endpoint returns a JSON object with a list of emails and the total count.
// From apps/web/app/api/v1/reply-tracker/route.ts:50-62
type ReplyTrackerResponse = {
emails: Array<{
threadId: string;
subject: string;
from: string;
date: string;
snippet: string;
}>;
count: number;
};
External Usage (MCP Server)
The MCP server uses this API to provide tools for fetching emails that need a reply or follow-up.
Server Actions
Several server actions manage the state and setup of the Reply Zero feature. These are defined in apps/web/utils/actions/reply-tracking.ts.
| Action | Description |
|---|---|
enableReplyTrackerAction | Enables the Reply Zero feature for the user by creating the necessary AI rules. |
processPreviousSentEmailsAction | Initiates a background job to scan the user's previously sent emails and create AWAITING trackers for them. |
resolveThreadTrackerAction | Marks a specific ThreadTracker as resolved or unresolved based on user interaction in the UI. |
Sources: apps/web/utils/actions/reply-tracking.ts:18-62
Reporting
Data from the Reply Zero feature is also used in other parts of the application, such as weekly summary emails. The SummaryEmail component can display counts for needsReplyCount and awaitingReplyCount, providing users with a snapshot of their follow-up status directly in their inbox.
Sources: packages/resend/emails/summary.tsx:18-21, packages/resend/emails/summary.tsx:142-152
Summary
The Reply Zero feature is a powerful tool for managing email follow-ups. By integrating with the AI assistant's rule engine and providing dedicated processing logic for inbound and outbound mail, it automates the tracking of important conversations. The feature is exposed through a clean user interface, a versioned API for external tools, and server actions for user-driven state changes, making it a well-integrated and essential part of the Inbox Zero application.