# LeadFlow OS - Local Business Intelligence Automation Kit (`huntersreeni/leadflow-os`) Actor

Turn Google Maps-style local business records into clean, scored, CRM-ready leads with n8n templates and MCP-agent-ready schemas.

- **URL**: https://apify.com/huntersreeni/leadflow-os.md
- **Developed by:** [Sreenivasan S](https://apify.com/huntersreeni) (community)
- **Categories:** Developer tools, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## LeadFlow OS

Local Business Intelligence Automation Kit for Apify, n8n, and MCP-agent workflows.

### What it does

LeadFlow OS turns local-business records into a workflow-ready lead pipeline:

```text
Google Maps-style business records
-> clean and normalize
-> remove duplicates
-> score each lead
-> split outputs into useful datasets
-> send A/B leads to n8n, Sheets, CRM, Telegram, or an AI agent through Apify MCP
````

This Actor is intentionally not another raw scraper. The product gap is the layer after scraping: the cleaning, scoring, routing, reporting, and automation that makes scraped data useful.

### Why this exists

The elephant in the room is Google Maps/local-business scraping demand. Huge existing Actors already collect raw places data. LeadFlow OS does not fight that elephant. It sells the elephant a dashboard.

Use any Google Maps-style export, paste the records here, and get CRM/n8n/MCP-ready rows back.

### MCP-ready positioning

Apify's hosted MCP server at `https://mcp.apify.com` can expose Actors as tools to AI clients. LeadFlow OS is prepared for that flow with:

- a clear input schema for business records and filters
- an output schema that points agents to the default dataset and run summary
- explainable lead scores and reason codes
- a `mcpAgentHint` field reminding agents to ask before writing to CRM or contacting businesses

Example agent flow:

```text
AI agent receives: "Find the best elephant-themed product shops from this Apify dataset."
-> calls LeadFlow OS through Apify MCP
-> receives scored rows
-> summarizes A-grade leads
-> asks before pushing anything to a CRM or outreach system
```

### MVP scope

v0.1.1 is post-processing mode. It accepts already-collected business records and turns them into clean, scored, workflow-ready output.

Included now:

- record normalization
- website/domain normalization
- deduplication by domain or name/address
- explainable lead scoring
- filters for rating, reviews, and required website
- multiple named datasets
- n8n template for high-score leads to Google Sheets plus Telegram
- output schema for better Apify Console/API/MCP discovery

Not included yet:

- built-in Google Maps crawling
- contact-page/email enrichment
- review summarization
- direct CRM writes

Those are v0.2+ candidates.

### Example input

```json
{
  "businesses": [
    {
      "name": "Elephant & Co. Toy Store",
      "address": "Kochi, Kerala",
      "phone": "+91 99999 99999",
      "website": "elephant-toys.example",
      "rating": 4.7,
      "reviewCount": 183,
      "category": "Toy store"
    },
    {
      "name": "Product Nest Gifts",
      "address": "Kochi, Kerala",
      "rating": 3.6,
      "reviewCount": 42,
      "category": "Gift shop"
    }
  ],
  "leadScoringProfile": "local_services",
  "outputMode": "mcp_agent_ready"
}
```

### Main output fields

| Field | Meaning |
|---|---|
| `name` | Business name |
| `category` | Business category |
| `address` | Address/location text |
| `phone` | Phone number if present |
| `website` | Normalized website URL |
| `domain` | Website domain for dedupe/routing |
| `rating` | Numeric rating |
| `reviewCount` | Number of reviews |
| `leadScore` | 0-100 score |
| `leadGrade` | A/B/C/D grade |
| `scoreReasons` | Explainable reason codes |
| `workflowStatus` | `dataset_only`, `n8n_ready`, `crm_ready`, or `mcp_agent_ready` |
| `suggestedNextAction` | Recommended workflow action |
| `mcpAgentHint` | Agent safety hint in MCP-agent mode |

### Output datasets

| Dataset alias | Purpose |
|---|---|
| `default` | Outreach-ready records for CRM/n8n/MCP agents |
| `businesses_clean` | Normalized business records |
| `lead_scores` | Score, grade, and reason codes |
| `failed_locations` | Skipped or invalid records |
| `duplicates` | Duplicate records |
| `audit_debug` | Run summary and non-sensitive diagnostics |

The Actor also stores `LEADFLOW_SUMMARY` in the default key-value store.

### Lead scoring v0.1.1

The scoring is simple and explainable:

- business name present
- phone present
- website present
- strong rating or low-rating opportunity
- review volume
- category present
- optional boosts for agency/local-services profiles

Grades:

- A: 75+
- B: 55-74
- C: 35-54
- D: below 35

### n8n template

Included template:

```text
templates/n8n/leadflow-os-google-sheets-telegram.json
```

Workflow shape:

```text
Manual/Cron trigger
-> Run LeadFlow OS Actor through Apify API
-> Read default dataset
-> Filter A/B leads
-> Append to Google Sheets
-> Send Telegram digest
```

### Pricing / Cost estimation

LeadFlow OS uses Apify's **pay-per-event** pricing model.

| Event | Price |
|---|---:|
| Actor Start | $0.00005 per run |
| Outreach-ready lead | $0.003 per lead ($3 per 1,000) |

Only records that pass filtering, deduplication, and scoring - and land in the `default` dataset - are billed as an "Outreach-ready lead." The run summary's `outreachReadyRecords` count is exactly the number of billable leads for that run, so what you see in the summary is what you pay for. Records skipped into `failed_locations` or `duplicates` are never billed.

### Permission and safety model

- Basic mode is dataset-only/post-processing. No workspace writes.
- MCP-agent mode returns structured lead intelligence, but does not contact businesses or write to CRM by itself.
- Advanced future connector modes should use least privilege and document any approval prompts clearly.

### Local development

```bash
npm install
npm run check
npm start
```

### Product note

LeadFlow OS is a productized automation layer around proven Apify demand. The sellable result is not "I scraped more rows." The sellable result is "your leads are cleaned, scored, routed, and ready for action."

# Actor input Schema

## `businesses` (type: `array`):

Business/place records to clean, score, dedupe, and prepare for workflow delivery. Works well with records exported from Google Maps/place scrapers.

## `searchQuery` (type: `string`):

Optional note for the source query, e.g. toy stores, dentists, restaurants, real estate agents.

## `location` (type: `string`):

Optional note for the source location, e.g. Kochi, Kerala.

## `maxResults` (type: `integer`):

Maximum input records to process in this run.

## `minimumRating` (type: `number`):

Optional rating filter. Records below this rating are skipped.

## `minimumReviews` (type: `integer`):

Optional review-count filter. Records below this count are skipped.

## `requireWebsite` (type: `boolean`):

Skip records without a website.

## `leadScoringProfile` (type: `string`):

Scoring profile used to calculate fit and actionability.

## `outputMode` (type: `string`):

Controls labels in the default dataset.

## Actor input object example

```json
{
  "businesses": [
    {
      "name": "Elephant & Co. Toy Store",
      "address": "Kochi, Kerala",
      "phone": "+91 99999 99999",
      "website": "elephant-toys.example",
      "rating": 4.7,
      "reviewCount": 183,
      "category": "Toy store",
      "sourceUrl": "https://maps.example/elephant-toys"
    },
    {
      "name": "Product Nest Gifts",
      "address": "Kochi, Kerala",
      "rating": 3.6,
      "reviewCount": 42,
      "category": "Gift shop"
    }
  ],
  "maxResults": 50,
  "requireWebsite": false,
  "leadScoringProfile": "generic",
  "outputMode": "mcp_agent_ready"
}
```

# Actor output Schema

## `outreachReadyLeads` (type: `string`):

Default dataset containing flattened leads for CRM, Sheets, n8n, and AI-agent workflows.

## `runSummary` (type: `string`):

Key-value-store JSON summary with received, clean, duplicate, skipped, and output counts.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "businesses": [
        {
            "name": "Elephant & Co. Toy Store",
            "address": "Kochi, Kerala",
            "phone": "+91 99999 99999",
            "website": "elephant-toys.example",
            "rating": 4.7,
            "reviewCount": 183,
            "category": "Toy store",
            "sourceUrl": "https://maps.example/elephant-toys"
        },
        {
            "name": "Product Nest Gifts",
            "address": "Kochi, Kerala",
            "rating": 3.6,
            "reviewCount": 42,
            "category": "Gift shop"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("huntersreeni/leadflow-os").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "businesses": [
        {
            "name": "Elephant & Co. Toy Store",
            "address": "Kochi, Kerala",
            "phone": "+91 99999 99999",
            "website": "elephant-toys.example",
            "rating": 4.7,
            "reviewCount": 183,
            "category": "Toy store",
            "sourceUrl": "https://maps.example/elephant-toys",
        },
        {
            "name": "Product Nest Gifts",
            "address": "Kochi, Kerala",
            "rating": 3.6,
            "reviewCount": 42,
            "category": "Gift shop",
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("huntersreeni/leadflow-os").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "businesses": [
    {
      "name": "Elephant & Co. Toy Store",
      "address": "Kochi, Kerala",
      "phone": "+91 99999 99999",
      "website": "elephant-toys.example",
      "rating": 4.7,
      "reviewCount": 183,
      "category": "Toy store",
      "sourceUrl": "https://maps.example/elephant-toys"
    },
    {
      "name": "Product Nest Gifts",
      "address": "Kochi, Kerala",
      "rating": 3.6,
      "reviewCount": 42,
      "category": "Gift shop"
    }
  ]
}' |
apify call huntersreeni/leadflow-os --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=huntersreeni/leadflow-os",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "LeadFlow OS - Local Business Intelligence Automation Kit",
        "description": "Turn Google Maps-style local business records into clean, scored, CRM-ready leads with n8n templates and MCP-agent-ready schemas.",
        "version": "0.1",
        "x-build-id": "xBRKHcFWPBLMT2M7k"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/huntersreeni~leadflow-os/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-huntersreeni-leadflow-os",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/huntersreeni~leadflow-os/runs": {
            "post": {
                "operationId": "runs-sync-huntersreeni-leadflow-os",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/huntersreeni~leadflow-os/run-sync": {
            "post": {
                "operationId": "run-sync-huntersreeni-leadflow-os",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "businesses"
                ],
                "properties": {
                    "businesses": {
                        "title": "Business records",
                        "type": "array",
                        "description": "Business/place records to clean, score, dedupe, and prepare for workflow delivery. Works well with records exported from Google Maps/place scrapers."
                    },
                    "searchQuery": {
                        "title": "Source search query",
                        "type": "string",
                        "description": "Optional note for the source query, e.g. toy stores, dentists, restaurants, real estate agents."
                    },
                    "location": {
                        "title": "Source location",
                        "type": "string",
                        "description": "Optional note for the source location, e.g. Kochi, Kerala."
                    },
                    "maxResults": {
                        "title": "Max records to process",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Maximum input records to process in this run.",
                        "default": 50
                    },
                    "minimumRating": {
                        "title": "Minimum rating",
                        "minimum": 0,
                        "maximum": 5,
                        "type": "number",
                        "description": "Optional rating filter. Records below this rating are skipped."
                    },
                    "minimumReviews": {
                        "title": "Minimum reviews",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Optional review-count filter. Records below this count are skipped."
                    },
                    "requireWebsite": {
                        "title": "Require website",
                        "type": "boolean",
                        "description": "Skip records without a website.",
                        "default": false
                    },
                    "leadScoringProfile": {
                        "title": "Lead scoring profile",
                        "enum": [
                            "generic",
                            "agency",
                            "local_services",
                            "custom"
                        ],
                        "type": "string",
                        "description": "Scoring profile used to calculate fit and actionability.",
                        "default": "generic"
                    },
                    "outputMode": {
                        "title": "Output mode",
                        "enum": [
                            "dataset_only",
                            "n8n_ready",
                            "crm_ready",
                            "mcp_agent_ready"
                        ],
                        "type": "string",
                        "description": "Controls labels in the default dataset.",
                        "default": "mcp_agent_ready"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
