{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "156504d4-d521-4e12-9062-096ac1ef6078",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -288,
        1320
      ],
      "parameters": {
        "path": "e180c04c-2d55-44b8-8f82-800cad5ac10e",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "a28d3e11-e26b-4fa9-913d-6b461809b95f",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -64,
        1320
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "patreon",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ca8bc4e6-b702-4fd4-9b67-44b591313723",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.headers['user-agent'] }}",
                    "rightValue": "Patreon"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "kofi",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "10184ef4-1078-4a92-94d8-ed517177a875",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.headers['user-agent'] }}",
                    "rightValue": "Kofi"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "70f7cdb3-acf6-4f15-92df-afb98700658c",
      "name": "Set Token",
      "type": "n8n-nodes-base.set",
      "position": [
        160,
        1800
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1c0061ae-b9c8-4650-9f96-6aa2ff08758a",
              "name": "token",
              "type": "string",
              "value": ""
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1e25c67b-0f3f-44c7-9afc-e99618be9bd1",
      "name": "Parse Kofi Payload",
      "type": "n8n-nodes-base.code",
      "position": [
        384,
        1800
      ],
      "parameters": {
        "jsCode": "// Input comes from n8n as items\nconst input = $('Webhook').first().json.body.data; // your JSON string\n\nlet parsed;\ntry {\n    parsed = JSON.parse(input); // parse the inner JSON\n} catch (e) {\n    console.error(\"Invalid JSON:\", e.message);\n    parsed = {};\n}\n\n// n8n requires an array of objects\nreturn [\n    {\n        json: parsed\n    }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "035c60bb-c8a7-4795-9820-ea548a78b957",
      "name": "Switch1",
      "type": "n8n-nodes-base.switch",
      "position": [
        1856,
        1688
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Donation",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5aab1f09-af6d-433d-8bf9-079780c9bf98",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Parse Kofi Payload').item.json.type }}",
                    "rightValue": "Donation"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Subscription",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ac034dcc-9cc1-4c22-9a74-3e957ab76587",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Parse Kofi Payload').item.json.type }}",
                    "rightValue": "Subscription"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Shop Order",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8956ef1d-adbb-488b-a160-5eac2155c003",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Parse Kofi Payload').item.json.type }}",
                    "rightValue": "Shop Order"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "de2be0e3-b586-45a6-87f9-cb12b6b83c25",
      "name": "Token Validation",
      "type": "n8n-nodes-base.if",
      "position": [
        608,
        1800
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "98973fc2-dbe3-451a-b1f3-cef4c7a72283",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.verification_token }}",
              "rightValue": "={{ $('Set Token').item.json.token }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "f05fdc67-54e6-4836-88a8-e3341cb039c9",
      "name": "Fake Payload Alert",
      "type": "n8n-nodes-base.gmail",
      "position": [
        832,
        1896
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "Someone just sent a fake payload to your Kofi webhook.",
        "options": {},
        "subject": "fake payload detected!",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "38ef2260-d4fc-44ac-9ed4-9e8919f84dde",
      "name": "Thank you Letter",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2080,
        1512
      ],
      "parameters": {
        "sendTo": "={{ $json.email }}",
        "message": "Say how happy you are.",
        "options": {},
        "subject": "=Thanks!",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0705c1aa-a3f4-4422-a405-052ccc42d7d6",
      "name": "Thank you Letter1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2080,
        1704
      ],
      "parameters": {
        "sendTo": "={{ $json.email }}",
        "message": "Say how happy you are.",
        "options": {},
        "subject": "=Thanks!",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d89e18e9-8406-4ca4-a0be-2ff47e928761",
      "name": "Thank you Letter2",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2080,
        1896
      ],
      "parameters": {
        "sendTo": "={{ $json.email }}",
        "message": "Say how happy you are.",
        "options": {},
        "subject": "=Thanks!",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e5f4cf22-e035-40ed-9786-c6f82c33345e",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        1632,
        1704
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "a0f542ef-9dce-4c07-9d75-a11891e90cc5",
      "name": "Get Newsletter Subs1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        832,
        1704
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.email }}",
              "lookupColumn": "email"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064/edit?usp=drivesdk",
          "cachedResultName": "Newsletter"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "c0231a04-0da6-4773-b178-379070d89589",
      "name": "Person Exists on the List?1",
      "type": "n8n-nodes-base.if",
      "position": [
        1120,
        1704
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7121acf2-f7c6-4284-baf4-d669bd982594",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.isEmpty() }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "93650e4a-bbb3-4c20-adc3-156d8ccdf540",
      "name": "Add New Sub to Newsletter1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1408,
        1632
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $('Parse Kofi Payload').item.json.from_name }}",
            "email": "={{ $('Parse Kofi Payload').item.json.email }}"
          },
          "schema": [
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064/edit?usp=drivesdk",
          "cachedResultName": "Newsletter"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "6b89b036-8a7e-4c58-914e-f4daf78110eb",
      "name": "Switch2",
      "type": "n8n-nodes-base.switch",
      "position": [
        1440,
        576
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "brand_new_follower",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9c7bde94-2d61-47c8-a1f1-b9c362792ce3",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output[0].content[0].text.status }}",
                    "rightValue": "brand_new_follower"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "brand_new_patron_one_time",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fb210a5c-eac9-4ea2-95dd-320d31230c00",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output[0].content[0].text.status }}",
                    "rightValue": "brand_new_patron_one_time"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "brand_new_patron_subscription",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a8c8eaa4-5554-46ca-b38a-a47f70c5a51d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output[0].content[0].text.status }}",
                    "rightValue": "brand_new_patron_subscription"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "follower_to_one_time",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8014762c-4ed0-45f6-b1f5-23acfa4f2de6",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output[0].content[0].text.status }}",
                    "rightValue": "follower_to_one_time"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "follower_to_subscription",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "87de895d-99e9-4496-b75a-33c685cefefc",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output[0].content[0].text.status }}",
                    "rightValue": "follower_to_subscription"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "subscription_upgraded",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fd10deae-ef40-4154-8246-e73836d375ff",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output[0].content[0].text.status }}",
                    "rightValue": "subscription_upgraded"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "subscription_downgraded",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "84132fef-f0c6-48f7-8b6d-bac1f114da6c",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output[0].content[0].text.status }}",
                    "rightValue": "subscription_downgraded"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "subscription_cancelled",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "1d2abbb5-dcc5-49e1-b77f-3302765a066a",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output[0].content[0].text.status }}",
                    "rightValue": "subscription_cancelled"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "68db8766-0dd3-4e09-8392-28a34c18c51d",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1056,
        672
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "options": {
          "textFormat": {
            "textOptions": {
              "type": "json_object"
            }
          }
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "=You are classifying Patreon webhook events.\n\nYou are given:\n\n1. Full webhook payload in `body.data`\n2. An additional field called `event_type`, taken from webhook headers (`x-patreon-event`)\n\nIMPORTANT RULES (STRICT):\n\n* `event_type` is authoritative and OVERRIDES any inference from `body.data`.\n* If `event_type == \"members:delete\"`, always return `subscription_cancelled`.\n* If `event_type == \"members:update\"`, you must never return a `brand_new_*` status. Only return `follower_to_one_time`, `follower_to_subscription`, `subscription_upgraded`, `subscription_downgraded`, or `subscription_cancelled`.\n* If `event_type == \"members:create\"`, you may return a `brand_new_*` status if the data matches.\n\nStatuses (choose exactly one):\n\n* brand_new_follower\n* brand_new_patron_one_time\n* brand_new_patron_subscription\n* follower_to_one_time\n* follower_to_subscription\n* subscription_upgraded\n* subscription_downgraded\n* subscription_cancelled\n\nHow to classify:\n\n1. subscription_cancelled\n\n   * If `event_type == \"members:delete\"`, return this. Always.\n\n2. Brand-new statuses (`brand_new_*`)\n\n   * Only if `event_type == \"members:create\"`.\n   * `brand_new_follower`: No prior membership, `patron_status` null or not a patron, no payment.\n   * `brand_new_patron_one_time`: First-ever patron, `pledge_cadence == 0`.\n   * `brand_new_patron_subscription`: First-ever patron, `pledge_cadence >= 1`.\n\n3. Updates (`members:update`)\n\n   * Never return any `brand_new_*` status.\n   * `follower_to_one_time`: Previously a follower, now `pledge_cadence == 0`.\n   * `follower_to_subscription`: Previously a follower, now `pledge_cadence >= 1`.\n   * `subscription_upgraded`: Existing subscription, payment/tier increased.\n   * `subscription_downgraded`: Existing subscription, payment/tier decreased.\n\nOutput format (STRICT):\n\n```\n{\n  \"status\": \"<one_of_the_statuses_above>\"\n}\n```\n\n---\n\nThis version is simplified, fully respects `event_type`, and prevents the LLM from incorrectly marking updates as \"brand new\".\n"
            },
            {
              "content": "={{ JSON.stringify($('Webhook').item.json.body.data) }}\n\nevent_type: {{ $('Webhook').item.json.headers['x-patreon-event'] }}"
            }
          ]
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "ab8acaeb-ebb6-4761-a094-c63ea6d2b637",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        832,
        672
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "1f388f14-3b64-4bdc-91b4-3a62b4060685",
      "name": "Get Newsletter Subs",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        160,
        672
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.body.data.attributes.email }}",
              "lookupColumn": "email"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064/edit?usp=drivesdk",
          "cachedResultName": "Newsletter"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "9604ff3c-3f46-4f1e-b411-cb7d9721f9a1",
      "name": "Person Exists on the List?",
      "type": "n8n-nodes-base.if",
      "position": [
        384,
        672
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7121acf2-f7c6-4284-baf4-d669bd982594",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.isEmpty() }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ccfec126-ec11-4710-a023-241e87a05d9b",
      "name": "Add New Sub to Newsletter",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        608,
        608
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $('Webhook').item.json.body.data.attributes.full_name }}",
            "email": "={{ $('Webhook').item.json.body.data.attributes.email }}"
          },
          "schema": [
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1uaPJWmAa8yEUPHad6OvDkoqLrahzZORDFjExyxR3064/edit?usp=drivesdk",
          "cachedResultName": "Newsletter"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "471eb7ee-ca1f-4a4a-b5a6-2adb0d49869f",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1664,
        0
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "fc089d56-268f-4a53-968b-f2f836d07ad5",
      "name": "Send a message1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1664,
        192
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "29521d5f-974c-4a4a-a986-620398782bf6",
      "name": "Send a message2",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1664,
        384
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "23f7e83f-107a-4dbb-9d96-ec5b689a3a2a",
      "name": "Send a message3",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1664,
        768
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "8117b97d-384e-4862-812f-664f07c03116",
      "name": "Send a message4",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1664,
        960
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c2c39b8c-5217-4f42-8469-bda9d6abdc13",
      "name": "Send a message5",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1664,
        1152
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "470a5590-889b-4ee0-81ab-3b2fcb1af8a8",
      "name": "Send a message6",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1664,
        1344
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7f619e67-2afe-4744-9593-8c373d6ee240",
      "name": "Send a message7",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1664,
        576
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ef9296e0-c8dc-4ad4-a2d5-f27f2b5e6fd1",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        272
      ],
      "parameters": {
        "width": 500,
        "height": 894,
        "content": "## Patreon & Ko-fi Webhook Processor\n\n### About\nThis system is listening for webhooks from patreon and kofi.\nOnce received, it detects the service by looking at headers. \n\nFor Kofi it parses and validates the payload to make sure it's not fake. Once validated, it checks whether the person is on your newsletter lead list. If not, it adds person to your newsletter list. Then it checks the status of the payload, either it's a donation, subscription or shop purchase. \n\nFor Patreon it checks whether the person is on your newsletter lead list and adds him if not. Then it checks the payload type using AI and returns a status, e.g. new patron, cancelled subscription etc.\n\n### Setup\n- [ ] Connect your Gmail account used to send thank-you and alert messages\n- [ ] Connect Google Sheets and select the Newsletter spreadsheet and sheet\n- [ ] Add your OpenAI API key and select the desired model for classification\n- [ ] Set the Ko-fi verification token in the workflow and Ko-fi webhook settings\n- [ ] Configure your Patreon webhook to send payloads to the webhook URL and forward x-patreon-event. Configure 6 events that are not deprecated and are not post-related.\n- [ ] Customize emails you'll be sending for each branch\n\n### Customization\nFor Kofi you can customize emails that you'll be sending to members. For shop orders you can add invoice generation, supplier file generation, connect with your stock etc.\nFor Patreon you can customize emails you'll send to followers and patrons.\nFor both you can enable a crm where you'll track how much each person paid you so you know whether somebody upgrades or downgrades their subscription based on CRM data."
      },
      "typeVersion": 1
    },
    {
      "id": "fe6bf38d-e74d-4d4a-9457-c5a9b97bdb8c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        112,
        1680
      ],
      "parameters": {
        "color": 3,
        "width": 192,
        "height": 288,
        "content": "## Set Token\nGet an auth token from Kofi to validate your payloads."
      },
      "typeVersion": 1
    },
    {
      "id": "da980daf-09d1-412a-80e6-e129a674c935",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        1520
      ],
      "parameters": {
        "color": 7,
        "width": 1024,
        "height": 352,
        "content": "## Newsletter\nWe check whether person is on our newsletter list or not. If not, we add him. If not, skip.\nCreate a \"Newsletter\" spreadsheet with columns \"email\" and \"name\". Set up the node and feel free to add more columns if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "644975a7-20c3-44be-bf56-384b66076095",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1824,
        1392
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 688,
        "content": "## Letters\nSet up letters that you're gonna send to members."
      },
      "typeVersion": 1
    },
    {
      "id": "78442062-d6cc-4654-877c-b94dbfd41791",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        480
      ],
      "parameters": {
        "color": 7,
        "width": 912,
        "height": 352,
        "content": "## Newsletter\nWe check whether person is on our newsletter list or not. If not, we add him. If not, skip.\nCreate a \"Newsletter\" spreadsheet with columns \"email\" and \"name\". Set up the node and feel free to add more columns if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "d5d54e94-2377-4222-ac0e-cac5ad3673b6",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        528
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 304,
        "content": "## Status Validation\nWe use OpenAI to determine the status of operations"
      },
      "typeVersion": 1
    },
    {
      "id": "ff263dd8-bbdc-4877-8e3e-dd035fed1333",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 1616,
        "content": "## Letters\nSet up letters that you're gonna send to members."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get Newsletter Subs",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Thank you Letter",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Thank you Letter1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Thank you Letter2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch2": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message7",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message5",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send a message6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Token": {
      "main": [
        [
          {
            "node": "Parse Kofi Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Switch2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Token Validation": {
      "main": [
        [
          {
            "node": "Get Newsletter Subs1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fake Payload Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Kofi Payload": {
      "main": [
        [
          {
            "node": "Token Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Newsletter Subs": {
      "main": [
        [
          {
            "node": "Person Exists on the List?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Newsletter Subs1": {
      "main": [
        [
          {
            "node": "Person Exists on the List?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add New Sub to Newsletter": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add New Sub to Newsletter1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Person Exists on the List?": {
      "main": [
        [
          {
            "node": "Add New Sub to Newsletter",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Person Exists on the List?1": {
      "main": [
        [
          {
            "node": "Add New Sub to Newsletter1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}