{
  "name": "Sync L4: One-way Airtable to Notion",
  "nodes": [
    {
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.4,
      "position": [-720, 0],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      }
    },
    {
      "name": "Airtable: changed records",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [-500, 0],
      "parameters": {
        "resource": "record",
        "operation": "search",
        "base": {
          "__rl": true,
          "mode": "id",
          "value": "appPLACEHOLDER01"
        },
        "table": {
          "__rl": true,
          "mode": "id",
          "value": "tblPLACEHOLDER01"
        },
        "filterByFormula": "IS_AFTER({Last modified time}, DATEADD(NOW(), -20, 'minutes'))",
        "options": {}
      },
      "credentials": {
        "airtableTokenApi": {
          "id": "REPLACE_ME",
          "name": "Airtable"
        }
      }
    },
    {
      "name": "Any records to process?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [-280, 0],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "n1",
              "leftValue": "={{ $json.id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ]
        }
      }
    },
    {
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [-60, -60],
      "parameters": {
        "batchSize": 1,
        "options": {}
      }
    },
    {
      "name": "Notion: find matching page",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "alwaysOutputData": true,
      "position": [180, 40],
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "mode": "url",
          "value": "https://www.notion.so/YOUR_NOTION_DATABASE_ID?v=YOUR_VIEW_ID"
        },
        "returnAll": false,
        "limit": 1,
        "filterType": "json",
        "filterJson": "={\n  \"property\": \"Airtable ID\",\n  \"rich_text\": { \"equals\": \"{{ $('Loop Over Items').item.json.id }}\" }\n}",
        "options": {}
      },
      "credentials": {
        "notionApi": {
          "id": "REPLACE_ME",
          "name": "Notion"
        }
      }
    },
    {
      "name": "Page found?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [400, 40],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "n2",
              "leftValue": "={{ $json.id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ]
        }
      }
    },
    {
      "name": "Notion: update page",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [640, -60],
      "parameters": {
        "resource": "databasePage",
        "operation": "update",
        "pageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Name|title",
              "title": "={{ $('Loop Over Items').item.json.Name }}"
            },
            {
              "key": "Airtable ID|rich_text",
              "textContent": "={{ $('Loop Over Items').item.json.id }}"
            }
          ]
        },
        "options": {}
      },
      "credentials": {
        "notionApi": {
          "id": "REPLACE_ME",
          "name": "Notion"
        }
      }
    },
    {
      "name": "Notion: create page",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [640, 140],
      "parameters": {
        "resource": "databasePage",
        "operation": "create",
        "databaseId": {
          "__rl": true,
          "mode": "url",
          "value": "https://www.notion.so/YOUR_NOTION_DATABASE_ID?v=YOUR_VIEW_ID"
        },
        "title": "={{ $('Loop Over Items').item.json.Name }}",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Airtable ID|rich_text",
              "textContent": "={{ $('Loop Over Items').item.json.id }}"
            }
          ]
        },
        "options": {}
      },
      "credentials": {
        "notionApi": {
          "id": "REPLACE_ME",
          "name": "Notion"
        }
      }
    },
    {
      "name": "Wait 250ms",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [880, 40],
      "parameters": {
        "amount": 0.25,
        "unit": "seconds"
      }
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Airtable: changed records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable: changed records": {
      "main": [
        [
          {
            "node": "Any records to process?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Any records to process?": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Notion: find matching page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion: find matching page": {
      "main": [
        [
          {
            "node": "Page found?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Page found?": {
      "main": [
        [
          {
            "node": "Notion: update page",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notion: create page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion: update page": {
      "main": [
        [
          {
            "node": "Wait 250ms",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notion: create page": {
      "main": [
        [
          {
            "node": "Wait 250ms",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 250ms": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {}
}
