{
  "id": "xzC6ZGU79T4uN7OH",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Track e-signatures and deliver signed PDFs with PDF Generator API, Gmail and Slack",
  "tags": [],
  "nodes": [
    {
      "id": "d6aba078-ddb7-4696-ad39-ce2fb35626d0",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        -176
      ],
      "parameters": {
        "width": 480,
        "height": 832,
        "content": "## Track e-signatures and deliver signed PDFs with PDF Generator API, Gmail and Slack\n\n### How it works\n\nThis workflow receives e-signature related events through a webhook and routes them based on the action type. New form submissions are saved to Google Sheets, while completed signature events update the submission record, download an optimized signed PDF, and distribute it. The signed document is emailed to the client, saved to Google Drive, and announced to the team in Slack.\n\n### Setup steps\n\n- Configure the webhook URL in the e-signature or form system that sends submission and signing events.\n- Connect Google Sheets credentials and select the spreadsheet/ranges used for saving new submissions and updating signed records.\n- Connect PDF Generator API credentials and configure the template/document settings needed to download the signed PDF.\n- Connect Gmail, Google Drive, and Slack credentials, then set the recipient email fields, Drive destination folder, and Slack channel.\n\n### Customization\n\nAdjust the switch rules in Route by Action to match the exact event names sent by your e-signature provider, and customize the email body, Slack message, spreadsheet columns, and Drive folder structure."
      },
      "typeVersion": 1
    },
    {
      "id": "719334ca-5092-40c3-b181-c1babee246ca",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        48
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 320,
        "content": "## Receive and route events\n\nEntry cluster that accepts incoming webhook events and branches the workflow according to the action type."
      },
      "typeVersion": 1
    },
    {
      "id": "f66668d7-300c-4ad0-88b0-d3061b25530d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 240,
        "height": 576,
        "content": "## Record submission data\n\nMiddle-left Google Sheets cluster that either saves a new form submission or updates an existing submission record when a signing event is received."
      },
      "typeVersion": 1
    },
    {
      "id": "aceec016-ee20-4d9b-89c0-680ce6b604b0",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 720,
        "content": "## Deliver signed PDF\n\nRight-side delivery cluster that downloads and optimizes the completed signed PDF, emails it to the client, saves it to Google Drive, and notifies the team in Slack."
      },
      "typeVersion": 1
    },
    {
      "id": "39cd60ac-a6de-4cef-920b-a052559784b9",
      "name": "When Document Callback",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -896,
        208
      ],
      "parameters": {
        "path": "document-callback",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "905e3b25-8c50-47e7-ad10-15a185406562",
      "name": "Process Signed PDF",
      "type": "@pdfgeneratorapi/n8n-nodes-pdf-generator-api.pdfGeneratorApi",
      "position": [
        -176,
        192
      ],
      "parameters": {
        "fileUrl": "={{ $('When Document Callback').item.json.body.response }}",
        "resource": "pdfServices",
        "operation": "optimize",
        "outputFormat": "file"
      },
      "credentials": {
        "pdfGeneratorApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4b71d1ca-5106-4ae3-87a9-be0a45ab25b2",
      "name": "Send Signed PDF via Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        112,
        0
      ],
      "parameters": {
        "sendTo": "={{ $('When Document Callback').item.json.body.action_data.email }}",
        "message": "=Hi {{ $('When Document Callback').item.json.body.action_data.first_name }},\n\nWelcome to Actual Reports! Your consent form is signed and you're all set to get started.\n\nYour signed document is attached for your records.\n\nSee you on the floor!\n\nBest Regards,\nActual Reports O\u00dc",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {
                "property": "=processed-document.pdf"
              }
            ]
          }
        },
        "subject": "Welcome to Actual Reports \u2013 you're good to go!",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "f335d8f1-7a8f-4c8a-bdec-1688237e01aa",
      "name": "Route by Document Action",
      "type": "n8n-nodes-base.switch",
      "position": [
        -672,
        208
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Signed",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5da84bd6-8b8a-40fb-9283-6f7423248f08",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.body.action_data.action }}",
                    "rightValue": "signed"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Form Submission",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2425880f-ce51-47e7-942e-60b9c63fc033",
                    "operator": {
                      "type": "string",
                      "operation": "notExists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.body.action_data }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "94c06b3e-78d3-41f4-a67b-a017c834b16d",
      "name": "Append Form Submission in Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -448,
        384
      ],
      "parameters": {
        "columns": {
          "value": {
            "City": "={{ $('When Document Callback').item.json.body.form_data.city }}",
            "Email": "={{ $('When Document Callback').item.json.body.form_data.email }}",
            "Phone": "={{ $('When Document Callback').item.json.body.form_data.phone }}",
            "Signed": "false",
            "Address": "={{ $('When Document Callback').item.json.body.form_data.address }}",
            "Full Name": "={{ $('When Document Callback').item.json.body.form_data.full_name }}",
            "Public ID": "={{ $('When Document Callback').item.json.body.meta.public_id }}",
            "Birth Date": "={{ $('When Document Callback').item.json.body.form_data.birth_date }}"
          },
          "schema": [
            {
              "id": "Full Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Full Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Birth Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Birth Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Address",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "City",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "City",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Public ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Public ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Signed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Signed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Signed At",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Signed At",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4
    },
    {
      "id": "1f324f48-7ae1-4fdf-b4d5-b0ebb471aba6",
      "name": "Store Signed PDF in Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        112,
        384
      ],
      "parameters": {
        "name": "={{ $('When Document Callback').item.json.body.action_data.first_name + ' ' + $('When Document Callback').item.json.body.action_data.last_name + ' - Fitness Consent Form.pdf' }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "inputDataFieldName": "processed-document.pdf"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "35986042-896d-48d4-8a12-95c76160add1",
      "name": "Notify Team via Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        112,
        192
      ],
      "parameters": {
        "text": "=New consent form signed!\nName: {{ $('When Document Callback').item.json.body.action_data.first_name }} {{ $('When Document Callback').item.json.body.action_data.last_name }}\nEmail: {{ $('When Document Callback').item.json.body.action_data.email }}\nDocument: {{ $('When Document Callback').item.json.body.response }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#general"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "de8e55ea-ff38-46b7-bbc2-0cf87bc472ba",
      "name": "Update Form Record in Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -448,
        192
      ],
      "parameters": {
        "columns": {
          "value": {
            "Signed": "true",
            "Public ID": "={{ $('When Document Callback').item.json.body.meta.public_id }}",
            "Signed At": "={{ $('When Document Callback').item.json.body.action_data.created_at }}",
            "row_number": 0
          },
          "schema": [
            {
              "id": "Full Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Full Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Birth Date",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Birth Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Address",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "City",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "City",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Public ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Public ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Signed",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Signed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Signed At",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Signed At",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Public ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "locationDefine": {
            "values": {}
          }
        },
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "4352505a-eaa1-4d19-a9dd-8d94904e0a09",
  "connections": {
    "Process Signed PDF": {
      "main": [
        [
          {
            "node": "Send Signed PDF via Gmail",
            "type": "main",
            "index": 0
          },
          {
            "node": "Notify Team via Slack",
            "type": "main",
            "index": 0
          },
          {
            "node": "Store Signed PDF in Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Team via Slack": {
      "main": [
        []
      ]
    },
    "When Document Callback": {
      "main": [
        [
          {
            "node": "Route by Document Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Document Action": {
      "main": [
        [
          {
            "node": "Update Form Record in Sheets",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Append Form Submission in Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Signed PDF via Gmail": {
      "main": [
        []
      ]
    },
    "Update Form Record in Sheets": {
      "main": [
        [
          {
            "node": "Process Signed PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}