Examples / Failed payment follow-up

Failed payment follow-up

When Stripe reports a failed invoice payment, Murmurator looks up the customer's subscriptions, your model judges how much revenue is at risk and what to do next, and billing gets a note in Slack. Big accounts go straight to customer success by email.

StripeYour AI modelsSlackEmail

What you tell the assistant

When a Stripe invoice payment fails in live mode, look up the customer's subscriptions, tell #billing in Slack what's at risk and what to do next, and email success@northwind.example when it's a big account.

Why it works

  • The trigger only fires on live-mode payment failures, and each delivery's Stripe signature is checked before anything runs.
  • list_subscriptions returns a trimmed view of the customer's plans, so the model reads what matters, not Stripe's full objects.
  • Only high-risk failures reach customer success, and the email connection can only ever write to your own domain.
Build this workflow

What it builds

Trigger
Stripe
tool
Look up subscriptions
stripe.list_subscriptions
llm
Judge the risk
smart · structured
tool
Tell #billing
slack.post_message
tool
Email customer success
email.send_email
if assess.output.data.risk equals high
View the definition
trigger:
  kind: stripe
  connection: stripe
  events: [invoice.payment_failed]
  livemode: [true]
steps:
  - key: subscriptions
    name: Look up subscriptions
    kind: tool
    tool: stripe.list_subscriptions
    args:
      customer: "{{ trigger.data.object.customer }}"
  - key: assess
    name: Judge the risk
    kind: llm
    model: smart
    system: You help the billing team of a B2B software company decide how to follow up on failed payments. Be brief and concrete.
    prompt: |
      A payment just failed.
      Customer: {{ trigger.data.object.customer_name }} ({{ trigger.data.object.customer_email }})
      Amount due: {{ trigger.data.object.amount_due }} in the smallest unit of {{ trigger.data.object.currency }}
      Attempt: {{ trigger.data.object.attempt_count }}
      Subscriptions: {{ steps.subscriptions.output }}
      High risk means an annual plan, more than $2,000 at stake, or a third failed attempt.
    schema:
      type: object
      properties:
        risk: { type: string, enum: [high, medium, low] }
        summary: { type: string }
        next_step: { type: string }
      required: [risk, summary, next_step]
  - key: notify
    name: "Tell #billing"
    kind: tool
    tool: slack.post_message
    args:
      channel: C04BILLING
      text: ":credit_card: Payment failed ({{ steps.assess.output.data.risk }} risk): {{ steps.assess.output.data.summary }}\nNext: {{ steps.assess.output.data.next_step }}\n{{ trigger.data.object.hosted_invoice_url }}"
  - key: escalate
    name: Email customer success
    kind: tool
    if: { path: steps.assess.output.data.risk, equals: high }
    tool: email.send_email
    args:
      to: success@northwind.example
      subject: "At risk: {{ trigger.data.object.customer_name }}'s payment failed"
      text: "{{ steps.assess.output.data.summary }}\n\nSuggested next step: {{ steps.assess.output.data.next_step }}\n\nInvoice: {{ trigger.data.object.hosted_invoice_url }}"

A sample run

What each step produces

Look up subscriptions tool

succeeded
Calling stripe.list_subscriptions
[
  {
    "id": "sub_1PqR7sLkdIwHu7ixM2cN8vYt",
    "status": "past_due",
    "current_period_end": 1790380800,
    "cancel_at_period_end": false,
    "items": [
      {
        "price": "price_1NwAnnualScale",
        "product": "prod_NwScale",
        "quantity": 12
      }
    ]
  }
]

Judge the risk llm

succeeded
Using model smart (Claude Sonnet 5, Murmurator AI)
{
  "text": "",
  "data": {
    "risk": "high",
    "summary": "Kestrel Health's annual Scale renewal ($11,880 for 12 seats) failed on the second attempt, and the subscription is now past due.",
    "next_step": "Have their account manager call accounts payable today and send the invoice link; Stripe retries again in three days."
  }
}

Tell #billing tool

succeeded
Calling slack.post_message
{
  "channel": "C04BILLING",
  "ts": "1758716410.000200"
}

Email customer success tool

succeeded
Calling email.send_email
{
  "id": "4f9c2b7e-6a1d-4e3b-9c8f-2d5e7a1b0c63",
  "to": [
    "success@northwind.example"
  ]
}

Trigger payload

{
  "id": "evt_1S8kQ2LkdIwHu7ixV3mJpA9c",
  "type": "invoice.payment_failed",
  "event": "invoice.payment_failed",
  "livemode": true,
  "data": {
    "object": {
      "id": "in_1S8kPzLkdIwHu7ixb4QeR2Ld",
      "customer": "cus_Qm4JtX8wVb2nRk",
      "customer_name": "Kestrel Health",
      "customer_email": "ap@kestrelhealth.example",
      "amount_due": 1188000,
      "currency": "usd",
      "attempt_count": 2,
      "billing_reason": "subscription_cycle",
      "hosted_invoice_url": "https://invoice.stripe.com/i/acct_1Nw/test_YWNjdF8xTnc"
    }
  }
}

Your next automation is one sentence away.

14-day free trial with $5 of built-in AI included. Cancel anytime.