Invoice intake and coding suggestion
Each invoice email that arrives is read, its details are pulled out as named fields, and account codes are suggested. You check the draft before it becomes the invoice record.
- messageId
- msg-sample-1
- threadId
- thr-sample-1
- from
- billing@sample-vendor.example
- to
- ["you@example.com"]
- subject
- Invoice 1042
- snippet
- Invoice 1042 for services…
- receivedAt
- 2026-11-04T10:00:00Z
- labelIds
- ["INBOX"]
- hasAttachments
- true
Sample result: Invoice drafted: Sample Vendor, amount and due date pulled out, codes suggested. Approved by the checker. Invoice record drafted.
What each step does
Step 1 · Write it back
The outcome is posted back through the connection you name. The secret stays sealed; the step carries the name only.
Step 2 · 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 3 · Shape the note
The wording of the note is shaped from the fields picked below.
Step 4 · 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 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 |
|---|---|---|
| Mailbox to read from | The connection, by name, that can fetch the full message. | A connection you name — never a key pasted here |
| Who checks invoice drafts | The role or person who approves each drafted record. | Bookkeeper |
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:63f10434743d… · sha256:b0cd62a89ee8… · sha256:fb8ccaa284a1…. 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-intake-and-coding-suggestion",
"version": 1,
"name": "Invoice intake and coding suggestion",
"category": "money-expenses",
"outcome": "Each invoice email that arrives is read, its details are pulled out as named fields, and account codes are suggested. You check the draft before it becomes the invoice record.",
"outputName": "Invoice record drafted",
"fits_when": [
"supplier_invoices"
],
"needs": [
"connection:mail"
]
},
"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": "mailConnection",
"kind": "connection",
"label": "Mailbox to read from",
"instruction": "The connection, by name, that can fetch the full message."
},
{
"name": "approverRole",
"kind": "string",
"label": "Who checks invoice drafts",
"instruction": "The role or person who approves each drafted record.",
"example": "Bookkeeper",
"default": "Approver"
}
],
"sample": {
"input": {
"messageId": "msg-sample-1",
"threadId": "thr-sample-1",
"from": "billing@sample-vendor.example",
"to": [
"you@example.com"
],
"subject": "Invoice 1042",
"snippet": "Invoice 1042 for services…",
"receivedAt": "2026-11-04T10:00:00Z",
"labelIds": [
"INBOX"
],
"hasAttachments": true
},
"output": "Invoice drafted: Sample Vendor, amount and due date pulled out, codes suggested. Approved by the checker. Invoice record drafted."
}
},
"flow.json": {
"name": "Invoice intake and coding suggestion",
"inputConvention": "envelope",
"steps": [
{
"type": "http",
"method": "GET",
"connectionFromVariable": "mailConnection",
"url": {
"segments": [
{
"text": "https://example.com/messages/"
},
{
"field": {
"source": "trigger",
"name": "messageId",
"label": "Message · ID"
}
}
]
}
},
{
"type": "ai",
"task": "extract",
"untrustedInput": true,
"text": {
"segments": [
{
"text": "Invoice message: "
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"body"
],
"label": "Message fetch · Body"
}
}
]
}
},
{
"type": "transform",
"template": {
"segments": [
{
"text": "Invoice draft from "
},
{
"field": {
"source": "trigger",
"name": "from",
"label": "Message · From"
}
},
{
"text": " — check the pulled-out details and suggested codes."
}
]
}
},
{
"type": "human",
"kind": "approval",
"prompt": {
"segments": [
{
"text": "Check this invoice draft: "
},
{
"field": {
"source": "step",
"stepIndex": 2,
"path": [
"text"
],
"label": "Invoice draft · Note"
}
}
]
},
"due": 259200,
"onExpire": "continue"
},
{
"type": "output",
"value": {
"segments": [
{
"text": "Invoice record drafted for message "
},
{
"field": {
"source": "trigger",
"name": "messageId",
"label": "Message · ID"
}
}
]
}
}
]
},
"rules.json": {
"rulesets": [],
"permissions": {
"approvals": {
"approveBeforeSteps": [
3
],
"rejectRequiresComment": true,
"dueSeconds": 259200,
"onExpire": "continue"
},
"connections": {
"required": [
{
"nameFromVariable": "mailConnection",
"usedBySteps": [
0
]
}
],
"optional": []
}
}
}
}