Quick overview
This workflow captures customer orders from Gmail or a public n8n form, matches the customer and their open quotations in freee, uses Anthropic Claude to interpret the order text, and creates an unsent freee Invoice draft based on the selected quotation, then notifies staff by Gmail.
How it works
- Triggers when a new Gmail message matches the subject search query or when someone submits the “order-to-freee-invoice” n8n form.
- Extracts the sender email, subject, and plain-text order message and applies shared configuration like company ID, payment terms, and staff notification email.
- Fetches partners from the freee API and identifies the customer by matching the sender email or a unique partner name mentioned in the order text.
- Retrieves the customer’s open freee quotations (prioritizing any Q-… number mentioned) plus existing invoices, and loads the details of the top quotation candidates.
- Sends the order text and quotation line summaries to Anthropic Claude to determine whether it is a clear order, which quotation it references, and any requested quantity changes or additions.
- Validates the AI result in code, prevents duplicates by checking for an existing invoice referencing the quotation number, applies only verifiable quantity changes, and turns unclear additions into “To check” note lines.
- Creates an UNSENT invoice draft in freee Invoice using prices/taxes from the quotation and either emails the staff a detailed result via Gmail or shows the outcome on the form completion page.
Setup
- Create/enable a freee app with permissions for Partners (read) and freee Invoice quotations/invoices (read/write), and add an n8n OAuth2 credential for the freee API.
- Add Gmail credentials for the Gmail Trigger and Gmail Send nodes, then set the staff notification address in the Config node.
- Add an Anthropic credential for the Claude chat model node.
- Update the Config node with your freee company ID, payment terms/days, max quotation candidates, and timezone.
- If using the form entry path, publish the form and share its URL; if using Gmail, adjust the Gmail search query to match your order emails.
Requirements
- freee with freee Invoice (freee請求書) and an app in freee Developers (permissions: partners read, [請求書] all document types read/write); an n8n OAuth2 API credential for freee. Gmail (OAuth2) and an Anthropic API key (one Claude call per order mail).
Customization
- Set the freee company ID, staff e-mail, payment terms (end of next month or days) and how many open quotations to compare in Config. Change which mails count in the Gmail search of New order mail (or use a label). Change the due date rule in Check and build. Send the notice to Slack or Teams instead of Gmail.
Additional info
Prices come from the quotation, never from the AI: Claude only says whether the mail is an order, for which quotation and which quantities change, quoting the words; code checks them, stops duplicates (memo "From quotation ..."), and copies every price and tax rate. Tested on a freee developer test company with made-up data: eight mails, including a real Gmail mail; freee's totals matched the workflow's own.