AITraining2U · n8n Workshop

Copy & Paste
AI Prompts

Ready-to-use prompts and JSON schemas for n8n AI nodes. Copy, paste, and go.

Back to Home

Workflow Overview

n8n AI extraction workflow: Form submission, Analyze document, Information Extractor, Split Out, Append to Google Sheet
AI extraction workflow
click to zoom
On form submission
Analyze document
Information Extractor
Split Out
Append to Sheet
AI · Extraction

Prompts for n8n's AI nodes — Information Extractor, Text Classifier, and Summarizer.

Extraction of Metrics
Extract Key Financial Performance Metrics
Extracts structured financial data (revenue, expenses, profit, margins) from raw text like reports, invoices, or statements using the Information Extractor node.
Information Extractor Node
Step 1 — Prompt to AI Chat (to get the JSON schema)
I want to extract the key financial performance metrics. I am working on n8n, please write me a JSON schema for the Information Extractor node, please refer to the input reference. [COPY PASTE YOUR INPUT REFERENCE FROM n8n HERE]
How to use: Copy the prompt above, paste it into an AI chat (e.g. ChatGPT, Claude). Include your actual input data from n8n where indicated. The AI will generate the JSON schema for you to paste back into the Information Extractor node's output schema. Below is an example of what it should produce.
Step 2 — System Prompt (paste into Information Extractor)
// Paste this into the "System Prompt" field of the Information Extractor node You are a financial data extraction specialist. Your task is to carefully analyze the provided text and extract key financial performance metrics with precision. Rules: - Extract exact numerical values as they appear in the text - If a currency is mentioned, include it (e.g. "MYR", "USD") - If a metric is not found in the text, return null - For percentages, return the number only (e.g. 12.5, not "12.5%") - If a date or period is mentioned, include it in the period field - Be conservative: only extract values you are confident about
Step 3 — JSON Schema (example output definition)
{ "type": "object", "properties": { "period": { "type": "string", "description": "The reporting period, e.g. Q1 2026, FY2025, Jan 2026" }, "currency": { "type": "string", "description": "ISO currency code, e.g. MYR, USD, SGD" }, "total_revenue": { "type": "number", "description": "Total revenue / sales / income for the period" }, "total_expenses": { "type": "number", "description": "Total operating expenses / costs for the period" }, "gross_profit": { "type": "number", "description": "Gross profit (revenue minus cost of goods sold)" }, "net_profit": { "type": "number", "description": "Net profit / net income after all expenses and taxes" }, "gross_margin_pct": { "type": "number", "description": "Gross profit margin as a percentage" }, "net_margin_pct": { "type": "number", "description": "Net profit margin as a percentage" }, "cost_of_goods_sold": { "type": "number", "description": "Cost of goods sold / direct costs" }, "operating_income": { "type": "number", "description": "Operating income / EBIT" }, "tax_amount": { "type": "number", "description": "Tax expense for the period" }, "year_over_year_growth_pct": { "type": "number", "description": "Revenue growth compared to previous year as percentage" } }, "required": ["total_revenue", "net_profit"] }
How to set up in n8n
  1. Add an Information Extractor node to your workflow
  2. Connect an AI model (e.g. OpenAI GPT-4o or Anthropic Claude) to the AI input
  3. Set Text to your input field — use the expression editor to reference the incoming data, e.g. {{ $json.text }} or {{ $json.body }}
  4. Paste the System Prompt into the system prompt field
  5. Switch Output Schema to Define Below, then paste the JSON Schema into the schema editor
  6. The node will output a clean JSON object with all extracted metrics
Tip: Connect the output to a Spreadsheet File node to automatically generate Excel reports from the extracted financial data. You can also chain this with a Filter node to flag entries where net_margin_pct < 10.
Extraction of Line Items
Extract Invoice Line Items
Extracts structured line items from invoices or receipts — product, quantity, unit price, and totals — ready for pivot tables or reconciliation.
Information Extractor Node
System Prompt
// Paste this into the "System Prompt" field of the Information Extractor node You are an invoice processing specialist. Extract all line items from the provided invoice or receipt text. Rules: - Extract every distinct product/service line item - Calculate line_total as quantity * unit_price if not stated - Capture the invoice number and date if present - Use the currency shown on the document - If tax/SST is listed separately, capture it - Return amounts as numbers, not formatted strings - For the line items, please flatten the table within line items (e.g. if modifiers, add-ons, discounts, or sub-items exist, flatten them into individual rows rather than nesting them)
JSON Schema (Output Definition)
{ "type": "object", "properties": { "invoice_number": { "type": "string", "description": "Invoice or receipt number" }, "invoice_date": { "type": "string", "description": "Invoice date in YYYY-MM-DD format" }, "vendor_name": { "type": "string", "description": "Name of the vendor or seller" }, "currency": { "type": "string", "description": "ISO currency code" }, "line_items": { "type": "array", "description": "List of products/services on the invoice", "items": { "type": "object", "properties": { "description": { "type": "string", "description": "Product or service name" }, "quantity": { "type": "number", "description": "Quantity purchased" }, "unit_price": { "type": "number", "description": "Price per unit" }, "line_total": { "type": "number", "description": "Total for this line item" } } } }, "subtotal": { "type": "number", "description": "Subtotal before tax" }, "tax_amount": { "type": "number", "description": "Tax / SST amount" }, "grand_total": { "type": "number", "description": "Grand total including tax" } }, "required": ["line_items", "grand_total"] }
How to set up in n8n
  1. Use Extract from File node to convert your PDF/image invoice to text first
  2. Connect the text output to an Information Extractor node
  3. Paste the system prompt and JSON schema as shown above
  4. The output line_items array can be split using a Split Out node for individual row processing
