Raise a Zoho Books invoice the moment a HubSpot deal is won

By General Input

When a deal moves to closed won in HubSpot, we find or create the customer in Zoho Books, draft the invoice, and tell finance in Slack.

Integrations

  • HubSpot
  • Zoho Books
  • Slack

Type

Deterministic Code

Categories

  • Sales
  • Finance

Watch HubSpot for deal updates and, whenever a deal moves into a closed won stage, raise the matching draft invoice in Zoho Books automatically so sales never has to hand off to finance by hand. Use a poll trigger on HubSpot deals_updated as the entry point.

First resolve what closed won actually means in this account. Call List Pipelines for deals and find the stage that is marked as the closed won stage, rather than hardcoding a stage label or id, because stage ids are pipeline specific. If the updated deal is not in that stage, stop and do nothing.

Read the deal with Search Deals, filtering on the deal id from the trigger, and pull the deal name, amount, currency, close date, pipeline, deal stage, and owner id. There is no plain get deal operation in the catalog, so Search Deals with an id filter is the way to fetch it. If the amount is zero, blank, or missing, stop without creating anything. Resolve the deal owner's name and email with Get Owner using the owner id on the deal.

Before touching anything in Zoho Books, check whether this deal has already been invoiced. Call List Invoices and look for an invoice whose reference number is the HubSpot deal id. If one exists, stop. This is the deduplication guarantee: the same closed won deal must never produce two invoices, even if the deal is edited, reopened, or closed again later. Do not rely on any in memory state for this, the reference number on the invoice is the source of truth.

Resolve the billing customer. Use Batch Read Associations on the deal to get its associated company ids and contact ids. Fetch the company with Search Companies to get the company name, domain, and billing address, and fetch the associated contacts with Search Contacts to get the primary contact's first name, last name, and email. If the deal has more than one associated contact, use the first one as the billing contact. If the deal has no associated company, fall back to the contact's name for the customer record.

Look the customer up in Zoho Books with List Contacts, matching on the company name first and falling back to the billing contact's email address. If nothing matches, create the customer with Create Contact using the company name as the customer name, the HubSpot contact as the primary contact person, and the currency from the deal.

Raise the invoice with Create Invoice against that customer. Use a single line item with the deal name as the description and the deal amount as the rate, set the invoice date to the deal close date, and set the due date to the close date plus 30 days for net 30 terms. Put the HubSpot deal id in the invoice reference number so the deduplication check above can find it on the next run. Leave the invoice as a draft rather than marking it sent.

Finish by posting to Slack with Send a Message to the finance channel. Address the message to the deal owner by name so they know the handoff is done, and include the customer name, the invoice amount and currency, the Zoho Books invoice number, and the due date, plus a link back to the HubSpot deal. Send exactly one message per invoice created.

Build this as a deterministic code workflow. Every step is a known lookup, mapping, or create over structured CRM fields, so no judgement, drafting, or summarization is required.

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentWin back LiveChat visitors whose chats went unansweredTurn Mailjet email clicks into ranked HubSpot follow-upsiMessage campaign console with pre-flight checks and delivery boardChat quality review board for LiveChat support leadsA searchable RFP answer library your bid team drafts fromSee which target accounts just started advertising on LinkedInAccount health board that puts product usage next to your CRMLook up a customer's full chat history mid conversationLusha prospecting workbench with credit-safe reveals