8
n8n 中文网amn8n.com

JotForm 返现(模板)

高级

这是一个自动化工作流,包含 25 个节点。主要使用 If, Code, Gmail, Notion, HttpRequest 等节点。 使用 JotForm、Gemini 2.5 和 Notion 的自动化返现收据处理

前置要求
  • Google 账号和 Gmail API 凭证
  • Notion API Key
  • 可能需要目标 API 的认证凭证
  • Google Gemini API Key

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "PtWwGGJYMVyJGgoI",
  "meta": {
    "instanceId": "7f1a0694161455be3a7e71f1e0dea04908b0376a1a81e3a0c1e5ac879d48f83a"
  },
  "name": "JotForm 返现(模板)",
  "tags": [],
  "nodes": [
    {
      "id": "fafc18fe-9ffe-42d1-aa6e-16d2c44b0bab",
      "name": "JotForm 触发器",
      "type": "n8n-nodes-base.jotFormTrigger",
      "position": [
        -2896,
        480
      ],
      "webhookId": "YOUR_JOTFORM_WEBHOOK_ID",
      "parameters": {
        "form": "YOUR_FORM_ID"
      },
      "typeVersion": 1
    },
    {
      "id": "53c0d83e-9711-4b81-b738-70919a4c764e",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -1760,
        768
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-lite"
      },
      "typeVersion": 1
    },
    {
      "id": "6a8cba61-0195-44d7-a8e6-c6ab918918ab",
      "name": "OCR.Space",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1856,
        480
      ],
      "parameters": {
        "url": "https://api.ocr.space/parse/image",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "base64Image",
              "value": "=data:image/jpeg;base64,{{$json.imageBase64}}"
            },
            {
              "name": "language",
              "value": "ara"
            },
            {
              "name": "OCREngine",
              "value": "1"
            },
            {
              "name": "filetype",
              "value": "jpg"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "apikey",
              "value": "YOUR_OCR_SPACE_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3794d88d-02db-4183-94f2-05d9cbcf8358",
      "name": "获取所有收据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2688,
        480
      ],
      "parameters": {
        "url": "https://api.jotform.com/form/YOUR_FORM_ID/files",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "apiKey",
              "value": "YOUR_JOTFORM_API_KEY_FOR_FILES"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6cc27de0-4bcf-4fc6-8bfc-27044cfa482d",
      "name": "获取收据文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2272,
        480
      ],
      "parameters": {
        "url": "={{ $json.lastFile.url.replace('http://','https://') }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a3580172-cbe7-41e3-9c8c-cf965050f75e",
      "name": "获取最新收据",
      "type": "n8n-nodes-base.code",
      "position": [
        -2480,
        480
      ],
      "parameters": {
        "jsCode": "// Access the array that contains all files\n// Adjust the path if necessary (e.g., $json.content or $json.files)\nconst files = $json.files || $json.content || [];\n\n// If it's a dictionary of answers, flatten all URLs\nlet allUrls = [];\nif (!Array.isArray(files)) {\n  // if it’s a Jotform structure like answers -> each -> answer:[urls]\n  const answers = files.answers || files.data?.answers || {};\n  for (const key of Object.keys(answers)) {\n    const a = answers[key]?.answer;\n    if (Array.isArray(a)) allUrls.push(...a);\n  }\n} else {\n  allUrls = files;\n}\n\n// Take the last file\nconst lastFile = allUrls[allUrls.length - 1] || null;\n\n// Return it as a single field\nreturn [{ json: { lastFile } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "12f9b49f-e973-4e2e-afa0-63b2488becc0",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -1424,
        752
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"store_name\": \"\",\n  \"purchase_date\": \"\",\n  \"products\": [\n    {\n      \"product_name\": \"\",\n      \"quantity\": 0,\n      \"unit_price\": 0,\n      \"total_price\": 0,\n      \"cashback_amount\": 0\n    }\n  ],\n  \"total_cashback\": 0\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "1aee2b39-2516-48ec-8b24-2565eb6974ce",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1616,
        480
      ],
      "parameters": {
        "text": "=You are an intelligent assistant for XQ Pharma.\n\nYou receive OCR text extracted from a customer's purchase receipt.\nThe text may include both Arabic and English, with missing spaces, symbols, or repeated lines.\n\n### STEP 1 — Clean and Organize\nClean and rewrite the OCR text in a clear, structured way:\n- Combine broken lines that belong to the same sentence or product.\n- Remove repeating symbols, dots, commas, or words.\n- Normalize Arabic (اكس كيو) and English (XQ) text forms.\n- Try to create a simple, readable “receipt” view with one product per line.\n\n### STEP 2 — Identify XQ Pharma Products\n- Find all products that belong to XQ Pharma (look for \"XQ\", \"اكس كيو\", or variants like \"اكس ك\").\n- Rebuild product lines if necessary (for example, join “كريم اكس” + “كيو مرطب” = “كريم اكس كيو مرطب”).\n- For each product line, detect nearby numbers that look like prices.\n\n### STEP 3 — Extract Data\nExtract:\n- store_name\n- purchase_date\n- products → a list of all identified XQ Pharma items, each with:\n  - product_name  \n  - quantity (default 1 if missing)\n  - unit_price (try to find numbers following the product name)\n  - total_price (quantity × unit_price if not listed)\n  - cashback_amount (10% of total_price)\n- total_cashback = sum of cashback_amount values\n\nIf any value is missing, infer it logically (for example, assume total_price = unit_price if only one quantity).\n\n### STEP 4 — Output\nReturn **only** a valid JSON in this exact structure (no text or notes before or after):\n\n{\n  \"store_name\": \"\",\n  \"purchase_date\": \"\",\n  \"products\": [\n    {\n      \"product_name\": \"\",\n      \"quantity\": ,\n      \"unit_price\": ,\n      \"total_price\": ,\n      \"cashback_amount\": \n    }\n  ],\n  \"total_cashback\": \n}\n\n### OCR Text Input:\n{{ $json.ParsedResults[0].ParsedText }}\n",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "29d1089d-f09b-4380-a9fd-20c79bb16b4e",
      "name": "客户邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -656,
        224
      ],
      "webhookId": "YOUR_GMAIL_WEBHOOK_ID",
      "parameters": {
        "sendTo": "={{ $('JotForm Trigger').item.json['E-mail'] }}",
        "message": "=🎉 Congratulations! You’ve earned a cashback reward 🎁\n\n🗓️ Purchase Date: {{ $('AI Agent').item.json.output.purchase_date }}\n🏬 Store: {{ $('AI Agent').item.json.output.store_name }}\n\n🧴 Products Purchased:\n{{ $node['AI Agent'].json[\"output\"][\"products\"].map(p => `• ${p.product_name} — Cashback: ${p.cashback_amount} EGP`).join('\\n') }}\n\n💰 Total Cashback Earned: {{ $('AI Agent').item.json.output.total_cashback }} EGP 🎉\n\nYour cashback will be added to your wallet within 24 hours.\nThank you for your purchase 💙\n",
        "options": {},
        "subject": "Cashback",
        "emailType": "text"
      },
      "typeVersion": 2.1
    },
    {
      "id": "f4e533e6-db38-48aa-acb6-544b16a6a915",
      "name": "营销邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -656,
        496
      ],
      "webhookId": "YOUR_GMAIL_WEBHOOK_ID",
      "parameters": {
        "sendTo": "=Marketing@yourcompany.com",
        "message": "=📢 Cashback Notification – New Reward Granted 🎉\n\n🗓️ Purchase Date: {{ $('AI Agent').item.json.output.purchase_date }}\n🏬 Store: {{ $('AI Agent').item.json.output.store_name }}\n\n🧾 Products Purchased:\n{{ $node['AI Agent'].json[\"output\"][\"products\"].map(p => `• ${p.product_name} — Cashback: ${p.cashback_amount} EGP`).join('\\n') }}\n\nCustomer name : {{ $('JotForm Trigger').item.json['Full Name'].first }} {{ $('JotForm Trigger').item.json['Full Name'].last }}\nCustomer Email: {{ $('JotForm Trigger').item.json['E-mail'] }}\nCustomer Phone Number: {{ $('JotForm Trigger').item.json['Contact Number'].full }}\n\n\n💰 Total Cashback Issued: {{ $('AI Agent').item.json.output.total_cashback }} EGP\n\n✅ Status: Cashback confirmation message sent to customer.\nPlease ensure this transaction is logged in the campaign tracking sheet.\n",
        "options": {},
        "subject": "Cashback Notification - New Reward",
        "emailType": "text"
      },
      "typeVersion": 2.1
    },
    {
      "id": "e4f93b36-e5df-4e62-a7c1-2565459d49f8",
      "name": "添加信息到数据库",
      "type": "n8n-nodes-base.notion",
      "position": [
        -944,
        384
      ],
      "parameters": {
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_NOTION_DATABASE_ID",
          "cachedResultUrl": "https://www.notion.so/YOUR_NOTION_DATABASE_ID",
          "cachedResultName": "Cashback"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Customer name|title",
              "title": "={{ $('JotForm Trigger').item.json['Full Name'].first }} {{ $('JotForm Trigger').item.json['Full Name'].last }}"
            },
            {
              "key": "Customer Email|email",
              "emailValue": "={{ $('JotForm Trigger').item.json['E-mail'] }}"
            },
            {
              "key": "Store Type|rich_text",
              "textContent": "={{ $('JotForm Trigger').item.json['Purchase Channel'] }}"
            },
            {
              "key": "Store Name|rich_text",
              "textContent": "={{ $('JotForm Trigger').item.json['Store Name'] }}"
            },
            {
              "key": "Cashback Amount|number",
              "numberValue": "={{ $json.output.total_cashback }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e20517ed-2f08-4b8b-bf81-41cd7fb23eea",
      "name": "是否有返现",
      "type": "n8n-nodes-base.if",
      "position": [
        -1216,
        480
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "329c2481-24e8-4871-8035-813bc48f82f2",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.output.total_cashback }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "36c305f5-efa7-4849-9f1e-1c384f8c4833",
      "name": "将图像转换为 base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -2064,
        480
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery",
        "destinationKey": "imageBase64"
      },
      "typeVersion": 1
    },
    {
      "id": "7199729e-da73-4c70-a0a2-6a67815a890b",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3008,
        400
      ],
      "parameters": {
        "color": 3,
        "width": 272,
        "content": "在表单提交时启动工作流;提供客户和初始购买数据。"
      },
      "typeVersion": 1
    },
    {
      "id": "b8601130-a266-4e72-af38-bd759db0457f",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2720,
        400
      ],
      "parameters": {
        "color": 4,
        "width": 176,
        "content": "从 JotForm API 请求所有上传的收据文件列表。"
      },
      "typeVersion": 1
    },
    {
      "id": "2db6bf7f-be22-4476-bb72-2d5ad7ae16bc",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2528,
        400
      ],
      "parameters": {
        "color": 5,
        "width": 192,
        "height": 176,
        "content": "从文件列表中提取最近上传的收据的 URL。"
      },
      "typeVersion": 1
    },
    {
      "id": "7c1b00ae-e1c9-495e-81ed-1adfd2f68317",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2320,
        400
      ],
      "parameters": {
        "color": 4,
        "width": 176,
        "height": 176,
        "content": "使用提取的 URL 下载实际的收据图像文件。"
      },
      "typeVersion": 1
    },
    {
      "id": "2b3df853-ea8b-4d31-9299-776f78841213",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2128,
        400
      ],
      "parameters": {
        "color": 5,
        "width": 208,
        "height": 176,
        "content": "将下载的图像编码为 base64 字符串,为 OCR 做准备。"
      },
      "typeVersion": 1
    },
    {
      "id": "c0e1412d-ad4d-4946-b831-521736cb267a",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1904,
        400
      ],
      "parameters": {
        "color": 4,
        "width": 192,
        "height": 176,
        "content": "将收据图像转换为纯文本。"
      },
      "typeVersion": 1
    },
    {
      "id": "85a4879c-6f96-4f97-be8f-80c14382a5e9",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1696,
        400
      ],
      "parameters": {
        "color": 6,
        "width": 368,
        "content": "使用 Gemini 清理原始 OCR 文本,识别 XQ 产品,并提取结构化数据,如价格和返现。"
      },
      "typeVersion": 1
    },
    {
      "id": "b6e73eed-0bba-47e4-9935-ab0bfb029f2f",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        400
      ],
      "parameters": {
        "color": 5,
        "width": 272,
        "content": "条件检查;仅当计算的返现金额大于零时才允许工作流继续。"
      },
      "typeVersion": 1
    },
    {
      "id": "384f6f49-6402-4ebf-865f-1bd2bfdbfb84",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        320
      ],
      "parameters": {
        "color": 4,
        "width": 224,
        "content": "将客户详细信息和计算的返现金额记录到 Notion 数据库。"
      },
      "typeVersion": 1
    },
    {
      "id": "00d037bc-7d84-4e71-b696-894de6e0a4f4",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        160
      ],
      "parameters": {
        "color": 5,
        "content": "向客户发送确认邮件,详细说明他们获得的返现奖励。"
      },
      "typeVersion": 1
    },
    {
      "id": "99b4585d-9f9a-4f88-93f2-8163fa3d7522",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        416
      ],
      "parameters": {
        "color": 5,
        "content": "向营销团队发送包含所有交易详情的内部邮件通知,用于跟踪。"
      },
      "typeVersion": 1
    },
    {
      "id": "af05870d-bd52-4b37-9a54-f1e49ef16963",
      "name": "便利贴12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2992,
        -368
      ],
      "parameters": {
        "width": 1024,
        "height": 736,
        "content": "# JotForm 设置指南"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "AI Agent": [
      {
        "json": {
          "output": {
            "products": [
              {
                "quantity": 1,
                "unit_price": 0,
                "total_price": 0,
                "product_name": "Placeholder Product 1",
                "cashback_amount": 0
              }
            ],
            "store_name": "Placeholder Store Name",
            "purchase_date": "YYYY-MM-DD",
            "total_cashback": 0
          }
        }
      }
    ],
    "OCR.Space": [
      {
        "json": {
          "OCRExitCode": 1,
          "ParsedResults": [
            {
              "ParsedText": "OCR_TEXT_FROM_RECEIPT_GOES_HERE"
            }
          ],
          "IsErroredOnProcessing": false,
          "ProcessingTimeInMilliseconds": "1000"
        }
      }
    ],
    "JotForm Trigger": [
      {
        "json": {
          "E-mail": "placeholder@example.com",
          "Full Name": {
            "last": "Placeholder Last Name",
            "first": "Placeholder First Name"
          },
          "Store Name": "xq pharma",
          "Purchase Date": {
            "day": "09",
            "year": "2025",
            "month": "10"
          },
          "Contact Number": {
            "full": "(000) 000-0000"
          },
          "Purchase Channel": "Online Store"
        }
      }
    ],
    "Add info to Database": [
      {
        "json": {
          "id": "PLACEHOLDER_NOTION_PAGE_ID",
          "url": "https://www.notion.so/PLACEHOLDER_NOTION_PAGE_ID",
          "name": "Placeholder Customer Name",
          "property_store_name": "Placeholder Store Name",
          "property_store_type": "Online Store",
          "property_customer_name": "Placeholder Customer Name",
          "property_customer_email": "placeholder@example.com",
          "property_cashback_amount": 0
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e1e2b6a4-b113-4c0b-9ac7-02c978c36323",
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Is There's cashback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OCR.Space": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JotForm Trigger": {
      "main": [
        [
          {
            "node": "Fetch All Receipts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gets Last Receipt": {
      "main": [
        [
          {
            "node": "Fetch Receipt File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch All Receipts": {
      "main": [
        [
          {
            "node": "Gets Last Receipt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Receipt File": {
      "main": [
        [
          {
            "node": "Convert Image to base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is There's cashback": {
      "main": [
        [
          {
            "node": "Add info to Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add info to Database": {
      "main": [
        [
          {
            "node": "Customer Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Marketing Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Image to base64": {
      "main": [
        [
          {
            "node": "OCR.Space",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量25
分类-
节点类型11
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Abdullah Alshiekh

Abdullah Alshiekh

@abdullah01

🚀 Automation pro building AI-powered workflows with n8n. 💼 Special focus on real use cases 🔧 Love clean, flexible, and business-ready automations.

外部链接
在 n8n.io 查看

分享此工作流