Extraction · Multiple Files
Extract Line Items from Multiple Invoices
For workflows with multiple invoices as input — extracts all detailed line items across all documents into a flat, structured output.
Information Extractor Node
Prompt to AI
I am working on n8n, please write me a JSON schema for the Information Extractor node, please refer to my input reference (I have multiple invoices as input). I want to extract all detailed line items in the invoices. For the line items, please flatten the table within line items (e.g. if modifiers, add-ons, discounts, or sub-items exist, flatten them into individual rows rather than nesting them). [PASTE YOUR INPUT REFERENCE JSON FROM n8n HERE]
System Prompt
// Paste this into the "System Prompt" field of the Information Extractor node You are an invoice data extraction specialist working with multiple invoices in a single batch. Rules: - Process ALL invoices in the input, not just the first one - Extract every line item from every invoice - Flatten nested items: modifiers, add-ons, discounts, and sub-items should each become their own row - Include the invoice_number on each line item so rows can be traced back to their source document - Return amounts as numbers, not formatted strings - If a field is not found, return null - Dates should be in YYYY-MM-DD format
JSON Schema (Output Definition)
{ "type": "object", "properties": { "invoices": { "type": "array", "description": "Array of all invoices processed", "items": { "type": "object", "properties": { "invoice_number": { "type": "string", "description": "Invoice or receipt number" }, "invoice_date": { "type": "string", "description": "Invoice date in YYYY-MM-DD format" }, "vendor_name": { "type": "string", "description": "Vendor or seller name" }, "currency": { "type": "string", "description": "ISO currency code" }, "line_items": { "type": "array", "description": "Flattened list of all line items including modifiers/add-ons as separate rows", "items": { "type": "object", "properties": { "item_type": { "type": "string", "enum": ["product", "service", "modifier", "addon", "discount"], "description": "Type of line item" }, "description": { "type": "string", "description": "Product, service, or modifier name" }, "parent_item": { "type": "string", "description": "Parent item name if this is a modifier/addon/discount, null otherwise" }, "quantity": { "type": "number", "description": "Quantity" }, "unit_price": { "type": "number", "description": "Price per unit" }, "line_total": { "type": "number", "description": "Total for this line" } } } }, "subtotal": { "type": "number", "description": "Subtotal before tax" }, "tax_amount": { "type": "number", "description": "Tax / SST amount" }, "grand_total": { "type": "number", "description": "Grand total including tax" } } } } }, "required": ["invoices"] }
How to set up in n8n
  1. Use a Loop Over Items or batch the files so all invoices arrive as one input
  2. Use Extract from File to convert PDFs/images to text
  3. Feed the combined text to Information Extractor with the above schema
  4. Use Split Out on invoices then again on line_items to get one row per line item
Tip: The item_type field lets you filter modifiers vs products downstream. Use a Filter node to separate discounts for separate processing, or a Switch to route each type differently.

AI Agent · System Messages

Prompts for improving AI Agent node system messages — fixing output format issues, Telegram compatibility, and reliable structured responses.

