AutomationFlowsAI & RAG › Generate Ai-powered Lease Renewal Offers with Ollama Llm, Supabase and Gmail

Generate Ai-powered Lease Renewal Offers with Ollama Llm, Supabase and Gmail

ByLakindu Siriwardana @laki99 on n8n.io

Automated Lease Offer Generation using AI (Ollama model). Duplicate File Check to avoid reprocessing the same customer. Personalized Offer Letter creation based on customer details from Supabase. PDF/Text File Conversion for formatted output. Automatic Google Drive Management…

Event trigger★★★★☆ complexityAI-powered17 nodesOllama ChatForm TriggerGmailSupabaseGoogle DriveChain Llm
AI & RAG Trigger: Event Nodes: 17 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #7201 — we link there as the canonical source.

This workflow follows the Chainllm → Form Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "PiWH2tT9abPCn184",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "LeaseRenewalOffer",
  "tags": [],
  "nodes": [
    {
      "id": "052b0f7a-43f1-4246-b034-00ddc4c10e1e",
      "name": "Ollama Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        200,
        600
      ],
      "parameters": {
        "model": "llama3.1:latest",
        "options": {
          "temperature": 0.3
        }
      },
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3e7e8a93-ca37-4ed5-83d7-659e87b7d4b5",
      "name": "Edit Fields",
      "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\": \"user@example.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": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -560,
        -80
      ],
      "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": "Convert to File",
      "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
      ],
      "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": {
          "name": "<your credential>"
        }
      },
      "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": {
          "name": "<your credential>"
        }
      },
      "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": {
          "name": "<your credential>"
        }
      },
      "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": {
          "name": "<your credential>"
        }
      },
      "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": {
          "name": "<your credential>"
        }
      },
      "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": {
          "name": "<your credential>"
        }
      },
      "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: \u20ac{{ $('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 \u2014 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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "1b3a0198-59ce-4ff2-b332-2ef33a5e6f86",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        -140
      ],
      "parameters": {
        "width": 1420,
        "height": 220,
        "content": "## Get Customer Information\n"
      },
      "typeVersion": 1
    },
    {
      "id": "67c75d5c-ad31-4f36-a1e7-ec1a7a7b1fe5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        100
      ],
      "parameters": {
        "color": 5,
        "width": 1420,
        "height": 280,
        "content": "## Generate offer letter \n"
      },
      "typeVersion": 1
    },
    {
      "id": "3baf2115-e8cd-499f-957d-d2e0dfe65bbc",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        400
      ],
      "parameters": {
        "color": 6,
        "width": 1420,
        "height": 320,
        "content": "## Send Email"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "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
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Automated Lease Offer Generation using AI (Ollama model). Duplicate File Check to avoid reprocessing the same customer. Personalized Offer Letter creation based on customer details from Supabase. PDF/Text File Conversion for formatted output. Automatic Google Drive Management…

Source: https://n8n.io/workflows/7201/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow is perfect for graphic designers, creative agencies, marketing teams, or freelancers who regularly use AI-generated images in their projects. It's specifically beneficial for teams that

Google Sheets, Google Drive, HTTP Request +5
AI & RAG

This workflow helps support teams evaluate call quality and deliver structured feedback without manual review. Agents upload their recordings using an n8n Form, and the system handles transcription, s

Google Gemini, Memory Buffer Window, Output Parser Structured +6
AI & RAG

My workflow 53. Uses formTrigger, httpRequest, lmChatOpenAi, form. Event-driven trigger; 74 nodes.

Form Trigger, HTTP Request, OpenAI Chat +15
AI & RAG

Episode 23: UGC with nanobanana. Uses lmChatOpenAi, lmChatOllama, lmChatDeepSeek, lmChatOpenRouter. Event-driven trigger; 74 nodes.

OpenAI Chat, Ollama Chat, Lm Chat Deep Seek +12
AI & RAG

leads. Uses supabase, gmail, formTrigger, httpRequest. Webhook trigger; 62 nodes.

Supabase, Gmail, Form Trigger +13