See llms.txt for all machine-readable content.

Back to Templates

Create freee請求書 invoice drafts from won HubSpot deals with Slack updates

Quick overview

This workflow runs every weekday and turns newly won HubSpot deals into UNSENT invoice drafts in freee請求書 by matching HubSpot companies to freee partners, copying HubSpot line items, and posting a single status report to Slack with links back to the deals.

How it works

  1. Runs on a weekday schedule at 9:00 (or manually) and loads configuration values like freee company ID, lookback window, and Slack channel.
  2. Retrieves recently closed-won HubSpot deals, the list of freee partners, and recent freee invoices for the configured company.
  3. Filters out deals that already have a corresponding freee invoice by checking for a hubspot-deal:<dealId> marker in the freee invoice memo.
  4. For each remaining deal, fetches its associated HubSpot company and line items, then validates that there is exactly one company, the currency is JPY, and no discounts are present.
  5. Builds invoice line items and totals, finds the matching freee partner by shortcut2 containing hubspot:<companyId>, and creates an UNSENT draft invoice in freee請求書.
  6. Posts a single Slack message summarizing created drafts and skipped deals, and writes a HubSpot note on each deal where an invoice draft was created.

Setup

  1. Add HubSpot private app token credentials with permission to read deals, companies, and line items and to create notes.
  2. Add a freee OAuth2 credential with access to read partners, read invoices, and create invoices, and set your freee company ID in the Config step.
  3. In freee, link each customer by setting the partner’s shortcut2 to hubspot:<HubSpotCompanyId> (or adjust the link_prefix value to match your convention).
  4. Add a Slack credential, invite the Slack app to the target channel, and set the channel ID in the Config step.
  5. Review and adjust Config values (won stages, lookback days, tax rate, payment terms, and max deals) before enabling the schedule.

Requirements

  • HubSpot account with a Service key (deals read and write, line items and companies read)
  • freee account with an app (partners read; invoices read and write)
  • Slack app with chat:write

Customization

  • Change won_stages for your pipeline, or lookback_days and the schedule.
  • Set prices_include_tax and tax_rate to match how you enter prices in HubSpot.
  • Turn on use_amount_without_items to invoice deals without line items as one line from the deal amount.
  • Change payment_terms (end_of_next_month or a number of days).

Additional info

Important limits:

  • One tax rate for all lines (set in Config); deals with reduced-rate items need a manual invoice.
  • Up to 100 won deals, 3,000 freee partners and 2,000 freee invoices are read per run. The freee invoice list is oldest first with a limit of 100 per page, so the workflow narrows it by billing date (lookback_days plus 31 days) and reads every page; if more invoices than that fall in the period, the duplicate check cannot see them all.
  • The HubSpot note is added after the Slack message; if it fails, the invoice still exists and is not created again.

What I tested (n8n 2.36.8, HubSpot free account, a freee test company, a Slack test channel; all data made up): a won deal with two line items (¥90,000 net) became an unsent draft of ¥99,000 with tax, the deal amount (¥99,000) was flagged as tax-included, and a note was added to the deal; the second run created nothing. A deal for a company without a linked freee partner and a deal without line items were listed with the reason and not invoiced. With use_amount_without_items and prices_include_tax on, the deal without items became a ¥22,000 draft (¥20,000 + ¥2,000 tax). freee refused tax-included prices with withholding "out" at first; the workflow now sets both to "in". The first version read one page of invoices, assuming it held the latest 100; the freee list is oldest first, so a company with more than 100 invoices would have received a new duplicate draft every weekday. I fixed it and tested the paging with a page size of 3: all three pages were read and the two invoiced deals, whose invoices were on page 3, were skipped. I did not test discounted line items (they are skipped by design), more than 100 deals, or a company with more than 100 real invoices.