8
n8n 中文网amn8n.com

LeaseRenewalOffer

高级

这是一个Document Extraction, Multimodal AI领域的自动化工作流,包含 17 个节点。主要使用 If, Set, Gmail, Supabase, FormTrigger 等节点。 使用Ollama LLM、Supabase和Gmail生成AI驱动的租约续约报价

前置要求
  • Google 账号和 Gmail API 凭证
  • Supabase URL 和 API Key
  • Google Drive API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "PiWH2tT9abPCn184",
  "meta": {
    "instanceId": "558d88703fb65b2d0e44613bc35916258b0f0bf983c5d4730c00c424b77ca36a",
    "templateCredsSetupCompleted": true
  },
  "name": "LeaseRenewalOffer",
  "tags": [],
  "nodes": [
    {
      "id": "052b0f7a-43f1-4246-b034-00ddc4c10e1e",
      "name": "## 🧠 LLM 总结",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        200,
        600
      ],
      "parameters": {
        "model": "llama3.1:latest",
        "options": {
          "temperature": 0.3
        }
      },
      "credentials": {
        "ollamaApi": {
          "id": "7CIt42W14b1MCgxQ",
          "name": "Ollama account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3e7e8a93-ca37-4ed5-83d7-659e87b7d4b5",
      "name": "获取简报",
      "type": "n8n-nodes-base.set",
      "position": [
        40,
        -80
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"landload_address\": \"Lakindu Siriwardana, Neuenlander Str. 28201 Bremen, Germany.\",\n  \"contact_email\": \"lakithegreat99@gmail.com\",\n  \"contact_phone\": \"+491739XXXXXX\",\n  \"company_name\": \"HX GmbH\",\n  \"landload_name\": \"Lakindu Siriwardana\"\n}\n",
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "ca9a343d-399c-4fba-9b43-33afa6d92109",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -560,
        -80
      ],
      "webhookId": "e8f9fa32-b7c8-4c19-95e0-576a4e5653b3",
      "parameters": {
        "options": {},
        "formTitle": "Customer Renewal Form",
        "formFields": {
          "values": [
            {
              "fieldType": "number",
              "fieldLabel": "Customer id:",
              "requiredField": true
            },
            {
              "fieldType": "number",
              "fieldLabel": "Renewal Amount:",
              "requiredField": true
            }
          ]
        },
        "formDescription": "By: Laki"
      },
      "typeVersion": 2.2
    },
    {
      "id": "4ba6fd65-73b0-4e7e-b153-c7480190dd5e",
      "name": "[{",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        560,
        200
      ],
      "parameters": {
        "options": {},
        "operation": "toText",
        "sourceProperty": "text"
      },
      "typeVersion": 1.1
    },
    {
      "id": "13ca0896-de6e-4514-a0e6-3ef6d50197b2",
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        520,
        420
      ],
      "webhookId": "",
      "parameters": {
        "sendTo": "={{ $('Supabase-search_cust').item.json.cust_email }}",
        "message": "={{ $json.text }}",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {
                "property": "down-data"
              }
            ]
          }
        },
        "subject": "=Offer Renewal {{ $('Supabase_cust_info').item.json.cust_name }} {{ $('Supabase-search_cust').item.json.renewable_date.toString().slice(0,7) }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "0d58e4d2-7cb7-4439-b767-08690b84e43a",
      "name": "Supabase-search_cust",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -360,
        -80
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "keyValue": "={{ $json['Customer id:'] }}"
            }
          ]
        },
        "tableId": "customer_details",
        "operation": "get"
      },
      "credentials": {
        "supabaseApi": {
          "id": "",
          "name": "Supabase account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ccc9a1df-fd42-46d8-b0bc-dee42b750046",
      "name": "Google Drive-delete_dup",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        60,
        120
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "deleteFile"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "",
          "name": "Google Drive account"
        }
      },
      "executeOnce": false,
      "typeVersion": 3,
      "alwaysOutputData": false
    },
    {
      "id": "840867fa-1b4b-4175-ad02-ab803e36af6e",
      "name": "If-check_dup",
      "type": "n8n-nodes-base.if",
      "position": [
        -120,
        180
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d4c39be3-a4a4-4cff-bc08-5209109359bd",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.id }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "01009db3-6a95-421f-b650-c3aa4943a58a",
      "name": "Supabase_cust_info",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -160,
        -80
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "keyValue": "={{ $json.id }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "customer_details",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "renewable_date",
              "fieldValue": "={{ $now }}"
            },
            {
              "fieldId": "Renewal Amount",
              "fieldValue": "={{ $('On form submission').item.json['Renewal Amount:'] }}"
            }
          ]
        },
        "operation": "update"
      },
      "credentials": {
        "supabaseApi": {
          "id": "",
          "name": "Supabase account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5edd5d07-b549-4f4b-b130-09b830de645d",
      "name": "Google Drive-search",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        240,
        -80
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "__rl": true,
            "mode": "list",
            "value": "1GGYne4bMaff9_1RvId2en38SPtmnInBA",
            "cachedResultUrl": "",
            "cachedResultName": "OfferRenewal"
          }
        },
        "options": {},
        "resource": "fileFolder",
        "queryString": "={{ $('Edit Fields').item.json.cust_name }}{{ $('Edit Fields').item.json.renewable_date }}"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3,
      "alwaysOutputData": true
    },
    {
      "id": "47b4fa52-ec59-449c-8e53-c7f5f0319a76",
      "name": "Google Drive-upload",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -280,
        420
      ],
      "parameters": {
        "name": "={{ $('Edit Fields').item.json.cust_name }}{{ $('Edit Fields').item.json.renewable_date }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1GGYne4bMaff9_1RvId2en38SPtmnInBA",
          "cachedResultUrl": "",
          "cachedResultName": "OfferRenewal"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "9e1ae15e-fe3b-491d-900d-817a9060d1f0",
      "name": "Basic LLM Chain-offerLetter",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        240,
        200
      ],
      "parameters": {
        "text": "=The output should follow the below format only. No extra text should be added\n\n{{ $('Edit Fields').item.json.landload_address.split(',').map(line => line.trim()).join('\\n') }}\n{{ $now.toISO().slice(0,10) }}\n\n{{ $('Supabase_cust_info').item.json.cust_name }}  \n{{ $('Supabase_cust_info').item.json.cust_address.split(',').map(line => line.trim()).join('\\n') }}.\n\nSubject: Lease Renewal Offer for Your Residence at {{ $('Supabase_cust_info').item.json.cust_address }}.\n\nDear {{ $('Supabase_cust_info').item.json.cust_name }},\n\nWe hope this letter finds you well.\n\nWe are writing to inform you that your current lease agreement for the property located at  {{ $('Supabase_cust_info').item.json.cust_address }} is due to expire on {{ $('Supabase_cust_info').item.json.renewable_date }}.\n\nWe would like to offer you the opportunity to renew your lease for an additional term of one year, under the following conditions:\n\n- Lease Term: From {{ $('Supabase_cust_info').item.json.renewable_date }} to {{ new Date(new Date($('Supabase_cust_info').item.json.renewable_date).setDate(new Date($('Supabase_cust_info').item.json.renewable_date).getDate() + 365)).toISOString().slice(0, 10) }}\n\n- Monthly Rent: €{{ $('On form submission').item.json['Renewal Amount:'] }}\n\nPlease confirm your acceptance of this offer by replying to this letter or contacting us no later than {{ new Date(new Date($('Supabase_cust_info').item.json.renewable_date).setDate(new Date($('Supabase_cust_info').item.json.renewable_date).getDate() + 7)).toISOString().slice(0,10) }}.\n\nShould you have any questions or wish to discuss any details of the renewal, please do not hesitate to reach out via email at {{ $('Edit Fields').item.json.contact_email }} or by phone at {{ $('Edit Fields').item.json.contact_phone }}.\n\nWe appreciate your tenancy and look forward to continuing to serve you.\n\nYours sincerely,\n\n{{ $('Edit Fields').item.json.landload_name }}\n{{ $('Edit Fields').item.json.company_name }} \n{{ $('Edit Fields').item.json.contact_email }}  \n{{ $('Edit Fields').item.json.contact_phone }}\n",
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "efa884ba-1617-40b5-9cd5-35268b338502",
      "name": "Basic LLM Chain-email",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -60,
        420
      ],
      "parameters": {
        "text": "=You are an assistant that writes professional business emails.  \nRefer to the provided text as the source of details.  \nWrite a formal letter to the client based on that text.  \n\nRequirements:  \n- The email should be short and mentioned find the attached document.  \n- No explanations, notes, or extra text — output only the final email content.  \n- Do not include any labels like \"Email:\" or \"Dear [Name]\" unless part of the actual email.  \n- The email must start directly with the greeting and end with the closing signature.  \n- don't import subject field\n\n[Provided text: {{ $('Basic LLM Chain-offerLetter').item.json.text }}]",
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "7681102f-2b1f-4368-ba49-90a1dad18f51",
      "name": "Google Drive-get_file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        340,
        420
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Google Drive-upload').item.json.id }}"
        },
        "options": {
          "binaryPropertyName": "down-data"
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "1b3a0198-59ce-4ff2-b332-2ef33a5e6f86",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        -140
      ],
      "parameters": {
        "width": 1420,
        "height": 220,
        "content": "## 获取客户信息"
      },
      "typeVersion": 1
    },
    {
      "id": "67c75d5c-ad31-4f36-a1e7-ec1a7a7b1fe5",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        100
      ],
      "parameters": {
        "color": 5,
        "width": 1420,
        "height": 280,
        "content": "## 生成续租报价函"
      },
      "typeVersion": 1
    },
    {
      "id": "3baf2115-e8cd-499f-957d-d2e0dfe65bbc",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        400
      ],
      "parameters": {
        "color": 6,
        "width": 1420,
        "height": 320,
        "content": "## 发送邮件"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3b191f36-aca4-4274-8249-555703d8bf06",
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Google Drive-search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If-check_dup": {
      "main": [
        [
          {
            "node": "Google Drive-delete_dup",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Basic LLM Chain-offerLetter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Google Drive-upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain-offerLetter",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Basic LLM Chain-email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Supabase-search_cust",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase_cust_info": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive-search": {
      "main": [
        [
          {
            "node": "If-check_dup",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive-upload": {
      "main": [
        [
          {
            "node": "Basic LLM Chain-email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase-search_cust": {
      "main": [
        [
          {
            "node": "Supabase_cust_info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain-email": {
      "main": [
        [
          {
            "node": "Google Drive-get_file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive-get_file": {
      "main": [
        [
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive-delete_dup": {
      "main": [
        [
          {
            "node": "Basic LLM Chain-offerLetter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain-offerLetter": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 文档提取, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量17
分类2
节点类型10
难度说明

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

作者
Lakindu Siriwardana

Lakindu Siriwardana

@laki99

AI Engineer | Researcher

外部链接
在 n8n.io 查看

分享此工作流