{
  "name": "S2D recipe - airtable-contract-pdf",
  "nodes": [
    {
      "id": "c3000000-0000-4000-8000-000000000001",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -540,
        -400
      ],
      "parameters": {
        "width": 600,
        "height": 340,
        "content": "## Contract PDF from an Airtable record\nMark a record Ready in your Contracts table and it becomes one SourceToDocs run: a contract from your Google Docs template, saved to Google Drive as a Doc and a PDF. The link is written back to the record and Status changes to Generated.\n\n**Set up before you activate**\n- Credentials: Airtable (Access Token or OAuth2) on the trigger and the Airtable node, a SourceToDocs API token on the SourceToDocs node\n- Base and Table are empty in both Airtable nodes: pick your Contracts table (fields Client legal name, Client address, Services, Fee, Payment terms, Start date, Signatory, Status, Contract link, and Status changed as a Last Modified Time field on Status)\n- SourceToDocs node: your contract document and its data set with the eight columns\n\nGuide: https://sourcetodocs.com/automations/airtable-contract-pdf/"
      }
    },
    {
      "id": "c3000000-0000-4000-8000-000000000002",
      "name": "Airtable Trigger",
      "type": "n8n-nodes-base.airtableTrigger",
      "typeVersion": 1,
      "position": [
        -480,
        0
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "authentication": "airtableTokenApi",
        "baseId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "tableId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "triggerField": "Status changed",
        "downloadAttachments": false,
        "additionalFields": {
          "fields": "Client legal name,Client address,Services,Fee,Payment terms,Start date,Signatory",
          "formula": "{Status} = 'Ready'"
        }
      }
    },
    {
      "id": "c3000000-0000-4000-8000-000000000003",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -260,
        -20
      ],
      "parameters": {
        "batchSize": 1,
        "options": {}
      }
    },
    {
      "id": "c3000000-0000-4000-8000-000000000004",
      "name": "SourceToDocs",
      "type": "@twovmodules/n8n-nodes-sourcetodocs.sourceToDocs",
      "typeVersion": 1.1,
      "position": [
        -20,
        0
      ],
      "parameters": {
        "resource": "document",
        "operation": "generate",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "rowsFrom": "mapped",
        "mappedDataSetId": "",
        "output": "simplified",
        "options": {},
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Client legal name": "={{ $json.fields['Client legal name'] }}",
            "Client address": "={{ $json.fields['Client address'] }}",
            "Services": "={{ $json.fields['Services'] }}",
            "Fee": "={{ $json.fields['Fee'] }}",
            "Payment terms": "={{ $json.fields['Payment terms'] }}",
            "Start date": "={{ $json.fields['Start date'] }}",
            "Signatory": "={{ $json.fields['Signatory'] }}",
            "Effective date": "={{ $now.toFormat('d LLLL yyyy') }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Client legal name",
              "displayName": "Client legal name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "Client address",
              "displayName": "Client address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "Services",
              "displayName": "Services",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "Fee",
              "displayName": "Fee",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "Payment terms",
              "displayName": "Payment terms",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "Start date",
              "displayName": "Start date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "Signatory",
              "displayName": "Signatory",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            },
            {
              "id": "Effective date",
              "displayName": "Effective date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      }
    },
    {
      "id": "c3000000-0000-4000-8000-000000000005",
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.2,
      "position": [
        200,
        0
      ],
      "parameters": {
        "authentication": "airtableTokenApi",
        "resource": "record",
        "operation": "update",
        "base": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "id": "={{ $('Loop Over Items').item.json.id }}",
            "Contract link": "={{ $json.file_url }}",
            "Status": "Generated"
          },
          "matchingColumns": [
            "id"
          ],
          "schema": [
            {
              "id": "id",
              "displayName": "id",
              "required": false,
              "defaultMatch": true,
              "display": true,
              "type": "string",
              "readOnly": true,
              "removed": false
            },
            {
              "id": "Contract link",
              "displayName": "Contract link",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Airtable Trigger": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "SourceToDocs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SourceToDocs": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Airtable": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
