workflows.fit
Back to n8n workflows
n8n template$5By Cong Nguyen

Automated request-to-quote with OpenAI, Google Sheets & CraftMyPDF

📄 What this workflow does - Turns a simple form submission into a polished, priced PDF quote—automatically. - Captures lead details via Form: Request a Quote. - Loads your Google Sheets catalog (SKUs, price, stock, m...

CommunicationHITLCore NodesData & StorageProductivityDevelopmentAILangchain
Open checkout
Loading interactive preview...

Template notes

📄 What this workflow does - Turns a simple form submission into a polished, priced PDF quote—automatically. - Captures lead details via Form: Request a Quote. - Loads your Google Sheets catalog (SKUs, price, stock, min qty, etc.). - Uses OpenAI to select SKUs and build a strict JSON quote (respects instock and minqty, optional discount ≤10%). - Maps data in a Code node to compute line totals, discount, VAT, and a unique invoicenumber; validates/falls back duedate. - Renders a branded PDF via CraftMyPDF, fetches the file link, and emails the customer the quote.

👤 Who is this for - SMBs and sales teams needing instant quotes from website forms. - Ops teams managing catalogs in Sheets who want LLM-assisted SKU selection. - Agencies/shops that must generate consistent, branded PDFs and email them automatically.

✅ Requirements - A self-hosted n8n instance. - Google Sheets catalog with (recommended) columns: sku, name, uom, unitprice, currency, instock (TRUE/FALSE), minqty, leadtimedays, notes. - Connected credentials: Google Sheets OAuth2, OpenAI (or compatible), CraftMyPDF, SMTP. - A CraftMyPDF template whose fields match the Code node output (invoicenumber, items[], grosstotal, etc.). CraftMyPDF provides a drag-and-drop editor and PDF Generation API that work well with n8n.

⚙️ How to set up - Import the workflow JSON into n8n. - In Google Sheets: Products, set real documentId/sheetName (IDs) and connect OAuth. - In LLM node, keep or change model (default gpt-4.1-mini), and keep the “JSON-only” system prompt. - In Create a PDF, set your CraftMyPDF templateId. - In Email: Send Quote, set fromEmail and SMTP credentials. - Submit a test form; verify LLM JSON → PDF render → email delivery. - (Optional) Adjust defaults in the Code node: vatpct (default 10), paymentterms, currency fallback, and validdays.

🧩 CraftMyPDF template — quick guide (UI) - Create & open a template: Log in → Manage Templates → New Template (choose blank or a starter) → Edit to open the editor. The editor has four core tabs: Designer, Preview, Data, Settings. - Paste sample JSON: Go to the Data tab and paste a sample that mirrors what n8n will send (e.g., includes invoicenumber, client, items[]). This JSON powers the editor’s auto-complete and live preview. - Bind fields fast: In Designer, use Data Fields to drag pre-bound text/image components that auto-insert expressions from your JSON—much quicker than manual binding. - Add line items: For repeating rows like items[], use Simple Table (set Data Source to {{data.items}}, then in each column use {{row.field}}, e.g., {{row.description}}, {{row.quantity}}, {{row.unitprice}}, {{row.total}}). - Use expressions: Anywhere you need dynamic text, enter {{ data.<field> }}—for example {{data.invoicenumber}}, {{data.client}}, {{data.grosstotal}}. Preview the result and/or generate a real PDF from the Preview tab. - Finish & integrate: Save the template, note its Template ID, and use it in the n8n CraftMyPDF node. You can return to the editor anytime to tweak layout/styles; the next workflow run will use the updated design. The editor and API are built for reusable templates.

🔁 How it works - Trigger → Form submission captures: Full Name, Email, Company, Requirements, Budget Min/Max, Need By, Notes. - Catalog Load → Sheets node returns rows; passed to the LLM as JSON. - LLM Quote → Model selects SKUs/qty, pricing, discount (≤10%), terms, and returns VALID JSON only. - Code Mapping → Parses JSON (strips code fences if present), computes discounts/VAT/totals, assigns invoicenumber (Q-YYYYMMDD-ABCDE), and validates duedate (falls back to today + validdays). - PDF Render → CraftMyPDF generates the branded quote and returns a file URL. - Delivery → HTTP node fetches the file; SMTP node emails the customer with dynamic subject and totals.

💡 About Margin AI [Margin AI](https://marginai.co/) is your AI Service Companion. We help organizations design intelligent, human-centric automation — from content pipelines and branding workflows to customer insights and sales enablement. Our tailored AI solutions scale marketing, operations, and creative processes with ease.