{
  "id": "ASwWItOn7uLqwkZl",
  "name": "Contract Template Generator with E-Signature Integration",
  "tags": [],
  "nodes": [
    {
      "id": "ce89136e-5810-4f42-b2a6-6ce919081de1",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -336
      ],
      "parameters": {
        "width": 340,
        "height": 420,
        "content": "## Contract Template Generator with E-Signature Integration\n\n### Overview\nAutomatically generates customized contract documents based on client requirements, uses AI to suggest optimal terms, and integrates with electronic signature services for seamless contract execution.\n\n### Key Features\n- **AI-Powered Contract Customization**: Intelligent clause suggestions based on contract type\n- **Markdown to HTML Conversion**: Professional document formatting\n- **Wait for Signature Webhook**: Pauses workflow until document is signed\n- **Multi-Party Signature Support**: Handles multiple signatories\n\n### Required Credentials\n- OpenAI API\n- E-Signature Service API (DocuSign/HelloSign)\n- SMTP/Gmail for notifications"
      },
      "typeVersion": 1
    },
    {
      "id": "004d7bf0-f75b-4567-841e-dea81f165245",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 280,
        "height": 524,
        "content": "### Step 1: Contract Request Intake\n- Receives contract request via webhook\n- Validates required fields (contract type, parties, terms)\n- Generates unique contract ID for tracking"
      },
      "typeVersion": 1
    },
    {
      "id": "f518c643-e7fa-4498-accc-f145fb71dd1c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 460,
        "height": 672,
        "content": "### Step 2: AI Contract Generation\n- Routes to appropriate template by contract type\n- AI Agent analyzes contract requirements\n- Suggests optimal terms and clauses\n- Generates Markdown-formatted contract draft"
      },
      "typeVersion": 1
    },
    {
      "id": "6f4e6192-9d2e-4dd8-a7da-6ed742c47b4a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1184,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 420,
        "height": 684,
        "content": "### Step 3: Document Processing & Signature Request\n- Converts Markdown to HTML for professional formatting\n- Sends document to e-signature service\n- Uses Wait node to pause until signature webhook received"
      },
      "typeVersion": 1
    },
    {
      "id": "53e93fbf-dd03-4c7d-b165-2f3b72eeeba1",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1824,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 576,
        "content": "### Step 4: Completion & Notification\n- Processes signature confirmation from webhook\n- Logs completed contract details to Google Sheets\n- Sends confirmation emails to all parties\n- Handles expired/pending signature scenarios"
      },
      "typeVersion": 1
    },
    {
      "id": "f23b334c-1139-45aa-9eff-0a8087cb2a10",
      "name": "Contract Request Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        48,
        208
      ],
      "parameters": {
        "path": "contract-request",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "f0acca3d-f5df-475d-888d-14e80f373b49",
      "name": "Validate Contract Request",
      "type": "n8n-nodes-base.if",
      "position": [
        272,
        208
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "check-type",
              "operator": {
                "type": "string",
                "operation": "exists"
              },
              "leftValue": "={{ $json.body.contractType }}",
              "rightValue": ""
            },
            {
              "id": "check-parties",
              "operator": {
                "type": "array",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.body.parties }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "1e3be390-afc2-4326-9b55-b5150ffb5465",
      "name": "Invalid Request Response",
      "type": "n8n-nodes-base.set",
      "position": [
        480,
        368
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "error",
              "type": "boolean",
              "value": "true"
            },
            {
              "id": "2",
              "name": "message",
              "type": "string",
              "value": "Missing required fields: contractType and parties array are required"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c15f0e96-584b-4870-984c-154be193c2f8",
      "name": "Prepare Contract Data",
      "type": "n8n-nodes-base.set",
      "position": [
        480,
        208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "contractId",
              "type": "string",
              "value": "={{ 'CTR-' + $now.format('yyyyMMdd') + '-' + Math.random().toString(36).substring(2, 8).toUpperCase() }}"
            },
            {
              "id": "2",
              "name": "contractType",
              "type": "string",
              "value": "={{ $json.body.contractType }}"
            },
            {
              "id": "3",
              "name": "parties",
              "type": "object",
              "value": "={{ $json.body.parties }}"
            },
            {
              "id": "4",
              "name": "customTerms",
              "type": "string",
              "value": "={{ $json.body.customTerms || '' }}"
            },
            {
              "id": "5",
              "name": "effectiveDate",
              "type": "string",
              "value": "={{ $json.body.effectiveDate || $now.format('yyyy-MM-dd') }}"
            },
            {
              "id": "6",
              "name": "expirationDate",
              "type": "string",
              "value": "={{ $json.body.expirationDate || '' }}"
            },
            {
              "id": "7",
              "name": "value",
              "type": "number",
              "value": "={{ $json.body.contractValue || 0 }}"
            },
            {
              "id": "8",
              "name": "currency",
              "type": "string",
              "value": "={{ $json.body.currency || 'USD' }}"
            },
            {
              "id": "9",
              "name": "requestedAt",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "05e7de11-0253-44a8-98c3-b7803689fe2d",
      "name": "Route by Contract Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        704,
        208
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.contractType }}",
                    "rightValue": "NDA"
                  }
                ]
              }
            },
            {
              "conditions": {
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.contractType }}",
                    "rightValue": "SERVICE"
                  }
                ]
              }
            },
            {
              "conditions": {
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.contractType }}",
                    "rightValue": "EMPLOYMENT"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "574932b8-79f0-4b8c-8f68-b109296f830a",
      "name": "NDA Template Base",
      "type": "n8n-nodes-base.set",
      "position": [
        928,
        48
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "templateType",
              "type": "string",
              "value": "Non-Disclosure Agreement"
            },
            {
              "id": "2",
              "name": "baseTerms",
              "type": "string",
              "value": "Confidentiality period: 2 years, Scope: All proprietary information, Exceptions: Publicly known information"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3cb67007-c983-4143-a0b4-ab7e757963f3",
      "name": "Service Agreement Base",
      "type": "n8n-nodes-base.set",
      "position": [
        928,
        208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "templateType",
              "type": "string",
              "value": "Service Agreement"
            },
            {
              "id": "2",
              "name": "baseTerms",
              "type": "string",
              "value": "Payment terms: Net 30, Warranty: 90 days, Liability cap: Contract value"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "245cdb87-1937-4b4e-a0a0-503cab265af1",
      "name": "Employment Contract Base",
      "type": "n8n-nodes-base.set",
      "position": [
        928,
        368
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "templateType",
              "type": "string",
              "value": "Employment Contract"
            },
            {
              "id": "2",
              "name": "baseTerms",
              "type": "string",
              "value": "Probation: 90 days, Notice period: 2 weeks, Benefits: Standard package"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "606d52b7-e2b5-4b42-9a8e-a626740315d3",
      "name": "Generic Contract Base",
      "type": "n8n-nodes-base.set",
      "position": [
        928,
        528
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "templateType",
              "type": "string",
              "value": "General Agreement"
            },
            {
              "id": "2",
              "name": "baseTerms",
              "type": "string",
              "value": "Standard commercial terms apply"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0e6990f5-dfc1-4cb4-9aff-18d1a870e943",
      "name": "Merge Template Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        1152,
        208
      ],
      "parameters": {
        "mode": "chooseBranch"
      },
      "typeVersion": 3
    },
    {
      "id": "5c46e53d-62d2-4055-a180-dee791e47615",
      "name": "AI Contract Advisor",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1344,
        208
      ],
      "parameters": {
        "text": "=You are a legal contract specialist. Generate a professional contract based on the following:\n\nContract Type: {{ $('Prepare Contract Data').first().json.contractType }}\nTemplate: {{ $json.templateType }}\nBase Terms: {{ $json.baseTerms }}\nCustom Terms Requested: {{ $('Prepare Contract Data').first().json.customTerms || 'None specified' }}\nParties: {{ JSON.stringify($('Prepare Contract Data').first().json.parties) }}\nEffective Date: {{ $('Prepare Contract Data').first().json.effectiveDate }}\nContract Value: {{ $('Prepare Contract Data').first().json.value }} {{ $('Prepare Contract Data').first().json.currency }}\n\nGenerate the contract in Markdown format with the following structure:\n1. Title and Contract ID\n2. Parties section\n3. Recitals/Background\n4. Key Terms and Conditions\n5. Obligations of each party\n6. Payment terms (if applicable)\n7. Term and termination\n8. Confidentiality clause\n9. Governing law\n10. Signature blocks\n\nReturn ONLY valid JSON with keys:\n- contractMarkdown: The full contract in Markdown format\n- suggestedClauses: Array of 3 additional recommended clauses\n- riskAssessment: Brief assessment of contract risk level (low/medium/high) with reason",
        "options": {
          "systemMessage": "You are an expert legal contract advisor. Generate professional, legally sound contract documents. Always output valid JSON."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "373f6f64-dd98-45f9-a615-a3e1629d2b52",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1344,
        432
      ],
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {
          "temperature": 0.3
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f5dd9e83-0fdb-489a-baa4-d3439093dee9",
      "name": "Parse AI Contract Response",
      "type": "n8n-nodes-base.code",
      "position": [
        1568,
        208
      ],
      "parameters": {
        "jsCode": "const contractData = $('Prepare Contract Data').first().json;\nconst aiResponse = $input.first().json;\n\nlet parsedContent = {};\ntry {\n  const outputText = aiResponse.output || '{}';\n  const jsonMatch = outputText.match(/\\{[\\s\\S]*\\}/);\n  if (jsonMatch) {\n    parsedContent = JSON.parse(jsonMatch[0]);\n  }\n} catch (e) {\n  parsedContent = {\n    contractMarkdown: '# Contract\\n\\nError generating contract content.',\n    suggestedClauses: ['Force Majeure', 'Dispute Resolution', 'Amendment Process'],\n    riskAssessment: 'medium - Unable to fully assess'\n  };\n}\n\nreturn [{\n  json: {\n    ...contractData,\n    contractMarkdown: parsedContent.contractMarkdown || '# Contract Document',\n    suggestedClauses: parsedContent.suggestedClauses || [],\n    riskAssessment: parsedContent.riskAssessment || 'medium',\n    generatedAt: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "57000b29-1b1a-49c4-a882-0c6b164ab551",
      "name": "Convert Markdown to HTML",
      "type": "n8n-nodes-base.markdown",
      "position": [
        1792,
        208
      ],
      "parameters": {
        "mode": "markdownToHtml",
        "options": {
          "tables": true,
          "strikethrough": true,
          "simpleLineBreaks": true
        },
        "markdown": "={{ $json.contractMarkdown }}",
        "destinationKey": "contractHtml"
      },
      "typeVersion": 1
    },
    {
      "id": "37d002c5-1b45-452f-aa77-cd56f5def4a2",
      "name": "Prepare Signature Request",
      "type": "n8n-nodes-base.code",
      "position": [
        2000,
        208
      ],
      "parameters": {
        "jsCode": "const data = $input.first().json;\nconst parties = data.parties || [];\n\nconst signers = parties.map((party, index) => ({\n  signerId: 'signer_' + (index + 1),\n  name: party.name,\n  email: party.email,\n  role: party.role || 'Signatory',\n  order: index + 1\n}));\n\nreturn [{\n  json: {\n    ...data,\n    signers: signers,\n    documentTitle: data.templateType + ' - ' + data.contractId,\n    signingDeadline: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString(),\n    webhookUrl: $execution.resumeUrl\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "5b9ee987-f85f-453e-81a8-97c770c48280",
      "name": "Send to E-Signature Service",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2224,
        208
      ],
      "parameters": {
        "url": "https://api.esignature-service.example.com/envelopes",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"envelope_id\": \"{{ $json.contractId }}\",\n  \"document_title\": \"{{ $json.documentTitle }}\",\n  \"document_html\": {{ JSON.stringify($json.contractHtml) }},\n  \"signers\": {{ JSON.stringify($json.signers) }},\n  \"webhook_url\": \"{{ $json.webhookUrl }}\",\n  \"deadline\": \"{{ $json.signingDeadline }}\"\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "httpHeaderAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "044abe06-c6ff-45f2-9f00-0b0d60f0e8f5",
      "name": "Send Signing Request Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2448,
        96
      ],
      "parameters": {
        "sendTo": "={{ $json.signers.map(s => s.email).join(', ') }}",
        "message": "=Dear Signatory,\n\nA contract document is ready for your signature.\n\nContract ID: {{ $json.contractId }}\nDocument: {{ $json.documentTitle }}\nDeadline: {{ $json.signingDeadline }}\n\nPlease review and sign the document at your earliest convenience.\n\nBest regards,\nContract Management System",
        "options": {},
        "subject": "=Contract Ready for Signature: {{ $json.documentTitle }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "410c3dfb-48a9-4884-a5a9-06b6360f169c",
      "name": "Wait for Signature Webhook",
      "type": "n8n-nodes-base.wait",
      "position": [
        2448,
        272
      ],
      "parameters": {
        "resume": "webhook",
        "options": {},
        "httpMethod": "POST",
        "resumeUnit": "days",
        "resumeAmount": 7,
        "limitWaitTime": true
      },
      "typeVersion": 1.1
    },
    {
      "id": "295ca481-6ed5-436e-8171-f9e82269feaf",
      "name": "Process Signature Result",
      "type": "n8n-nodes-base.code",
      "position": [
        2672,
        272
      ],
      "parameters": {
        "jsCode": "const webhookData = $input.first().json;\nconst originalData = $('Prepare Signature Request').first().json;\n\nconst isComplete = webhookData.body?.status === 'completed' || webhookData.body?.event === 'envelope_completed';\nconst isExpired = webhookData.body?.status === 'expired' || !webhookData.body;\n\nreturn [{\n  json: {\n    contractId: originalData.contractId,\n    documentTitle: originalData.documentTitle,\n    status: isComplete ? 'SIGNED' : (isExpired ? 'EXPIRED' : 'PENDING'),\n    signedAt: isComplete ? new Date().toISOString() : null,\n    signers: originalData.signers,\n    signatureDetails: webhookData.body || {},\n    effectiveDate: originalData.effectiveDate,\n    expirationDate: originalData.expirationDate,\n    value: originalData.value,\n    currency: originalData.currency\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "bad71063-390f-4160-891d-deecd502ec5d",
      "name": "Check Signature Status",
      "type": "n8n-nodes-base.if",
      "position": [
        2880,
        272
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "check-signed",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "SIGNED"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "b0e252a8-7b89-40e1-b463-e6e890f0efdf",
      "name": "Log Completed Contract",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3120,
        160
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "5d9c0856-fa6f-47a6-89a8-19ee12a921a6",
      "name": "Send Completion Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3344,
        160
      ],
      "parameters": {
        "sendTo": "={{ $json.signers.map(s => s.email).join(', ') }}",
        "message": "=Dear All,\n\nThe contract has been successfully signed by all parties.\n\nContract ID: {{ $json.contractId }}\nDocument: {{ $json.documentTitle }}\nSigned At: {{ $json.signedAt }}\nEffective Date: {{ $json.effectiveDate }}\n\nA copy of the signed document will be sent separately.\n\nThank you for your cooperation.\n\nBest regards,\nContract Management System",
        "options": {},
        "subject": "=Contract Signed: {{ $json.documentTitle }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "38eb1af3-9dec-4584-b707-5b5695c6ca20",
      "name": "Log Expired or Pending",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3120,
        400
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "a689643d-343d-4cad-911a-1546e1cfb645",
      "name": "Send Reminder or Expiry Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3344,
        400
      ],
      "parameters": {
        "sendTo": "={{ $json.signers.map(s => s.email).join(', ') }}",
        "message": "=Dear Signatory,\n\nThe contract signing request has {{ $json.status === 'EXPIRED' ? 'expired' : 'not been completed' }}.\n\nContract ID: {{ $json.contractId }}\nDocument: {{ $json.documentTitle }}\nStatus: {{ $json.status }}\n\n{{ $json.status === 'EXPIRED' ? 'Please contact the sender if you still wish to proceed with this contract.' : 'Please sign the document at your earliest convenience.' }}\n\nBest regards,\nContract Management System",
        "options": {},
        "subject": "=Contract {{ $json.status }}: {{ $json.documentTitle }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "0f8723aa-a47c-4bea-8138-795b2943efcc",
      "name": "Merge Final Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        3568,
        272
      ],
      "parameters": {
        "mode": "chooseBranch"
      },
      "typeVersion": 3
    },
    {
      "id": "93ccaf19-0657-4822-90d6-926f8c9a4940",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        3792,
        272
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n  \"success\": true,\n  \"contractId\": \"{{ $('Prepare Contract Data').first().json.contractId }}\",\n  \"status\": \"Contract request processed\",\n  \"message\": \"Contract has been generated and sent for signatures\"\n}"
      },
      "typeVersion": 1.1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8be8c6b4-d86c-4431-9beb-65d9495709bd",
  "connections": {
    "NDA Template Base": {
      "main": [
        [
          {
            "node": "Merge Template Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Contract Advisor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "AI Contract Advisor": {
      "main": [
        [
          {
            "node": "Parse AI Contract Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Final Results": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Template Data": {
      "main": [
        [
          {
            "node": "AI Contract Advisor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generic Contract Base": {
      "main": [
        [
          {
            "node": "Merge Template Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Contract Data": {
      "main": [
        [
          {
            "node": "Route by Contract Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Completion Email": {
      "main": [
        [
          {
            "node": "Merge Final Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Signature Status": {
      "main": [
        [
          {
            "node": "Log Completed Contract",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Expired or Pending",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Completed Contract": {
      "main": [
        [
          {
            "node": "Send Completion Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Expired or Pending": {
      "main": [
        [
          {
            "node": "Send Reminder or Expiry Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Contract Type": {
      "main": [
        [
          {
            "node": "NDA Template Base",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Service Agreement Base",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Employment Contract Base",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generic Contract Base",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Service Agreement Base": {
      "main": [
        [
          {
            "node": "Merge Template Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Contract Request Webhook": {
      "main": [
        [
          {
            "node": "Validate Contract Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Markdown to HTML": {
      "main": [
        [
          {
            "node": "Prepare Signature Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Employment Contract Base": {
      "main": [
        [
          {
            "node": "Merge Template Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Invalid Request Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Signature Result": {
      "main": [
        [
          {
            "node": "Check Signature Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Signature Request": {
      "main": [
        [
          {
            "node": "Send to E-Signature Service",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Contract Request": {
      "main": [
        [
          {
            "node": "Prepare Contract Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Invalid Request Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Contract Response": {
      "main": [
        [
          {
            "node": "Convert Markdown to HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Signature Webhook": {
      "main": [
        [
          {
            "node": "Process Signature Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send to E-Signature Service": {
      "main": [
        [
          {
            "node": "Send Signing Request Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Wait for Signature Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Reminder or Expiry Email": {
      "main": [
        [
          {
            "node": "Merge Final Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}