Failed GoCardless payments retried or chased by reason
When a Direct Debit fails, an AI agent reads why. Payments that can go through on a second try are retried in GoCardless, the rest get a customer email, and every case is logged.
The prompt
When a GoCardless payment fails, look up the payment and the customer, and have AI read the failure reason. If a second try is likely to work, like insufficient funds, and GoCardless isn't already retrying it, retry the payment. If the mandate or bank account no longer works, or the payer disputed it, email the customer from Gmail explaining why it failed and what to do. If GoCardless refuses the retry, email them too. Log every failed payment and what we did about it to a Google Sheet.
FlowRunner Prompt to Flow built this flow from that request. Here it is as it opens in the editor.
The flow
Download the file, then in FlowRunner click + beside Flows, pick it under Import a Flow Version and click Create. How importing works
What each step does
- Payment failed Checks GoCardless every 5 minutes for payments that failed.
- Get the customer Reads the payment, its mandate and the customer behind it, so the flow has the amount, what it was for, and who to write to.
- Read the failure reason An AI agent reads the failure cause and the bank's reason code. It decides whether a second attempt is likely to work and writes a short email to the customer.
- Worth retrying? Funds problems go to a retry. A cancelled mandate, a closed account, a disputed charge or a payment GoCardless will retry on its own goes to the customer email.
- Retry the payment Asks GoCardless to collect the payment again on the earliest date. If GoCardless refuses the retry, the customer gets the email instead.
- Email the customer Sends the customer the AI-written email from Gmail: the amount, why it did not go through, and what to do next.
- Log the customer notice Adds a row to your Google Sheet with the date, payment, customer, amount, failure cause, the agent's reasoning and the outcome. Retried payments are logged the same way.
Before you turn it on
- Enter the Client ID and Client Secret of your GoCardless partner app, then connect your GoCardless, Gmail and Google Sheets accounts.
- Add your Anthropic key in the flow setting Anthropic key.
- Pick your log spreadsheet and sheet in the two Google Sheets steps. Give it the columns Date, Payment, Customer, Email, Amount, Failure, Decision and Outcome.