Agent setup guide
Won Deal → Stripe Invoice
When a HubSpot deal is won, prepares the Stripe invoice for your approval, then creates, finalizes and sends it and notes it on the deal.
What it does
When a HubSpot deal is won, prepares the Stripe invoice for your approval, then creates, finalizes and sends it and notes it on the deal.
- Starts when a HubSpot deal reaches your Closed won stage.
- Reads the deal and its contacts; AI picks the billing contact by your rule and turns the deal into invoice lines (from the line items written in the deal description, or one line for the deal amount).
- The invoice total is recalculated in code before anyone sees it — never by the AI: the lines are added up and compared with the deal amount; anything the AI got wrong is corrected and flagged to the reviewer, and Stripe gets only the checked, approved lines.
- A person approves the invoice — contact, lines, currency, terms — and can edit any of it.
- Finds or creates the Stripe customer, creates the draft invoice and adds every line; only a complete invoice is finalized.
- Stripe emails the invoice with its payment page, and the invoice number, total and link are noted on the HubSpot deal.
What it needs
- A paid plan (agents run live on paid plans).
- An AI provider key (Settings → AI Providers).
- HubSpot and Stripe (a restricted key with write access to Customers, Invoices and Invoice Items), connected in Settings → Integrations. Stripe is waiting for approval, so this agent switches on once it's live.
- Deals with an amount, and line items written in the deal description if you want more than one line.
What it doesn't do
- One-off invoices only: no subscriptions, recurring billing, taxes or discounts.
- It doesn't read HubSpot product line items — only what's written on the deal.
- Nothing is created in Stripe before a person approves; it doesn't charge cards or chase payment.
- If Stripe refuses a line, the draft invoice is left unsent in Stripe for you to fix.
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: HubSpot and Stripe.
- The app it watches, connected in Settings → Integrations (the agent starts from an app event).
- About 20 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 HubSpot
Connect the HubSpot account your deals are in (Settings → Integrations → HubSpot).
3. Connect Stripe
Connect Stripe with a restricted key that can write Customers, Invoices and Invoice Items (Settings → Integrations → Stripe).
4. Pick your Closed won stage
Open the trigger and pick your HubSpot account, pipeline and Closed won stage.
| Setting | What to enter | In step |
|---|---|---|
| HubSpot account (won deals) | The HubSpot account whose won deals are invoiced. Pick your connected HubSpot account. | “Deal reached Closed won” |
| Deal pipeline | The pipeline your deals are in. | “Deal reached Closed won” |
| Closed won stage | The stage that means the deal is won (usually “Closed won”). | “Deal reached Closed won” |
5. Paste your invoicing rules
Open “Prepare the invoice” and replace the placeholder with your currency, payment terms, billing contact rule, line-item format and memo.
| Setting | What to enter | In step |
|---|---|---|
| Your invoicing rules | Replace the placeholder with your default currency, payment terms (days until due), who the billing contact is, how line items are written in the deal description, and the invoice memo. It starts as “[PASTE YOUR DEFAULT CURRENCY, PAYMENT TERMS (DAYS UNTIL DUE), WHO THE BILLING CONTACT IS ON A DEAL, HOW LINE ITEMS ARE WRITTEN IN THE DEAL DESCRIPTION AND THE INVOICE MEMO HERE]” until you replace it. | “Prepare the invoice” |
6. Pick your HubSpot account in each step
Open “Read the deal”, “Find the deal's contacts” and “Note it on the deal” and pick your HubSpot account.
| Setting | What to enter | In step |
|---|---|---|
| HubSpot account (deal) | The same HubSpot account, to read the deal. Pick your connected HubSpot account. | “Read the deal” |
| HubSpot account (contacts) | The same HubSpot account, to read the deal's contacts. Pick your connected HubSpot account. | “Find the deal's contacts” |
| HubSpot account (note) | The same HubSpot account, to log the invoice on the deal. Pick your connected HubSpot account. | “Note it on the deal” |
7. Pick your Stripe account in each step
Open each Stripe step (find and create customer, draft invoice, lines, finalize, send) and pick your Stripe account.
| Setting | What to enter | In step |
|---|---|---|
| Stripe account (find customer) | The Stripe account you invoice from. Pick your connected Stripe account. | “Find the Stripe customer” |
| Stripe account (create customer) | The same Stripe account. Pick your connected Stripe account. | “Create the Stripe customer” |
| Stripe account (draft invoice) | The same Stripe account. Pick your connected Stripe account. | “Create the draft invoice” |
| Stripe account (lines) | The same Stripe account. Pick your connected Stripe account. | “Add the line” |
| Stripe account (finalize) | The same Stripe account. Pick your connected Stripe account. | “Finalize the invoice” |
| Stripe account (send) | The same Stripe account. Pick your connected Stripe account. | “Email it from Stripe” |
8. Test it with Dry Run
Press Dry Run: the agent runs on sample data with no messages sent and nothing written to your apps.
9. Switch the trigger on
Open the trigger and click “Activate app trigger”: deals that reach the stage after activation are picked up on your plan's schedule interval.
How it works
The agent is a normal workflow with 20 steps (1 AI step, with a person approving in Reviews). You can open, edit and monitor it like any other workflow.
- Deal reached Closed won — Starts on “Deal entered a stage” in HubSpot (an app event). Starts when a HubSpot deal moves into the stage you pick (your Closed won stage). Checked on your plan's schedule interval.
- Read the deal — HubSpot: Find records. Reads the deal's details from HubSpot: name, amount, currency, description (where the line items are written) and close date.
- Find the deal's contacts — HubSpot: Find records. Lists the contacts linked to the deal (name, email, job title, company) to pick the billing contact.
- Prepare the invoice — AI step (runs on your AI provider key). AI picks the billing contact, turns the deal into invoice lines (amounts in cents; the total is rechecked in code next), sets the due date and memo from your rules, and lists anything to check.
- Check the math — Step. Adds up the invoice lines and converts every amount to cents in code — not by AI — writes the correct total and its difference from the deal amount, fills the review summary from the checked figures and flags anything the AI got wrong. Stripe gets only the checked lines.
- Approve the invoice — A person approves or rejects it in Reviews (the run waits). A person checks the billing contact, every line and the total in Reviews, edits them if needed and approves. Nothing is created in Stripe before this approval.
- Not approved — Kept in the run history. Branch: Rejected. Rejected: nothing was created in Stripe.
- Find the Stripe customer — Stripe: Find a customer by email. Branch: Approved. Looks for an existing Stripe customer with the billing email.
- Already a Stripe customer? — Decision: picks the branch to follow. An existing customer is reused; otherwise one is created with the billing contact's name and email.
- Create the Stripe customer — Stripe: Create a customer. Branch: New customer. Creates the customer in Stripe with the billing contact's email and the company name.
- Create the draft invoice — Stripe: Create a draft invoice. Branch: Existing customer. Creates a draft invoice for the customer with your payment terms and memo.
- Each line — Repeats the steps below for each item (up to 20 per run). Adds every approved line to the draft invoice (up to 20); the loop stops at the first line Stripe refuses.
- [For each item — “Each line”] Add the line — Stripe: Add an invoice line. Adds the line (description and amount) to the draft invoice.
- All lines added? — Decision: picks the branch to follow. Only a complete invoice is finalized and sent; otherwise the draft stays in Stripe for you to fix.
- Draft left in Stripe — Kept in the run history. Branch: Incomplete. No line or a failed line: the draft invoice stays in Stripe, unsent; the run history shows why.
- Line refused by Stripe — Kept in the run history. Branch: Line refused. Stripe refused a line: the draft invoice stays in Stripe, unsent; the run history shows Stripe's message.
- Finalize the invoice — Stripe: Finalize an invoice. Branch: Complete. Finalizes the draft: it gets its number, payment page and PDF.
- Email it from Stripe — Stripe: Send an invoice. Stripe emails the invoice with its payment page to the billing contact.
- Note it on the deal — HubSpot: Add a note. Logs the invoice number, total and payment link on the HubSpot deal.
- Invoice sent — Kept in the run history. The run history keeps the deal, the approved invoice and Stripe's ids.
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, dealname, amount, pipeline, dealstage, closedate, owner_id, createdate, properties.
- 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.
- For-each loops repeat only the first 3 items.
Go live
- Open the trigger and click “Activate app trigger”: deals that reach the stage after activation are picked up on your plan's schedule interval.
- 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
Where do the line items come from?
From the deal: write them in the deal description in the format your rules describe (e.g. one “Item — amount” per line). With none, the invoice has one line for the deal amount. HubSpot product line items aren't read.
Can the AI get the total wrong?
Not in what you approve: after the AI reads the deal, the lines are added up in code and compared with the deal amount, and the review screen shows anything that was corrected. Each line's amount is read from the deal by the AI, so compare the lines with the deal before approving.
Is anything sent without approval?
No. Nothing is created in Stripe until a person approves the invoice in Reviews.
Does it set up subscriptions?
No. One-off invoices only.
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 .