Browse the docs

Agent setup guide

Razorpay Failed Payment Recovery

When a Razorpay payment fails, a kind email with a new payment link for the same amount is sent from Gmail once you approve.

Available About 8 min to set up

What it does

When a Razorpay payment fails, a kind email with a new payment link for the same amount is sent from Gmail once you approve.

  • Starts when a Razorpay payment attempt fails.
  • AI writes a kind email explaining the failure in plain words; a second AI step checks the wording and quotes anything it blocks.
  • A person approves every email in Reviews; nothing is created or sent before that.
  • Code checks the recipient, the amount and leftover placeholders.
  • Creates a new Razorpay payment link for the same amount (unique per failed payment) and sends it from Gmail.

What it needs

  • A paid plan (agents run live on paid plans).
  • An AI provider key (Settings → AI Providers).
  • Razorpay: a Key Id and Key Secret generated in Live mode (an activated Razorpay account; India-focused).
  • Gmail, connected in Settings → Integrations.

What it doesn't do

  • The AI never writes or changes an amount, and it never offers discounts that aren't in your rules.
  • Payments without a customer email are held, not texted.
  • It doesn't retry the charge itself: the customer pays through the new link.

Availability and plans

Available

Its workflow is built and tested, and every app it needs is live. You can get it and set it up now.

Included free on the Enterprise plan; on other paid plans it's a one-time purchase per workspace (the price is on the Agents page). The Agents page in the app always shows its current status.

Before you start

  • A paid plan: agents run live, and the Free plan only runs Dry Runs.
  • An AI provider key (OpenAI, Anthropic, Google and more) in Settings → AI Providers. AI usage is billed by your provider.
  • These apps, connected in Settings → Integrations: Razorpay and Gmail.
  • The app it watches, connected in Settings → Integrations (the agent starts from an app event).
  • About 8 minutes.

Set it up step by step

