Workflows / Stripe / invoice.upcoming

Stripe Invoice Upcoming Notification to Slack & Email

Use the Stripe integration by MagicBell to setup a workflow when invoice.upcoming triggers in Stripe.

Connect Stripe to MagicBell to receive events and trigger workflows. This guide uses the MagicBell CLI.

Add the Stripe integration

Save your Stripe webhook signing secret in MagicBell. See Stripe webhooks.

magicbell integration save_stripe \
  --data '{"webhook_signing_secret":"whsec_xxx"}'

Copy the ID from the response and use it to build your webhook URL:

https://api.magicbell.com/v2/integrations/stripe/webhooks/incoming/{id}

Setup the webhook

  • Setup a webhook in Stripe with the URL from the last step.
  • Select the invoice.upcoming event.
  • If you already have a webhook configured, make sure it includes this event.

Add a workflow

Create a workflow that triggers automatically when Stripe sends this event.

Workflow key

Use this key to trigger the workflow when Stripe sends a invoice.upcoming:

integration.stripe.invoice.upcoming

Example workflow

Give customers advance notice of an upcoming invoice so they can ensure their payment method is up to date.

{
  "key": "integration.stripe.invoice.upcoming",
  "steps": [
    {
      "command": "broadcast",
      "input": {
        "content": "Your next invoice for ${{payload.data.object.amount_due}} will be charged soon. Please ensure your payment method is up to date.",
        "recipients": [
          {
            "external_id": "{{payload.data.object.customer}}"
          }
        ],
        "title": "Upcoming invoice"
      }
    }
  ]
}

Save with the CLI

Use the MagicBell CLI to save this workflow to your project. You can also use the Workflows API endpoint instead.

magicbell workflow save \
  --data '{"key":"integration.stripe.invoice.upcoming","steps":[{"command":"broadcast","input":{"content":"Your next invoice for ${{payload.data.object.amount_due}} will be charged soon. Please ensure your payment method is up to date.","recipients":[{"external_id":"{{payload.data.object.customer}}"}],"title":"Upcoming invoice"}}]}'

Event payload

Sample payload for the invoice.upcoming event. Use liquid templates to access fields in your workflow.

{
  "api_version": "2023-10-16",
  "created": 1694109381,
  "data": {
    "object": {
      "amount_due": 1000,
      "billing_reason": "subscription_cycle",
      "collection_method": "charge_automatically",
      "created": 1694109381,
      "currency": "usd",
      "customer": "cus_Na6dX7aXxi11N4",
      "customer_email": "customer@example.com",
      "customer_name": "Jenny Rosen",
      "id": "in_1MowQVLkdIwHu7ixfRsqIVzt",
      "livemode": false,
      "next_payment_attempt": 1694195781,
      "object": "invoice",
      "period_end": 1684966567,
      "period_start": 1682288167,
      "status": "draft",
      "subscription": "sub_1MowQVLkdIwHu7ixeRlqHVzs"
    }
  },
  "id": "evt_1NqIfSLkdIwHu7ixPpZ2Ab5c",
  "livemode": false,
  "object": "event",
  "type": "invoice.upcoming"
}
View all Stripe workflows →