Dillo Flows
Money & expenses, template v1

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.

Starts when: Email received. Produces: Invoice logging result. Steps: 5
Sample run — illustrative, not a record of a real run
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
1Pull out the details2A person decides3Write it back4Send it onward5The result

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.

Message · SubjectMessage · Snippet

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.

Invoice · VendorInvoice · NumberInvoice · Amount (cents)Invoice · Due date

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.

Invoice · VendorInvoice · NumberInvoice · Amount (cents)Invoice · Due dateMessage · ID

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.

Invoice · Number

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.

FieldWhat to put in itExample
Payables sheetThe connection, by name, that can append rows to the payables sheet.A connection you name — never a key pasted here
Who approvesThe role or person the approval card is addressed to.Office manager

Set it up

  1. Fill in the fields below.
  2. Name the connections it needs — by name only.
  3. Look at the trigger preview: what would start a run, counted before anything is armed.
  4. Review the steps, the rules, and every place a person is asked.
  5. Create it — then run it once yourself, and read the run's record.
Creating never arms the trigger. The flow is created switched off: no runs start for things that already match. Arming is a separate tap on the created flow, after you have seen the preview count.

Use this template

The connection, by name, that can append rows to the payables sheet.

Connections are named, sealed, and never shown again. Add one in the console's setup, then pick it here by name.

The role or person the approval card is addressed to.

Sign in to preview what this trigger would match in your space.

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": []
      }
    }
  }
}

All templates   See the system: Link Map