Payment failed — save-the-subscription draft
When a payment fails, a save-the-subscription message and an internal note are drafted for you. A person approves before anything is sent.
- invoiceId
- in_sample
- subscriptionId
- sub_sample
- amountDue
- 2800
- currency
- usd
- customerId
- cus_sample
- attemptCount
- 1
- stripeEventId
- evt_sample
Sample result: Draft written in a helpful tone (first failed attempt). Internal note attached. Awaiting approval — nothing sent.
What each step does
Step 1 · Draft it
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.
Step 2 · Shape the note
The wording of the note is shaped from the fields picked below.
Step 3 · 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 4 · 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 |
|---|---|---|
| Who approves the draft | The role or person who approves before anything is sent. | Support lead |
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:f3a4efc6f2e6… · sha256:210485940fc5… · sha256:2bc0bb452076…. 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": "payment-failed-save-the-subscription-draft",
"version": 1,
"name": "Payment failed — save-the-subscription draft",
"category": "money-expenses",
"outcome": "When a payment fails, a save-the-subscription message and an internal note are drafted for you. A person approves before anything is sent.",
"outputName": "Draft for approval",
"fits_when": [
"online_payments"
],
"needs": []
},
"trigger": {
"type": "stripe.invoice.payment_failed",
"source": "stripe",
"manifestFields": {
"invoiceId": "string!",
"subscriptionId": "string",
"amountDue": "int",
"currency": "string",
"customerId": "string",
"attemptCount": "int",
"stripeEventId": "string!"
}
},
"inputConvention": "envelope",
"variables": [
{
"name": "approverRole",
"kind": "string",
"label": "Who approves the draft",
"instruction": "The role or person who approves before anything is sent.",
"example": "Support lead",
"default": "Approver"
}
],
"sample": {
"input": {
"invoiceId": "in_sample",
"subscriptionId": "sub_sample",
"amountDue": 2800,
"currency": "usd",
"customerId": "cus_sample",
"attemptCount": 1,
"stripeEventId": "evt_sample"
},
"output": "Draft written in a helpful tone (first failed attempt). Internal note attached. Awaiting approval — nothing sent."
}
},
"flow.json": {
"name": "Payment failed — save-the-subscription draft",
"inputConvention": "envelope",
"steps": [
{
"type": "ai",
"task": "draft",
"text": {
"segments": [
{
"text": "A payment failed. Invoice "
},
{
"field": {
"source": "trigger",
"name": "invoiceId",
"label": "Invoice · ID"
}
},
{
"text": ", attempt "
},
{
"field": {
"source": "trigger",
"name": "attemptCount",
"label": "Invoice · Attempt"
}
},
{
"text": ". Draft a kind, clear save-the-subscription message."
}
]
}
},
{
"type": "transform",
"template": {
"segments": [
{
"text": "Internal note: payment failed for invoice "
},
{
"field": {
"source": "trigger",
"name": "invoiceId",
"label": "Invoice · ID"
}
},
{
"text": " — draft awaiting approval, nothing sent."
}
]
}
},
{
"type": "human",
"kind": "approval",
"prompt": {
"segments": [
{
"text": "Approve this save-the-subscription draft? "
},
{
"field": {
"source": "step",
"stepIndex": 0,
"path": [
"draft"
],
"label": "Draft · Text"
}
}
]
},
"due": 259200,
"onExpire": "continue"
},
{
"type": "output",
"value": "Draft for approval — nothing was sent."
}
]
},
"rules.json": {
"rulesets": [
{
"name": "payment-failure-intake",
"version": 1,
"rules": [
{
"id": "failure-has-invoice",
"on": "step.payload.invoiceId",
"op": "missing",
"action": "block",
"msg": "A payment-failure event without an invoice id cannot be drafted against."
}
]
}
],
"permissions": {
"approvals": {
"approveBeforeSteps": [
2
],
"rejectRequiresComment": true,
"dueSeconds": 259200,
"onExpire": "continue"
},
"connections": {
"required": [],
"optional": []
}
}
}
}