Invoice from email → ledger sheet
An invoice arrives by email; the vendor, invoice number, amount, and due date are extracted and — after your approval — written as a row in the payables sheet, so every bill that lands is on the ledger the day it arrives.
- messageId
- msg_404
- threadId
- thr_404
- from
- billing@supplier.example.com
- to
- ["ap@company.example.com"]
- subject
- Invoice 2214 — November services
- snippet
- Invoice 2214 for $1,240.00, due December 1.
- receivedAt
- 2026-11-09T19:00:00Z
- labelIds
- ["INBOX"]
- hasAttachments
- true
Sample result: Invoice logged: 2214.
What each step does
Step 1 · Pull out the details
An AI step does this part. Today it runs on a simulated stand-in, labelled simulated on every run, until a real model is wired. This step reads text that arrived from outside — an email, a document, a form. Treat its output as a draft from untrusted input: that is why a person checks what it produces before anything leaves.
Step 2 · A person decides
The run stops and asks the person named in your settings. The decision window is 72 hours; if it lapses, the run carries on without a decision, and the lapse is on the record. Rejecting always takes a comment.
Step 3 · Write it back
The outcome is posted back through the connection you name. The secret stays sealed; the step carries the name only.
Step 4 · Send it onward
Step 5 · The result
This is what the run hands back, written into the run's record where you can read it.
What you'll fill in
These are the only things the template asks of you. Examples teach the shape — they are never values your flow runs on; what you type (or the stated starting value) is what gets used.
| Field | What to put in it | Example |
|---|---|---|
| Payables sheet | The connection, by name, that can append rows to the payables sheet. | A connection you name — never a key pasted here |
| Who approves | The role or person the approval card is addressed to. | Office manager |
Set it up
- Fill in the fields below.
- Name the connections it needs — by name only.
- Look at the trigger preview: what would start a run, counted before anything is armed.
- Review the steps, the rules, and every place a person is asked.
- Create it — then run it once yourself, and read the run's record.
Use this template
The definition
The whole mechanism, before you take it. Package checksums: sha256:73e21a11479a… · sha256:a6e24b225431… · sha256:273d514eec79…. A flow made from this template carries this template's name and version in its record, and exports in the standard bundle with that provenance.
Advanced · the three files, as written
{
"trigger.json": {
"template": {
"slug": "invoice-from-email-to-ledger-sheet",
"version": 1,
"name": "Invoice from email → ledger sheet",
"category": "money-expenses",
"outcome": "An invoice arrives by email; the vendor, invoice number, amount, and due date are extracted and — after your approval — written as a row in the payables sheet, so every bill that lands is on the ledger the day it arrives.",
"outputName": "Invoice logging result",
"fits_when": [
"supplier_invoices"
],
"needs": [
"connection:sheet"
]
},
"trigger": {
"type": "email.message.received",
"source": "gmail",
"manifestFields": {
"messageId": "string!",
"threadId": "string!",
"from": "string!",
"to": "string[]!",
"subject": "string",
"snippet": "string",
"receivedAt": "iso!",
"labelIds": "string[]!",
"hasAttachments": "bool!"
}
},
"inputConvention": "envelope",
"variables": [
{
"name": "sheetConnection",
"kind": "connection",
"label": "Payables sheet",
"instruction": "The connection, by name, that can append rows to the payables sheet."
},
{
"name": "approverRole",
"kind": "string",
"label": "Who approves",
"instruction": "The role or person the approval card is addressed to.",
"example": "Office manager",
"default": "Approver"
}
],
"sample": {
"input": {
"messageId": "msg_404",
"threadId": "thr_404",
"from": "billing@supplier.example.com",
"to": [
"ap@company.example.com"
],
"subject": "Invoice 2214 — November services",
"snippet": "Invoice 2214 for $1,240.00, due December 1.",
"receivedAt": "2026-11-09T19:00:00Z",
"labelIds": [
"INBOX"
],
"hasAttachments": true
},
"output": "Invoice logged: 2214."
}
},
"flow.json": {
"name": "Invoice from email → ledger sheet",
"inputConvention": "envelope",
"clefIn": [
{
"ruleset": "invoice-ledger-guard",
"ids": [
"sender-present",
"attachment-flag"
]
}
],
"steps": [
{
"type": "ai",
"task": "extract",
"untrustedInput": true,
"text": {
"segments": [
{
"text": "Extract the vendor, invoice number, amount in cents, currency, and due date from this invoice email. Subject: "
},
{
"field": {
"source": "trigger",
"name": "subject",
"label": "Message · Subject"
}
},
{
"text": ". Message: "
},
{
"field": {
"source": "trigger",
"name": "snippet",
"label": "Message · Snippet"
}
}
]
}
},
{
"type": "human",
"kind": "approval",
"due": 259200,
"onExpire": "continue",
"prompt": {
"segments": [
{
"text": "Log this invoice? "
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"vendor"
],
"label": "Invoice · Vendor"
}
},
{
"text": " #"
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"invoiceNumber"
],
"label": "Invoice · Number"
}
},
{
"text": " — "
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"amountCents"
],
"label": "Invoice · Amount (cents)"
}
},
{
"text": ", due "
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"dueDate"
],
"label": "Invoice · Due date"
}
}
]
}
},
{
"type": "http",
"method": "POST",
"connectionFromVariable": "sheetConnection",
"url": "https://sheets.example.com/rows",
"body": {
"segments": [
{
"text": "{\"vendor\": \""
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"vendor"
],
"label": "Invoice · Vendor"
}
},
{
"text": "\", \"invoiceNumber\": \""
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"invoiceNumber"
],
"label": "Invoice · Number"
}
},
{
"text": "\", \"amountCents\": "
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"amountCents"
],
"label": "Invoice · Amount (cents)"
}
},
{
"text": ", \"dueDate\": \""
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"dueDate"
],
"label": "Invoice · Due date"
}
},
{
"text": "\", \"sourceMessage\": \""
},
{
"field": {
"source": "trigger",
"name": "messageId",
"label": "Message · ID"
}
},
{
"text": "\"}"
}
]
}
},
{
"type": "dispatch",
"channel": "event",
"name": "finance.invoice.logged"
},
{
"type": "output",
"value": {
"segments": [
{
"text": "Invoice logged: "
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"invoiceNumber"
],
"label": "Invoice · Number"
}
},
{
"text": "."
}
]
}
}
]
},
"rules.json": {
"rulesets": [
{
"name": "invoice-ledger-guard",
"version": 1,
"rules": [
{
"id": "sender-present",
"on": "step.payload.from",
"op": "missing",
"action": "block",
"msg": "An invoice with no sender cannot be vouched for or logged."
},
{
"id": "attachment-flag",
"on": "step.payload.hasAttachments",
"op": "ne",
"action": "flag",
"msg": "The email carries no attachment; the figures come from the body alone.",
"value": true
}
]
}
],
"permissions": {
"approvals": {
"approveBeforeSteps": [
1
],
"rejectRequiresComment": true,
"dueSeconds": 259200,
"onExpire": "continue"
},
"connections": {
"required": [
{
"nameFromVariable": "sheetConnection",
"usedBySteps": [
2
]
}
],
"optional": []
}
}
}
}