# Dairy Milk Collection & Quality Pricing

**Category:** Agriculture  
**Tools:** HTTP, Google Sheets, n8n  
**Nodes:** 17  
**Built by:** Forgent Systems

Records daily milk collection, calculates the rate from fat and SNF quality, blocks duplicate entries and sends a WhatsApp receipt. A daily summary report goes out automatically.

![Workflow](preview.webp)

## How it works

1. A form captures the farmer, quantity and quality readings.
2. Input is validated and checked against today's entries for duplicates.
3. Rate and amount are calculated from quality and the entry is saved.
4. The farmer gets a WhatsApp confirmation, or an alert if there's a problem.
5. Each day, totals are aggregated and a report is sent on WhatsApp.

## Use cases

- Milk collection centers
- Dairy cooperatives
- Private dairies

## Data setup

**Google Sheets** (tab: columns)

- **Milk Collection Sheet → Sheet1**: `Farmer Name`, `Collection Date`, `Session`, `Farmer ID`, `Mobile Number`, `Milk Quantity`, `Fat (%)`, `SNF (%)`, `Collection Center`, `Operator Name`, `Remarks`, `Quality`, `Rate`, `Amount`, `Created At`

## Setup

1. In n8n open **Workflows → Import from File** and choose `workflow.json`.
2. Connect these credentials:
   - Google Sheets account
   - Twilio account
3. Point the Sheets / Airtable / Drive / Slack nodes at your own resources (structure above).
4. Replace placeholder emails, phone numbers and `YOUR-FORM-ID` links with your own.
5. Times use the America/New_York timezone and dates use MM/DD/YYYY. Adjust if needed.
6. Run a test execution, then activate.

## Nodes

- **Milk Entry Form Trigger** — `n8n-nodes-base.formTrigger`
- **Validate Milk Input** — `n8n-nodes-base.if`
- **Check Duplicate Entry (Sheet)** — `n8n-nodes-base.googleSheets`
- **Is Duplicate Entry?** — `n8n-nodes-base.if`
- **Send Duplicate Alert Message** — `n8n-nodes-base.twilio`
- **Save Milk Entry** — `n8n-nodes-base.googleSheets`
- **Send Success Message** — `n8n-nodes-base.twilio`
- **Daily Scheduler** — `n8n-nodes-base.scheduleTrigger`
- **Aggregate Milk Data** — `n8n-nodes-base.code`
- **Generate Report Message** — `n8n-nodes-base.code`
- **Send WhatsApp Alert** — `n8n-nodes-base.twilio`
- **Sticky Note2** — `n8n-nodes-base.stickyNote`
- **Sticky Note** — `n8n-nodes-base.stickyNote`
- **Sticky Note1** — `n8n-nodes-base.stickyNote`
- **Send Invalid Input Alert** — `n8n-nodes-base.twilio`
- **Calculate Qty, Rate & Amount** — `n8n-nodes-base.code`
- **Fetch Today Milk Records** — `n8n-nodes-base.googleSheets`