Agent · Output Formatting
Fix AI Agent Output for Telegram (No Parse Errors)
Improves the system message of an AI Agent node so all responses are Telegram-compatible — no format errors when parsing messages through the Telegram Send Message node.
AI Agent Node
Prompt to AI (to improve your system message)
I am working on n8n. I have an AI Agent node whose output goes to a Telegram Send Message node. I keep getting format/parse errors because the AI output contains characters or formatting that Telegram's API cannot parse. Please improve my AI Agent's system message so that ALL responses are in Telegram-compatible format. The output must: 1. Use Telegram MarkdownV2 format only 2. Escape all special characters that MarkdownV2 requires: _ * [ ] ( ) ~ ` > # + - = | { } . ! 3. Never use HTML tags 4. Never use standard Markdown (only MarkdownV2) 5. Keep responses clean, readable, and well-structured Here is my current system message: [PASTE YOUR CURRENT SYSTEM MESSAGE HERE]
Append this to your system message (or use as a base)
// Append this to the end of your AI Agent's system message // This ensures all output is Telegram MarkdownV2 compatible CRITICAL OUTPUT FORMATTING RULES: You MUST format ALL responses for Telegram MarkdownV2. Follow these rules exactly — any violation will cause a parse error and the message will fail to send. 1. ESCAPE these special characters with a backslash (\) whenever they appear in normal text (not as formatting): _ * [ ] ( ) ~ ` > # + - = | { } . ! Example: "Price: $10.50" → "Price: $10\.50" Example: "Q&A" → "Q&A" Example: "50% off!" → "50% off\!" 2. ALLOWED formatting (use these for structure): *bold text* _italic text_ __underline__ ~strikethrough~ `inline code` ```pre-formatted code block``` [link text](https://example\.com) 3. NEVER use: - HTML tags (, , , etc.) - Standard Markdown (## headers, --- lines, ** bold) - Unescaped special characters in plain text - Nested formatting (e.g. *_bold italic_*) - Empty formatting markers (* * or _ _) 4. For bullet lists, use plain text markers: • Item one • Item two (Use the bullet character •, not - or *) 5. For section headers, use bold: *Section Title* 6. For numbers and prices, always escape dots: RM 1,250\.00 not RM 1,250.00 10\.5% not 10.5% 7. For URLs, escape dots and special chars inside: [Click here](https://example\.com/page\?id\=123) 8. Keep responses concise. Use line breaks (\n) for spacing between sections.
How to set up in n8n
  1. Open your AI Agent node and go to the System Message field
  2. Append the formatting rules above to the end of your existing system message
  3. In the Telegram Send Message node, set Parse Mode to MarkdownV2
  4. Test with messages containing special characters (prices, percentages, URLs) to verify
Common parse errors: The #1 cause is unescaped dots in numbers like RM 1,250.00 and unescaped exclamation marks. The #2 cause is using standard Markdown headers (##) instead of bold (*text*). Adding these rules to your system message fixes 95% of Telegram formatting failures.
Alternative approach: If MarkdownV2 is too strict, you can set the Telegram node's Parse Mode to HTML instead, and update the system message rules to output <b>, <i>, <code> tags. HTML mode is more forgiving with special characters but less flexible for styling.

Code · JavaScript Node

Prompts for generating JavaScript code to use inside n8n's Code node — for data transformation, report generation, and file output.

Code · Report Generation
Sales Reconciliation Report (HTML + Downloadable File)
Generates a JavaScript Code node that produces an HTML reconciliation report comparing POS sales to bank statements, with unmatched transactions and discrepancies highlighted. Outputs a downloadable Base64 binary file in n8n.
Code Node (JavaScript)
Prompt to AI
I am working on n8n, please write me Code in JavaScript for a Code node. The input reference consists of: - Bank Statements - Credit Card Merchant Statements - POS Sales Report I want the output in HTML format as a downloadable Base64 binary file in n8n. The reconciliation report should show: 1. My sales as per POS sales report (summary and breakdown) 2. Reconciling items: - Unmatched transactions (in POS but not in bank, and vice versa) - Discrepancies (amount differences for matched transactions) - Timing differences (transactions on different dates) 3. Tally back to bank statements (final reconciliation to bank balance) The HTML report should be styled, printable, and professional-looking. Here is my input reference data from n8n: [PASTE YOUR INPUT JSON FROM n8n HERE]
How to set up in n8n
  1. Ensure your upstream nodes provide 3 inputs: bank statements, credit card merchant statements, and POS sales report (use Merge nodes to combine if needed)
  2. Copy the prompt above, paste your actual n8n JSON input data where indicated
  3. Send to an AI Chat node (e.g. GPT-4o or Claude) to generate the JavaScript code
  4. Paste the generated code into a Code node set to JavaScript
  5. The Code node will output a binary item — connect it to a Respond to Webhook or Send Email node to deliver the HTML report
How Base64 binary output works in n8n: The Code node converts the HTML string to a Base64-encoded buffer using Buffer.from(html).toString('base64'), then returns it as a binary property. This makes it downloadable as an .html file through the n8n UI or via webhook response.
Tip: Include your actual JSON data in the prompt so the AI can reference your exact field names (e.g. transaction_date, settlement_amount, pos_total). The more specific your input, the more accurate the generated code.

AITraining2U Workshop · n8n AI Prompts · April 2026