Get the agent first (buy it, or it's already yours when your plan includes it), then in Agents → My agents press “Set up this agent”. That creates the agent's workflow in your workspace (it counts towards your plan's workflow limit) and opens the canvas with a setup checklist above it. Each item links to the exact place to go and ticks itself off when it's done.

1. Connect your AI provider

The AI steps run on your own key (OpenAI, Anthropic, Google and more). Add one in Settings → AI Providers.

2. Connect Razorpay

Connect Razorpay with your Live Key Id and Key Secret (Settings → Integrations → Razorpay).

3. Connect Gmail

Connect the Gmail account the email is sent from.

4. Pick your Razorpay account

Open the trigger and pick your Razorpay connection.

SettingWhat to enterIn step
Razorpay account (failed payments)The Razorpay connection whose failed payments start the agent. Pick your connected Razorpay account.“Payment failed”

5. Write your email rules

Open “Write the recovery email” and replace the placeholder.

SettingWhat to enterIn step
Your email rulesReplace the placeholder with your business name, tone, sign-off and what to say when a payment fails. It starts as “[YOUR BUSINESS NAME, YOUR TONE, YOUR SIGN-OFF, AND WHAT TO SAY WHEN A PAYMENT FAILS (E.G. TRY ANOTHER CARD OR UPI; HOW TO REACH YOU). NO DISCOUNTS UNLESS YOU OFFER THEM]” until you replace it.“Write the recovery email”

6. Pick Razorpay and Gmail

Open “Create a new payment link” and “Send it from Gmail” and pick your accounts.

SettingWhat to enterIn step
Razorpay account (payment link)The same Razorpay connection. Pick your connected Razorpay account.“Create a new payment link”
Gmail accountThe Gmail account the email is sent from. Pick your connected Gmail account.“Send it from Gmail”

7. Test it with Dry Run

Press Dry Run: the agent runs on sample data with no messages sent and nothing written to your apps.

8. Switch the trigger on

Open the trigger and click “Activate app trigger”: payments that fail from now on start the agent.

How it works

The agent is a normal workflow with 11 steps (2 AI steps, with a person approving in Reviews). You can open, edit and monitor it like any other workflow.

  • Payment failed — Starts on “Payment failed” in Razorpay (an app event). Starts when a Razorpay payment attempt fails. Razorpay is checked every few minutes.
  • Write the recovery email — AI step (runs on your AI provider key). AI writes a kind, short email explaining in plain words that the payment didn't go through and inviting the customer to try again. The amount and a new link are added by code.
  • Final wording check — AI step (runs on your AI provider key). A second AI step checks only the wording against clear rules (no blame, no invented offers or deadlines) and quotes any sentence it blocks.
  • Approve the recovery email — A person approves or rejects it in Reviews (the run waits). A person reads the email (and the wording check's verdict) in Reviews, edits it if needed and approves. No link is created and nothing is sent before this approval.
  • Not approved — Kept in the run history. Branch: Rejected. Rejected: nothing was created or sent.
  • Check before sending — Step. Branch: Approved. In code, after approval: one valid recipient, the failed payment's amount is a number, no placeholders left, and the wording check didn't block it.
  • Send it? — Decision: picks the branch to follow. Emails that pass get a new link and are sent; the rest are held with the reason.
  • Held — Kept in the run history. Branch: Held. The email failed a check (recipient, amount, placeholders or the wording check); nothing was created or sent. The reason is in the run history.
  • Create a new payment link — Razorpay: Create a payment link. Branch: Passes. Creates a Razorpay payment link for the failed payment's amount (copied by code, in paise), with the payment id as its unique reference so a retried run can't create two.
  • Send it from Gmail — Gmail: Send an email. Sends the approved email from your Gmail with the new payment link added by code.
  • Sent — Kept in the run history. The run history keeps the failed payment, the email and the new link.

Test it with Dry Run

Press Dry Run in the canvas. The agent runs on the sample data stored on its trigger (the “Sample data for Dry Run” box), so you can check every step's output before anything is live. The sample has the same shape as a real event from the app.

Sample data fields

id, status, amount, currency, method, order_id, email, contact, description, error_code, error_description, error_reason, created_at, payment.

  • Nothing is sent or written: app actions, emails and Slack posts are simulated, and AI steps don't call your AI provider.
  • Approval steps use the Dry Run decision you pick in the step's settings (approved, rejected or timeout), so you can try each branch.

Go live

  • Open the trigger and click “Activate app trigger”: payments that fail from now on start the agent.
  • Activating the app trigger needs the trigger's connected account. The first check only remembers what's already there, so older items don't start runs; the same item never starts two runs.
  • The setup checklist adds a “paid plan” item before activation: live runs need a paid plan (the Free plan only runs Dry Runs).
  • When every checklist item is done and the trigger is on, the checklist says “Live — this agent is running”. Follow its runs in the workflow's History tab and in Analytics → Agents.

Questions

Can the AI change the amount?

No. The new link is for the failed payment's amount, copied by code; the AI never writes an amount.

Can a customer get two links for one failure?

No. The failed payment's id is the link's unique reference, and Razorpay refuses a second link with the same reference.

Is the email sent automatically?

No. Every email waits for your approval in Reviews.

Troubleshooting

  • “No AI provider connected” or a rejected key: connect or fix the key in Settings → AI Providers, then press Test there.
  • A checklist item stays unticked: the setting is still empty or still contains its placeholder text. Open the step from the checklist and fill it in.
  • An app step fails with “Needs reconnect”: the account's access was revoked or expired. Reconnect it in Settings → Integrations.
  • No runs start: activate the app trigger with a connected account. Only items created after activation start runs.
  • A run shows as paused: it's waiting for someone in Reviews to approve or reject it.
  • A step failed: open the run in History and check that step in the Trace tab for the error and what it received.

Generated from the agent's own workflow, so it always matches what the agent does. Last updated .