协议起草与电子签名自动化
高级
这是一个Document Extraction领域的自动化工作流,包含 33 个节点。主要使用 Set, Code, Gmail, Merge, DataTable 等节点。 自动化完整协议生命周期:JotForm、审批、Signwell电子签名与跟踪
前置要求
- •Google 账号和 Gmail API 凭证
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
使用的节点 (33)
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "TWnGL7anpqfTlrTu",
"meta": {
"instanceId": "90dd23d886c9cb675f452d0fb004af6ee783e4e974ef4384cbfad1854c68a875",
"templateCredsSetupCompleted": true
},
"name": "协议起草与电子签名自动化",
"tags": [
{
"id": "ClBqgyA0LGlkvyvZ",
"name": "Contracts",
"createdAt": "2025-10-16T09:18:33.184Z",
"updatedAt": "2025-10-16T09:18:33.184Z"
},
{
"id": "ZFOFNDdsvoQ2qGKW",
"name": "Form Automation",
"createdAt": "2025-10-16T09:18:33.189Z",
"updatedAt": "2025-10-16T09:18:33.189Z"
},
{
"id": "ZUPuUVjkdgHAmXJY",
"name": "Document Generation",
"createdAt": "2025-10-16T09:18:33.178Z",
"updatedAt": "2025-10-16T09:18:33.178Z"
},
{
"id": "aXYmTJgLTE6cyQne",
"name": "Agreements",
"createdAt": "2025-10-20T04:04:41.153Z",
"updatedAt": "2025-10-20T04:04:41.153Z"
}
],
"nodes": [
{
"id": "ebc8134f-42d0-41cf-99de-61df1a74a558",
"name": "JotForm 触发器",
"type": "n8n-nodes-base.jotFormTrigger",
"position": [
-880,
-352
],
"webhookId": "c4c32e08-4686-4831-966c-7241f91b8048",
"parameters": {
"form": "252888042997475"
},
"credentials": {
"jotFormApi": {
"id": "MEZxYkQDesqbiRMw",
"name": "JotForm account"
}
},
"typeVersion": 1
},
{
"id": "d8d29e44-2dd1-4f58-9c6f-56aafb3d02b0",
"name": "获取清洁文档 URL",
"type": "n8n-nodes-base.set",
"position": [
-64,
-352
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "f10e836d-09ee-4fed-93bd-548c0e6ac685",
"name": "documentUrl",
"type": "string",
"value": "=https://docs.google.com/document/d/{{ $json.documentId }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "58107ec8-d271-446e-9265-af7597678714",
"name": "分享邮件草稿",
"type": "n8n-nodes-base.gmail",
"position": [
144,
-224
],
"webhookId": "f7e31863-b041-4ea2-bd2d-12a16654e17f",
"parameters": {
"sendTo": "YOUR_EMAIL_ADDRESS",
"message": "=Hi – your agreement composer here emailing on behalf of you...\n<br><br>\nThe draft digital services agreement for <b>{{ $('Edit Fields').item.json.clientCompanyName }}</b> is ready for your review: {{ $json.documentUrl }}.\n<br><br>\nOnce you are happy with it, simply reply <b>Approved</b> so that I can continue the process. Otherwise, you can edit the draft as required, and then reply 'Approved' after so that I can continue the same process.\n<br><br>\n<em>Please note, the agreement will be sent for signing to <b>{{ $('Edit Fields').item.json.clientFullName }}</b> ({{ $('Edit Fields').item.json.clientEmail }}).</em>\n<br><br>\nThanks!",
"options": {
"senderName": "Your Agreement Composer",
"appendAttribution": false
},
"subject": "=Approval Request: Draft - {{ $('Copy and Rename File').item.json.name }}"
},
"credentials": {
"gmailOAuth2": {
"id": "51mlyK2w5LA9QaKi",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "300eec85-1d70-486a-b596-5f9e38f6f6b4",
"name": "获取简报",
"type": "n8n-nodes-base.set",
"position": [
-672,
-352
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "5eaad570-e75d-4a35-8811-7f88c7a5afe7",
"name": "clientCompanyName",
"type": "string",
"value": "={{ $json['Company Name'] }}"
},
{
"id": "7136a740-0ea6-449d-a4ea-269ff1455d18",
"name": "clientCompanyAddress",
"type": "string",
"value": "={{ (() => {\n const a = $json['Company Address'] ?? {};\n const parts = [a.addr_line1, a.addr_line2, a.city, a.state, a.postal, a.country]\n .map(v => (typeof v === 'string' ? v.trim() : v))\n .filter(v => v); // drops empty/undefined\n\n return parts.join(', ');\n})() }}"
},
{
"id": "3947ba78-0d19-44df-8b0a-53302a7a0b31",
"name": "clientFullName",
"type": "string",
"value": "={{ $json[\"Full Name\"].first }} {{ $json[\"Full Name\"].last }}"
},
{
"id": "d07cb3d5-ff59-4984-bf3d-a83b8fcba9cb",
"name": "ClientNamePosition",
"type": "string",
"value": "={{ $json[\"Your Position / Job Title\"] }}"
},
{
"id": "7b28296d-5c19-4ca8-b77b-f8d0d83dedb9",
"name": "clientEmail",
"type": "string",
"value": "={{ $json.Email }}"
},
{
"id": "efc5cdb0-49eb-451f-acea-df916982d05a",
"name": "formCompletedDate",
"type": "string",
"value": "={{ $now.format('yyyy-MM-dd') }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "65107954-9e06-47dd-9199-e4c34182f36a",
"name": "复制并重命名文件",
"type": "n8n-nodes-base.googleDrive",
"position": [
-464,
-352
],
"parameters": {
"name": "=Digital Services Agreement - {{ $json.clientCompanyName }} - {{ $json.formCompletedDate }} - Ref-{{ new Date().toISOString().replace(/[-T:.Z]/g, '') }}",
"fileId": {
"__rl": true,
"mode": "list",
"value": "1Nz2sAkDiIxMylzec7vNqOwjP2RRIeV8VOip4UWh2JD8",
"cachedResultUrl": "https://docs.google.com/document/d/1Nz2sAkDiIxMylzec7vNqOwjP2RRIeV8VOip4UWh2JD8/edit?usp=drivesdk",
"cachedResultName": "Digital Services Agreement - {{clientCompanyName}} - {{currentDate}}"
},
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1DNTyDTLimYYpG6Oj_DxSfaw9yx-S43rH",
"cachedResultUrl": "https://drive.google.com/drive/folders/1DNTyDTLimYYpG6Oj_DxSfaw9yx-S43rH",
"cachedResultName": "Services Agreements - Drafts"
},
"operation": "copy",
"sameFolder": false
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "IjoB5flCkLlcfjdH",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "731dc0a8-e40d-4ccb-baf4-8aa14cb6e543",
"name": "更新新文件",
"type": "n8n-nodes-base.googleDocs",
"position": [
-256,
-352
],
"parameters": {
"simple": false,
"actionsUi": {
"actionFields": [
{
"text": "{{clientCompanyName}}",
"action": "replaceAll",
"replaceText": "={{ $('Edit Fields').item.json.clientCompanyName }}"
},
{
"text": "{{clientFullName}}",
"action": "replaceAll",
"replaceText": "={{ $('Edit Fields').item.json.clientFullName }}"
},
{
"text": "{{clientNamePosition}}",
"action": "replaceAll",
"replaceText": "={{ $('Edit Fields').item.json.ClientNamePosition }}"
},
{
"text": "{{clientCompanyAddress}}",
"action": "replaceAll",
"replaceText": "={{ $('Edit Fields').item.json.clientCompanyAddress }}"
},
{
"text": "{{agreementDate1}}",
"action": "replaceAll",
"replaceText": "={{ new Date($('Edit Fields').item.json.formCompletedDate).toLocaleDateString('en-US', { month:'long', day:'numeric', year:'numeric' }) }}"
},
{
"text": "{{agreementDate2}}",
"action": "replaceAll",
"replaceText": "={{ new Date($('Edit Fields').item.json.formCompletedDate).toLocaleDateString('en-US', { month:'short', day:'numeric', year:'numeric' }) }}"
}
]
},
"operation": "update",
"documentURL": "={{ $json.id }}"
},
"credentials": {
"googleDocsOAuth2Api": {
"id": "lJWyEbBbmTlTRv3x",
"name": "Google Docs account"
}
},
"typeVersion": 2,
"alwaysOutputData": true
},
{
"id": "13d43194-f2a6-466e-a587-97f3752f0bed",
"name": "获取相关协议记录",
"type": "n8n-nodes-base.dataTable",
"position": [
-640,
128
],
"parameters": {
"limit": 1,
"filters": {
"conditions": [
{
"keyName": "documentFileName",
"keyValue": "={{ (() => {\n const s = ($json.Subject ?? '').toString();\n const m = s.match(/Digital Services Agreement.*$/i);\n return m ? m[0].trim() : s;\n})() }}"
}
]
},
"operation": "get",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "7q3kikjopVGUGQgQ",
"cachedResultUrl": "/projects/7FLBLfPJX4Uw0i6f/datatables/7q3kikjopVGUGQgQ",
"cachedResultName": "Services Agreements"
}
},
"executeOnce": false,
"typeVersion": 1
},
{
"id": "c4fbf446-5a2e-4ece-80e3-af4ee341a23a",
"name": "检查邮件批准状态",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-880,
128
],
"parameters": {
"filters": {
"q": "from:@YOUR_EMAIL_DOMAIN \"Re: Approval Request: Draft\" \"Approved\" ",
"labelIds": [
"Label_1461057032612050483"
]
},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "51mlyK2w5LA9QaKi",
"name": "Gmail account"
}
},
"typeVersion": 1.2
},
{
"id": "2fa4037a-3f10-48db-ba88-9da006d0ecf6",
"name": "下载文件为 PDF",
"type": "n8n-nodes-base.googleDrive",
"position": [
-432,
128
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "url",
"value": "={{ $json.documentUrl }}"
},
"options": {
"binaryPropertyName": "downloadedPdfFile",
"googleFileConversion": {
"conversion": {
"docsToFormat": "application/pdf"
}
}
},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "IjoB5flCkLlcfjdH",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "ab82861a-b78b-44f2-8c91-77418777f4c2",
"name": "上传 PDF 文件",
"type": "n8n-nodes-base.googleDrive",
"position": [
-208,
128
],
"parameters": {
"name": "={{ $json.documentFileName }}",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1DNTyDTLimYYpG6Oj_DxSfaw9yx-S43rH",
"cachedResultUrl": "https://drive.google.com/drive/folders/1DNTyDTLimYYpG6Oj_DxSfaw9yx-S43rH",
"cachedResultName": "Services Agreements - Drafts"
},
"inputDataFieldName": "=downloadedPdfFile"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "IjoB5flCkLlcfjdH",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "13e7027a-a84d-4619-8e25-4cbdd87d1fd0",
"name": "在 Signwell 中创建文档",
"type": "n8n-nodes-base.httpRequest",
"position": [
224,
128
],
"parameters": {
"url": "https://www.signwell.com/api/v1/documents/",
"method": "POST",
"options": {},
"jsonBody": "={\n \"test_mode\": true,\n \"draft\": false,\n \"with_signature_page\": false,\n \"reminders\": false,\n \"apply_signing_order\": false,\n \"embedded_signing\": true,\n \"embedded_signing_notifications\": true,\n \"text_tags\": false,\n \"allow_decline\": true,\n \"allow_reassign\": true,\n \"files\": [\n {\n \"name\": \"{{ $('Upload PDF File').item.json.name }}.pdf\",\n \"file_url\": \"https://drive.google.com/uc?export=download&id={{ $('Upload PDF File').item.json.id }}\"\n }\n ],\n \"recipients\": [\n {\n \"send_email\": false,\n \"send_email_delay\": 0,\n \"id\": \"1\",\n \"name\": \"{{ $('Get Relevant Agreement Record').item.json.clientFullName }}\",\n \"email\": \"{{ $('Get Relevant Agreement Record').item.json.clientEmail }}\"\n }\n ],\n \"fields\": [\n [\n {\n \"type\": \"signature\",\n \"required\": true,\n \"fixed_width\": false,\n \"lock_sign_date\": false,\n \"x\": 140,\n \"y\": 527,\n \"page\": 2,\n \"recipient_id\": \"1\",\n \"height\": \"40.0\",\n \"width\": \"200.0\"\n },\n {\n \"type\": \"date\",\n \"required\": true,\n \"fixed_width\": false,\n \"lock_sign_date\": true,\n \"x\": 100,\n \"y\": 588,\n \"page\": 2,\n \"recipient_id\": \"1\",\n \"date_format\": \"Month DD, YYYY\"\n }\n ]\n ]\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "X-Api-Key",
"value": "YOUR_SIGNWELL_API_KEY"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "776c7399-727c-4a96-a09b-748ebf486364",
"name": "向客户发送准备好的协议",
"type": "n8n-nodes-base.gmail",
"position": [
544,
432
],
"webhookId": "96aa5fa2-dfd3-46b1-b831-400093f55b46",
"parameters": {
"sendTo": "={{ $json.recipients[0].email }}",
"message": "=Hi {{ $json.recipients[0].name.split(\" \")[0] }},\n<br><br>\nThanks for the conversations so far regarding the engagement.\n<br><br>\nAs discussed, please find the Services Agreement for your review and e-signing: <b>{{ $json.recipients[0].embedded_signing_url }}</b>.\n<br><br>\nThanks,<br>\nYOUR NAME",
"options": {
"senderName": "YOUR NAME OR COMPANY NAME",
"appendAttribution": false
},
"subject": "=Please Review and Sign: {{ $json.name }}"
},
"credentials": {
"gmailOAuth2": {
"id": "51mlyK2w5LA9QaKi",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "a390b505-acee-4f18-9919-9bf512d3afd9",
"name": "更新行 - 批准状态",
"type": "n8n-nodes-base.dataTable",
"position": [
-432,
336
],
"parameters": {
"columns": {
"value": {
"approvalStatus": "Approved"
},
"schema": [
{
"id": "documentFileName",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "documentFileName",
"defaultMatch": false
},
{
"id": "clientEmail",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientEmail",
"defaultMatch": false
},
{
"id": "clientFullName",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientFullName",
"defaultMatch": false
},
{
"id": "clientNamePosition",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientNamePosition",
"defaultMatch": false
},
{
"id": "clientCompanyName",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientCompanyName",
"defaultMatch": false
},
{
"id": "clientCompanyAddress",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientCompanyAddress",
"defaultMatch": false
},
{
"id": "documentUrl",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "documentUrl",
"defaultMatch": false
},
{
"id": "approvalStatus",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "approvalStatus",
"defaultMatch": false
},
{
"id": "sentDocumentPdfUrl",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "sentDocumentPdfUrl",
"defaultMatch": false
},
{
"id": "sentDate",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "sentDate",
"defaultMatch": false
},
{
"id": "signwellUrl",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "signwellUrl",
"defaultMatch": false
},
{
"id": "docSigned",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "docSigned",
"defaultMatch": false
},
{
"id": "finalExecutedDocGDrive",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "finalExecutedDocGDrive",
"defaultMatch": false
},
{
"id": "finalExecutedDocSignwellUrl",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "finalExecutedDocSignwellUrl",
"defaultMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"filters": {
"conditions": [
{
"keyValue": "={{ $json.id }}"
}
]
},
"options": {},
"operation": "update",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "7q3kikjopVGUGQgQ",
"cachedResultUrl": "/projects/7FLBLfPJX4Uw0i6f/datatables/7q3kikjopVGUGQgQ",
"cachedResultName": "Services Agreements"
}
},
"typeVersion": 1
},
{
"id": "e3d74ab8-44ef-4dd2-ade0-dbe942af78d3",
"name": "更新行 - 附加文档详情",
"type": "n8n-nodes-base.dataTable",
"position": [
544,
80
],
"parameters": {
"columns": {
"value": {
"sentDate": "={{ $('Create Document in Signwell').item.json.created_at }}",
"signwellUrl": "={{ $('Create Document in Signwell').item.json.recipients[0].embedded_signing_url }}",
"signwellDocID": "={{ $json.id }}",
"sentDocumentPdfUrl": "={{ $('Upload PDF File').item.json.webViewLink }}"
},
"schema": [
{
"id": "documentFileName",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "documentFileName",
"defaultMatch": false
},
{
"id": "clientEmail",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientEmail",
"defaultMatch": false
},
{
"id": "clientFullName",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientFullName",
"defaultMatch": false
},
{
"id": "clientNamePosition",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientNamePosition",
"defaultMatch": false
},
{
"id": "clientCompanyName",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientCompanyName",
"defaultMatch": false
},
{
"id": "clientCompanyAddress",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientCompanyAddress",
"defaultMatch": false
},
{
"id": "documentUrl",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "documentUrl",
"defaultMatch": false
},
{
"id": "approvalStatus",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "approvalStatus",
"defaultMatch": false
},
{
"id": "sentDocumentPdfUrl",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "sentDocumentPdfUrl",
"defaultMatch": false
},
{
"id": "sentDate",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "sentDate",
"defaultMatch": false
},
{
"id": "signwellUrl",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "signwellUrl",
"defaultMatch": false
},
{
"id": "docSigned",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "docSigned",
"defaultMatch": false
},
{
"id": "finalExecutedDocGDrive",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "finalExecutedDocGDrive",
"defaultMatch": false
},
{
"id": "finalExecutedDocSignwellUrl",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "finalExecutedDocSignwellUrl",
"defaultMatch": false
},
{
"id": "signwellDocID",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "signwellDocID",
"defaultMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"filters": {
"conditions": [
{
"keyValue": "={{ $('Get Relevant Agreement Record').item.json.id }}"
}
]
},
"options": {},
"operation": "update",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "7q3kikjopVGUGQgQ",
"cachedResultUrl": "/projects/7FLBLfPJX4Uw0i6f/datatables/7q3kikjopVGUGQgQ",
"cachedResultName": "Services Agreements"
}
},
"typeVersion": 1
},
{
"id": "b926ab5b-99ba-4400-9726-ca7ccc8bd9ef",
"name": "授予 PDF 文件共享访问权限",
"type": "n8n-nodes-base.googleDrive",
"position": [
0,
128
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"options": {},
"operation": "share",
"permissionsUi": {
"permissionsValues": {
"role": "reader",
"type": "anyone"
}
}
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "IjoB5flCkLlcfjdH",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "26ceb85f-ea7d-4b06-9739-5295f2ebdb70",
"name": "移除 PDF 文件共享访问权限",
"type": "n8n-nodes-base.httpRequest",
"position": [
544,
256
],
"parameters": {
"url": "=https://www.googleapis.com/drive/v3/files/{{ $('Upload PDF File').item.json.id }}/permissions/anyoneWithLink",
"method": "DELETE",
"options": {},
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googleDriveOAuth2Api"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "IjoB5flCkLlcfjdH",
"name": "Google Drive account"
}
},
"typeVersion": 4.2
},
{
"id": "5ca86907-f3f4-473f-ad9c-a172f7e17079",
"name": "提取完整邮件线程 - 已完成文档 URL",
"type": "n8n-nodes-base.gmail",
"position": [
-640,
816
],
"webhookId": "2569cc53-b873-438f-b4ae-060bee204b92",
"parameters": {
"simple": false,
"options": {},
"resource": "thread",
"threadId": "={{ $json.threadId }}",
"operation": "get"
},
"credentials": {
"gmailOAuth2": {
"id": "51mlyK2w5LA9QaKi",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "0236fb26-b121-4874-ace9-7976f82df4ba",
"name": "获取 Signwell 已完成文档 URL + 数据",
"type": "n8n-nodes-base.code",
"position": [
-400,
816
],
"parameters": {
"jsCode": "// Robust SignWell link extractor for a Gmail thread item\n\nconst msgs = $json.messages || ($json.payload ? [$json] : []);\nconst out = { decodedText: '', downloadLink: '', extractedFilename: '' };\n\n// helpers\nfunction b64urlDecode(s = '') {\n s = s.replace(/-/g, '+').replace(/_/g, '/');\n while (s.length % 4) s += '=';\n return Buffer.from(s, 'base64').toString('utf8');\n}\nfunction qpDecode(s = '') {\n // remove soft line breaks and decode =XX\n return s.replace(/=\\r?\\n/g, '').replace(/=([A-Fa-f0-9]{2})/g, (_, h) => String.fromCharCode(parseInt(h, 16)));\n}\nfunction partText(part) {\n if (!part?.body?.data) return '';\n let s = b64urlDecode(part.body.data);\n const isQP = (part.headers || []).some(h => /Content-Transfer-Encoding/i.test(h.name) && /quoted-printable/i.test(h.value));\n if (isQP) s = qpDecode(s);\n return s;\n}\nfunction findFirstLinkInParts(p) {\n if (!p) return null;\n // prefer text/plain, then text/html\n if (/^text\\//i.test(p.mimeType)) {\n const s = partText(p);\n const m = s.match(/https:\\/\\/www\\.signwell\\.com\\/app\\/signed\\/[^\\s\"'()<>]+/i);\n if (m) return m[0].replace(/[.)]+$/, ''); // strip trailing punctuation\n }\n for (const child of (p.parts || [])) {\n const found = findFirstLinkInParts(child);\n if (found) return found;\n }\n return null;\n}\nfunction findPlainText(p) {\n if (!p) return '';\n if (p.mimeType === 'text/plain') return partText(p);\n for (const child of (p.parts || [])) {\n const s = findPlainText(child);\n if (s) return s;\n }\n return '';\n}\n\n// process first message in thread\nfor (const m of msgs) {\n // Subject can be top-level or in headers\n const subject = m.Subject || m.subject ||\n (m.payload?.headers || []).find(h => h.name === 'Subject')?.value || '';\n const nameMatch = subject.match(/\\(([^)]+)\\)/);\n if (nameMatch) out.extractedFilename = nameMatch[1].replace(/\\.pdf$/i, '');\n\n out.downloadLink = findFirstLinkInParts(m.payload) || '';\n out.decodedText = findPlainText(m.payload) || '';\n break;\n}\n\nreturn [{ json: out }];\n"
},
"typeVersion": 2
},
{
"id": "1b0a1605-2c44-4bcf-b728-643be7d8655c",
"name": "从 Signwell 下载已完成文档",
"type": "n8n-nodes-base.httpRequest",
"position": [
-144,
816
],
"parameters": {
"url": "={{ $json.downloadLink }}",
"options": {
"response": {
"response": {
"responseFormat": "file",
"outputPropertyName": "finalExecutedDocGDrive"
}
}
}
},
"typeVersion": 4.2
},
{
"id": "d8a87424-131d-4eb1-b385-0b1ec209ef6d",
"name": "上传已完成文档",
"type": "n8n-nodes-base.googleDrive",
"position": [
96,
928
],
"parameters": {
"name": "={{ $node['Get Signwell Completed Doc URL + Data'].json['extractedFilename'] }}_SIGNED.pdf",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {},
"folderId": {
"__rl": true,
"mode": "list",
"value": "1hRcXphNp4YPFaBzJOj86w2im4Pv5jH4H",
"cachedResultUrl": "https://drive.google.com/drive/folders/1hRcXphNp4YPFaBzJOj86w2im4Pv5jH4H",
"cachedResultName": "Services Agreements - Final Versions"
},
"inputDataFieldName": "finalExecutedDocGDrive"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "IjoB5flCkLlcfjdH",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "250db16b-8cf8-438c-b2ca-cf2e53a5a136",
"name": "检查邮件中的完成通知",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-896,
816
],
"parameters": {
"filters": {
"q": "from:signwelldocs@signwell.com \"document completed (digital services agreement\" ",
"labelIds": [
"Label_572888736126663916"
]
},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "51mlyK2w5LA9QaKi",
"name": "Gmail account"
}
},
"typeVersion": 1.2
},
{
"id": "4daba244-542c-41c4-85ee-0c76cb12c4ea",
"name": "获取相关协议记录2",
"type": "n8n-nodes-base.dataTable",
"position": [
320,
928
],
"parameters": {
"limit": 1,
"filters": {
"conditions": [
{
"keyName": "documentFileName",
"keyValue": "={{ $('Download Completed Doc from Signwell').item.json.extractedFilename }}"
}
]
},
"operation": "get",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "7q3kikjopVGUGQgQ",
"cachedResultUrl": "/projects/7FLBLfPJX4Uw0i6f/datatables/7q3kikjopVGUGQgQ",
"cachedResultName": "Services Agreements"
}
},
"executeOnce": false,
"typeVersion": 1
},
{
"id": "975619f1-0546-44b5-827e-81871649b273",
"name": "更新行 - 已完成文档详情",
"type": "n8n-nodes-base.dataTable",
"position": [
544,
1024
],
"parameters": {
"columns": {
"value": {
"docSigned": "Yes",
"finalExecutedDocGDrive": "={{ $('Upload Completed Doc').item.json.webContentLink }}",
"finalExecutedDocSignwellUrl": "={{ $('Download Completed Doc from Signwell').item.json.downloadLink }}"
},
"schema": [
{
"id": "documentFileName",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "documentFileName",
"defaultMatch": false
},
{
"id": "clientEmail",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientEmail",
"defaultMatch": false
},
{
"id": "clientFullName",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientFullName",
"defaultMatch": false
},
{
"id": "clientNamePosition",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientNamePosition",
"defaultMatch": false
},
{
"id": "clientCompanyName",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientCompanyName",
"defaultMatch": false
},
{
"id": "clientCompanyAddress",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "clientCompanyAddress",
"defaultMatch": false
},
{
"id": "documentUrl",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "documentUrl",
"defaultMatch": false
},
{
"id": "approvalStatus",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "approvalStatus",
"defaultMatch": false
},
{
"id": "sentDocumentPdfUrl",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "sentDocumentPdfUrl",
"defaultMatch": false
},
{
"id": "sentDate",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "sentDate",
"defaultMatch": false
},
{
"id": "signwellUrl",
"type": "string",
"display": true,
"removed": true,
"readOnly": false,
"required": false,
"displayName": "signwellUrl",
"defaultMatch": false
},
{
"id": "docSigned",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "docSigned",
"defaultMatch": false
},
{
"id": "finalExecutedDocGDrive",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "finalExecutedDocGDrive",
"defaultMatch": false
},
{
"id": "finalExecutedDocSignwellUrl",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "finalExecutedDocSignwellUrl",
"defaultMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"filters": {
"conditions": [
{
"keyValue": "={{ $json.id }}"
}
]
},
"options": {},
"operation": "update",
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "7q3kikjopVGUGQgQ",
"cachedResultUrl": "/projects/7FLBLfPJX4Uw0i6f/datatables/7q3kikjopVGUGQgQ",
"cachedResultName": "Services Agreements"
}
},
"typeVersion": 1
},
{
"id": "c3005f01-30b9-4f42-943b-b8371ae9adf7",
"name": "从 Signwell 移除已完成文档",
"type": "n8n-nodes-base.httpRequest",
"position": [
784,
1024
],
"parameters": {
"url": "=https://www.signwell.com/api/v1/documents/{{ $json.signwellDocID }}",
"method": "DELETE",
"options": {},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "X-Api-Key",
"value": "YOUR_SIGNWELL_API_KEY"
},
{
"name": "accept",
"value": "application/json"
}
]
}
},
"typeVersion": 4.2
},
{
"id": "1bdc96ce-bc11-41cb-9525-c9f1abc5ef80",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-992,
-464
],
"parameters": {
"color": 5,
"width": 1392,
"height": 432,
"content": "## 获取客户表单输入 > 创建 + 发送协议草稿(内部)"
},
"typeVersion": 1
},
{
"id": "5dab0894-c4e7-41cd-9404-de4051b5259c",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-992,
0
],
"parameters": {
"color": 2,
"width": 1808,
"height": 656,
"content": "## 获取内部批准 > 创建 Signwell 文档 > 向客户发送协议"
},
"typeVersion": 1
},
{
"id": "06ab07cd-6660-44aa-ac46-f4c15cf37cfc",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-992,
688
],
"parameters": {
"color": 4,
"width": 2080,
"height": 544,
"content": "## 获取已完成的 Signwell 文档通知 > 下载并存储已完成的协议 > 与客户共享"
},
"typeVersion": 1
},
{
"id": "7ca36348-ef27-44b4-96f0-64bc12f08172",
"name": "合并数据",
"type": "n8n-nodes-base.merge",
"position": [
544,
832
],
"parameters": {
"mode": "combine",
"options": {},
"combineBy": "combineByPosition"
},
"typeVersion": 3.1
},
{
"id": "0fdb0538-ab98-41bf-9d7e-226f16d62a93",
"name": "向客户发送已完成的协议 PDF",
"type": "n8n-nodes-base.gmail",
"position": [
784,
832
],
"webhookId": "d39932e5-037b-499f-a277-d77e42d52045",
"parameters": {
"sendTo": "={{ $json.clientEmail }}",
"message": "=Hi {{ (() => {\n const raw = ($json.clientFullName?.name ?? $json.clientFullName ?? '').toString();\n const first = raw.trim().replace(/\\s+/g, ' ').split(' ')[0] || '';\n return first; // \"John\" or \"John-Boy\"\n})() }},\n<br><br>\nPlease find attached the fully signed agreement.\n<br><br>\nThanks,\n<br>\nYOUR NAME",
"options": {
"senderName": "YOUR NAME OR COMPANY NAME",
"attachmentsUi": {
"attachmentsBinary": [
{
"property": "finalExecutedDocGDrive"
}
]
},
"appendAttribution": false
},
"subject": "=Signed Agreement Copy ({{ $json.documentFileName }})\n"
},
"credentials": {
"gmailOAuth2": {
"id": "51mlyK2w5LA9QaKi",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "2084e233-a3a2-4fcb-b55b-a4a4757ce165",
"name": "插入新行",
"type": "n8n-nodes-base.dataTable",
"position": [
144,
-384
],
"parameters": {
"columns": {
"value": {
"clientEmail": "={{ $('Edit Fields').item.json.clientEmail }}",
"documentUrl": "={{ $json.documentUrl }}",
"clientFullName": "={{ $('Edit Fields').item.json.clientFullName }}",
"documentFileName": "={{ $('Copy and Rename File').item.json.name }}",
"clientCompanyName": "={{ $('Edit Fields').item.json.clientCompanyName }}",
"clientNamePosition": "={{ $('Edit Fields').item.json.ClientNamePosition }}",
"clientCompanyAddress": "={{ $('Edit Fields').item.json.clientCompanyAddress }}"
},
"schema": [
{
"id": "documentFileName",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "documentFileName",
"defaultMatch": false
},
{
"id": "clientEmail",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "clientEmail",
"defaultMatch": false
},
{
"id": "clientFullName",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "clientFullName",
"defaultMatch": false
},
{
"id": "clientNamePosition",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "clientNamePosition",
"defaultMatch": false
},
{
"id": "clientCompanyName",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "clientCompanyName",
"defaultMatch": false
},
{
"id": "clientCompanyAddress",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "clientCompanyAddress",
"defaultMatch": false
},
{
"id": "documentUrl",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "documentUrl",
"defaultMatch": false
},
{
"id": "approvalStatus",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "approvalStatus",
"defaultMatch": false
},
{
"id": "sentDocumentPdfUrl",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "sentDocumentPdfUrl",
"defaultMatch": false
},
{
"id": "sentDate",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "sentDate",
"defaultMatch": false
},
{
"id": "signwellUrl",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "signwellUrl",
"defaultMatch": false
},
{
"id": "docSigned",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "docSigned",
"defaultMatch": false
},
{
"id": "finalExecutedDocGDrive",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "finalExecutedDocGDrive",
"defaultMatch": false
},
{
"id": "finalExecutedDocSignwellUrl",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "finalExecutedDocSignwellUrl",
"defaultMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"dataTableId": {
"__rl": true,
"mode": "list",
"value": "7q3kikjopVGUGQgQ",
"cachedResultUrl": "/projects/7FLBLfPJX4Uw0i6f/datatables/7q3kikjopVGUGQgQ",
"cachedResultName": "Services Agreements"
}
},
"typeVersion": 1
},
{
"id": "30a27a9e-2c98-4b70-b320-9c260cad1a76",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2032,
-976
],
"parameters": {
"color": 7,
"width": 1008,
"height": 2032,
"content": "# **协议起草与电子签名自动化**"
},
"typeVersion": 1
},
{
"id": "3a637b50-3438-4a8a-994e-d9223a1c8d75",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
-992,
-976
],
"parameters": {
"color": 7,
"width": 896,
"height": 480,
"content": "## 快速故障排除"
},
"typeVersion": 1
},
{
"id": "81473db5-2e22-46cf-8916-50272872e083",
"name": "便签 5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-64,
-1200
],
"parameters": {
"color": 7,
"width": 800,
"height": 704,
"content": "## 示例输出"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "786fdb22-129f-423a-b7fb-8f54bf4f95c2",
"connections": {
"Merge Data": {
"main": [
[
{
"node": "Send Client Completed Agreement PDF",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Copy and Rename File",
"type": "main",
"index": 0
}
]
]
},
"Insert New Row": {
"main": [
[]
]
},
"JotForm Trigger": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Update New File": {
"main": [
[
{
"node": "Get Clean Doc URL",
"type": "main",
"index": 0
}
]
]
},
"Upload PDF File": {
"main": [
[
{
"node": "Grant Sharing Access to PDF File",
"type": "main",
"index": 0
}
]
]
},
"Get Clean Doc URL": {
"main": [
[
{
"node": "Share Email Draft",
"type": "main",
"index": 0
},
{
"node": "Insert New Row",
"type": "main",
"index": 0
}
]
]
},
"Share Email Draft": {
"main": [
[]
]
},
"Copy and Rename File": {
"main": [
[
{
"node": "Update New File",
"type": "main",
"index": 0
}
]
]
},
"Download File as PDF": {
"main": [
[
{
"node": "Upload PDF File",
"type": "main",
"index": 0
}
]
]
},
"Upload Completed Doc": {
"main": [
[
{
"node": "Get Relevant Agreement Record2",
"type": "main",
"index": 0
}
]
]
},
"Check for Email Approval": {
"main": [
[
{
"node": "Get Relevant Agreement Record",
"type": "main",
"index": 0
}
]
]
},
"Create Document in Signwell": {
"main": [
[
{
"node": "Send Prepared Agreement to Client",
"type": "main",
"index": 0
},
{
"node": "Remove Sharing Access to PDF File",
"type": "main",
"index": 0
},
{
"node": "Update Row - Additional Doc Details",
"type": "main",
"index": 0
}
]
]
},
"Update Row - Approval Status": {
"main": [
[]
]
},
"Get Relevant Agreement Record": {
"main": [
[
{
"node": "Update Row - Approval Status",
"type": "main",
"index": 0
},
{
"node": "Download File as PDF",
"type": "main",
"index": 0
}
]
]
},
"Get Relevant Agreement Record2": {
"main": [
[
{
"node": "Update Row - Completed Doc Details",
"type": "main",
"index": 0
},
{
"node": "Merge Data",
"type": "main",
"index": 1
}
]
]
},
"Grant Sharing Access to PDF File": {
"main": [
[
{
"node": "Create Document in Signwell",
"type": "main",
"index": 0
}
]
]
},
"Remove Sharing Access to PDF File": {
"main": [
[]
]
},
"Send Prepared Agreement to Client": {
"main": [
[]
]
},
"Update Row - Completed Doc Details": {
"main": [
[
{
"node": "Remove Completed Doc from Signwell",
"type": "main",
"index": 0
}
]
]
},
"Download Completed Doc from Signwell": {
"main": [
[
{
"node": "Upload Completed Doc",
"type": "main",
"index": 0
},
{
"node": "Merge Data",
"type": "main",
"index": 0
}
]
]
},
"Get Signwell Completed Doc URL + Data": {
"main": [
[
{
"node": "Download Completed Doc from Signwell",
"type": "main",
"index": 0
}
]
]
},
"Check Email for Completed Notification": {
"main": [
[
{
"node": "Extract Full Email Thread - Completed Doc URL",
"type": "main",
"index": 0
}
]
]
},
"Extract Full Email Thread - Completed Doc URL": {
"main": [
[
{
"node": "Get Signwell Completed Doc URL + Data",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 文档提取
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
第一轮快速通道AI招聘助手
通过Gemini AI分析从Gmail到Slack和Google Sheets的快速简历筛选
If
Set
Code
+15
50 节点Dean Pike
AI医疗报告生成器
使用Gemini AI和Google Workspace从电子邮件生成医疗报告
Set
Code
Gmail
+8
21 节点Abdullah Alshiekh
文档提取
第一轮 Telegram 和 LinkedIn 快速通道 AI 招聘助手
AI候选人筛选流程:LinkedIn到Telegram,集成Gemini与Apify
If
Set
Code
+15
55 节点Dean Pike
人力资源
研讨会证书预颁发系统
自动化研讨会证书系统,集成 JotForm、邮件验证和 Google Workspace
If
Code
Gmail
+8
24 节点Jitesh Dugar
文档提取
✨🩷自动化社交媒体内容发布工厂 + 系统提示组合
基于动态系统提示和GPT-4o的AI驱动多平台社交媒体内容工厂
If
Set
Code
+20
100 节点Amit Mehta
内容创作
转录评估器
使用DeepGram和GPT-4o的音频对话分析与可视化
Set
Code
Html
+15
54 节点RealSimple Solutions
人工智能
工作流信息
难度等级
高级
节点数量33
分类1
节点类型11
作者
Dean Pike
@deanjpSaving 20+ hours weekly for growing companies by putting their client-facing and back-office operations on autopilot. As the Founder of TidyCurve, we build AI agents and workflow automations that replace critical repetitive work: from lead generation and customer support, to marketing, recruitment, and onboarding. We deploy scalable solutions in 4-8 weeks at a fraction of enterprise costs - backed by a 60-day 3x ROI guarantee.
外部链接
在 n8n.io 查看 →
分享此工作流