Generate Square invoices and subscriptions from text with GPT-4o Mini

Go to Workflow
0 views
Built by isaWOW isaWOW
Created on August 18, 2026

Description

Quick overview
This sub-workflow accepts plain-language invoice details from a parent workflow, uses OpenAI to normalize and structure the data, then uses the Square API to find or create the customer, create and publish an invoice, and optionally create a monthly subscription, returning the public invoice URL.

How it works
Receives invoice fields (name, email, item, amount, notes, recurring flag, and date) from a parent workflow via an Execute Workflow trigger.
Uses OpenAI (GPT-4o-mini) with a structured output parser to clean and normalize the invoice data, including converting the date to YYYY-MM-DD and generating a unique invoice number.
Searches Square Customers by email and creates a new Square customer if no match is found.
Retrieves the Square customer profile and checks whether the customer has a card on file.
Creates a Square order and then creates and publishes a Square invoice configured for email delivery.
If the invoice is marked as Monthly, creates a Square subscription plan and plan variation and attaches the subscription to the customer; otherwise returns the published invoice public URL to the parent workflow.

Setup
Add an OpenAI credential for the OpenAI chat model nodes used by the agent and structured output parser.
Create a Square access token and replace YOUR_SQUARE_ACCESS_TOKEN in the Authorization header on every Square HTTP request.
Set your Square location ID by replacing YOUR_SQUARE_LOCATION_ID in the Create Order and Attach Subscription requests.
Call this workflow from a parent workflow and pass the expected input fields (Name, Email, Item, Amount, Notes, Recurring, and Date).

Nodes Used (4)

AI Agent
@n8n/n8n-nodes-langchain.agent
HTTP Request
n8n-nodes-base.httpRequest
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured