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

# Email Lead Flow 

<img src="https://mintcdn.com/devrel/mIs5bV2YHX7MUNHO/images/EmailLeadFlow.jpg?fit=max&auto=format&n=mIs5bV2YHX7MUNHO&q=85&s=aca1247b1b329da82b9446997799ecc0" alt="Email Lead Flow Jp" width="2400" height="1640" data-path="images/EmailLeadFlow.jpg" />

This automation flow extracts business or sales leads directly from a Gmail inbox, analyzes email content using an LLM (Language Model), categorizes and enriches the leads, and exports the structured data to a Google Sheet with performance tracking via an Analytics Dashboard.

## **Workflow Steps & Components**

### **1. Gmail Manager**

**Component**: Gmail Manager\
**Purpose**: Connects to Gmail and fetches emails from a specific label (e.g., “Inbound Leads”).\
**User Configurations:**

1. Gmail Credentials JSON
2. Target Label (e.g., Leads)
3. Max Emails to Fetch
4. Apply Label after Processing (e.g., Processed)
5. Optional: Extract Attachments

**Output**: Email subjects, senders, message bodies, and attachments (if any).

### **2. AI Lead Categorizer**

**Component**: AI Lead Categorizer\
**Purpose**: Uses an LLM to analyze email content and identify:

1. Lead type (Sales, Business Development, Partnership, etc.)
2. Key contact info (Name, Email, Company)
3. Message intent (Inquiry, Demo Request, Proposal, etc.)

**Inputs:**

1. Email body (from Gmail Manager)
2. Job/Industry context prompt

### **3.  Language Model (LLM Processor)**

**Componen**t: Language Model\
**Purpose**: Provides context-aware understanding to classify emails more precisely and extract meaningful fields.

**Connected To:**

1. AI Lead Categorizer for enrichment
2. Email Auto-Reply System for crafting response messages

### **4. Email Auto-Reply System**

**Component**: Email Auto-Reply System

**Purpose**: Automatically drafts personalized replies using extracted lead details and your preferred tone.

**Example Outputs:**

1. “Thank you for your interest in our services. Our business development team will reach out shortly.”
2. “Appreciate your inquiry. Here’s a link to schedule a meeting.”

**Inputs:**

1. Extracted lead details
2. LLM-generated message tone (formal/friendly)
3. Predefined templates

### **5**.**Google Sheets Integration**

**Component**: Google Sheets Writer

**Purpose:** Appends structured lead data into a centralized Google Sheet.

**Typical Columns:**\
\| Date | Name | Email | Company | Lead Type | Message Summary | Follow-up Status |

**Required Config:**

1. Spreadsheet ID
2. Target Sheet Name

### **6. Analytics Dashboard**

**Component**: Analytics Dashboard\
**Purpose**: Provides a visual summary of lead statistics, such as:

1. Number of leads processed
2. Lead sources (email domains)
3. Category breakdown (Partnerships, Sales, etc.)
4. Performance metrics (response rate, follow-up progress)

### **7. Final Output**

**Component**: Text Output\
**Purpose**: Displays a summary message in Playground view

**e.g., “10 new leads extracted and appended to Google Sheet successfully.”**

## **End-to-End Flow Summary**

| **Stage**       | **Action**                    | **Output**            |
| :-------------- | :---------------------------- | :-------------------- |
| **Gmail Fetch** | **Retrieve new lead emails**  | **Raw messages**      |
| **Categorize**  | **Use LLM to extract fields** | **Name, Email, Type** |
| **Reply**       | **Auto-generate response**    | **Draft email text**  |
| **Export**      | **Save to Google Sheets**     | **Structured data**   |
| **Analyze**     | **Dashboard metrics**         | **Lead performance**  |

## **Highlights**

1. Works automatically on labeled inboxes.
2. Uses LLMs for accurate intent and field extraction
3. Creates and sends contextually personalized replies.
4. Tracks processed leads in real-time via Google Sheets + Dashboard.
