Create QuickBooks invoices the moment HubSpot deals close won

By General Input

When a HubSpot deal flips to closed won, an agent finds or creates the customer in QuickBooks, drafts the invoice, and confirms it in your finance Slack channel.

Integrations

  • HubSpot
  • QuickBooks Online
  • Slack Bot

Type

Agentic Task

Categories

  • Finance
  • Sales

Build an agent workflow that turns every closed won HubSpot deal into a QuickBooks invoice and posts a confirmation in our finance Slack channel.

Trigger: HubSpot webhook on deal property change, filtered to the dealstage property switching to closed won (closedwon). The webhook payload gives the agent the dealId to work with.

When the workflow fires, the agent should:

1. Call HubSpot Get Deal for that dealId with associations to contacts, companies, and line items. Pull the deal amount, close date, owner, and the associated line items. Also pull the primary associated contact (email, first name, last name, phone) and the primary associated company (name, domain, billing address). If the deal is missing a primary contact or company, post a Slack message flagging the gap and stop.

2. Find or create the QuickBooks customer. Use QuickBooks Query Entities to search Customer first by the contact's email (PrimaryEmailAddr), then by the company DisplayName if no email match. If a customer exists, reuse its Id. If not, call QuickBooks Create Customer with DisplayName set to the company name (fall back to the contact full name), PrimaryEmailAddr set to the contact email, billing address from the company, and phone from the contact. The agent should reason about close-but-not-exact matches and prefer reusing an existing record over creating a duplicate.

3. Map deal line items to QuickBooks items. For each HubSpot line item, look up a QuickBooks Item with a matching name using Query Entities. If nothing matches, fall back to a configurable default service item (the user picks this during setup). Build the invoice line array with the item reference, quantity, unit price, and description from the HubSpot line item.

4. Call QuickBooks Create Invoice with the matched CustomerRef, the mapped Line array, and TxnDate set to the HubSpot deal close date. Capture the new invoice's DocNumber and Id.

5. Post a confirmation to a Slack channel (default to #finance, let the user change it at setup) using Slack Bot Send a Message. The message should include the customer DisplayName, invoice total (TotalAmt), invoice DocNumber, and a link back to the original HubSpot deal (https://app.hubspot.com/contacts/{portalId}/record/0-3/{dealId}). Format it cleanly with mrkdwn.

Error handling: if the QuickBooks customer create fails, if no line items map and there is no default service item set, or if the invoice create returns a Fault, the agent should post a Slack message in the same channel describing what failed and which HubSpot deal it was for, then stop without creating partial records.

Use the Slack Bot integration (not the user-token Slack one) so the confirmation comes from a bot identity that does not depend on any single user staying in the org.

Related prompts

Explore more prompts
A brand asset library your marketing team actually searchesTurn Mailjet email clicks into ranked HubSpot follow-upsClean out the Looker dashboards and Looks nobody opensLiveKit live operations console for room moderationWake up dormant Keap leads with a researched reasoniMessage campaign console with pre-flight checks and delivery boardLiveChat coverage board for planning next week's shiftsPhone routing control panel for LiveKit voice agentsA searchable RFP answer library your bid team drafts fromLinkedIn Ads budget pacing dashboard for every client account