{
  "name": "Champion Job-Change Radar",
  "nodes": [
    {
      "id": "027f184e-9503-4936-a1f6-ea18a039f72a",
      "name": "Champion Recheck Submitted",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.6,
      "position": [
        0,
        432
      ],
      "parameters": {
        "formDescription": "After checking a champion's current employer in Clay, submit the result here to run the Champion Job-Change Radar.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Email",
              "fieldType": "email",
              "requiredField": true
            },
            {
              "fieldLabel": "Current Company",
              "fieldType": "text",
              "requiredField": true
            },
            {
              "fieldLabel": "Current Title",
              "fieldType": "text",
              "requiredField": false
            }
          ]
        },
        "formTitle": "Champion Recheck Result",
        "options": {
          "path": "champion-recheck"
        }
      }
    },
    {
      "id": "1da2c4b8-5404-4a5a-bb88-0c0144e6bcdf",
      "name": "Look Up Champion",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        224,
        208
      ],
      "parameters": {
        "dataTableId": {
          "__rl": true,
          "cachedResultName": "Champion Roster",
          "mode": "id",
          "value": "ognnl0Ng9MUnB9E8"
        },
        "filters": {
          "conditions": [
            {
              "condition": "eq",
              "keyName": "email",
              "keyValue": "={{ $json['Email'] }}"
            }
          ]
        },
        "limit": 1,
        "matchType": "allConditions",
        "operation": "get",
        "resource": "row",
        "returnAll": false
      }
    },
    {
      "id": "f5306773-0dad-45c3-bca2-9c2169e37cf6",
      "name": "Job Change Detected?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        448,
        208
      ],
      "parameters": {
        "conditions": {
          "combinator": "and",
          "conditions": [
            {
              "leftValue": "={{ $('Champion Recheck Submitted').item.json['Current Company'] }}",
              "operator": {
                "operation": "notEquals",
                "type": "string"
              },
              "rightValue": "={{ $json.lastKnownCompany }}"
            },
            {
              "leftValue": "={{ $('Champion Recheck Submitted').item.json['Current Company'] }}",
              "operator": {
                "operation": "notEmpty",
                "type": "string"
              }
            }
          ],
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 1
          }
        }
      }
    },
    {
      "id": "8af8e0cb-b6d1-40dd-85b9-8a075cde8c96",
      "name": "Find Deal History",
      "type": "n8n-nodes-base.salesforce",
      "typeVersion": 1.1,
      "position": [
        672,
        112
      ],
      "parameters": {
        "resource": "search",
        "operation": "query",
        "query": "=SELECT Id, Name, Amount, StageName, CloseDate, Description FROM Opportunity WHERE AccountId = '{{ $json.originalAccountId }}' ORDER BY CloseDate DESC LIMIT 5"
      },
      "credentials": {
        "salesforceOAuth2Api": {
          "name": "Salesforce account"
        }
      }
    },
    {
      "id": "fbe99254-f986-4159-b0b1-8dcf583d192e",
      "name": "Summarize Deal History",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        896,
        112
      ],
      "parameters": {
        "jsCode": "const opps = $input.all().map(item => item.json).filter(o => o.Id);\nconst dealHistoryText = opps.length > 0\n  ? opps.map(o => `- ${o.Name}: $${o.Amount || 0}, Stage: ${o.StageName}, Close: ${o.CloseDate}${o.Description ? ' — ' + o.Description : ''}`).join('\\n')\n  : 'No prior opportunity history found for this account.';\n\nreturn [{\n  json: {\n    dealHistoryText,\n    dealCount: opps.length\n  }\n}];"
      }
    },
    {
      "id": "320bbe3c-1240-470b-9d26-84c3009136ee",
      "name": "Job-Change Rationale Drafter",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        1120,
        112
      ],
      "parameters": {
        "hasOutputParser": true,
        "options": {
          "systemMessage": "You are a champion-tracking assistant for Fortavault, Inc., a fictional data protection and security platform (cloud backup, ransomware recovery, zero-trust access, and compliance reporting). Products: Fortavault Backup Cloud, Fortavault Shield, Fortavault Access, Fortavault Insights. Key competitors: Veyron Data, Ashcombe Systems, Cyphertide, Northgate Cloud Security, Ridgeline Compliance.\n\nA contact who was previously a champion or closed-won buyer at one company has just changed jobs to a new company, detected via a real Clay lookup (not simulated). Your job is to assess whether it's worth pursuing them at their new company and draft a specific re-engagement angle grounded in their history with Fortavault.\n\nWrite rationale as 1-2 sentences explaining why this is worth pursuing now - private, for the rep only. Write reengagementAngle as a 2-3 sentence opener a rep could paste into an email or LinkedIn message, referencing their prior experience with Fortavault by name and connecting it to a specific reason to talk now at the new company, grounded in real Fortavault products/positioning where relevant.\n\nRespond with a JSON object with exactly two fields: rationale (string) and reengagementAngle (string)."
        },
        "promptType": "define",
        "text": "=A past Fortavault champion just changed jobs, detected via a real Clay lookup.\n\nContact: {{ $('Look Up Champion').item.json.contactName }}\nOld company (where they were a champion/closed-won contact): {{ $('Look Up Champion').item.json.lastKnownCompany }}\nNew company: {{ $('Champion Recheck Submitted').item.json['Current Company'] }}\nNew title (if known): {{ $('Champion Recheck Submitted').item.json['Current Title'] }}\n\nTheir deal history at the old company:\n{{ $('Summarize Deal History').item.json.dealHistoryText }}\n\nDraft a rationale for why it's worth pursuing this person at their new company, plus a re-engagement angle."
      }
    },
    {
      "id": "ae133a55-deb2-46f6-bb32-a5225c5bb516",
      "name": "Anthropic Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "typeVersion": 1.5,
      "position": [
        1136,
        336
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-6",
          "cachedResultName": "Claude Sonnet 4.6"
        },
        "options": {
          "temperature": 0.4
        }
      },
      "credentials": {
        "anthropicApi": {
          "name": "Anthropic account"
        }
      }
    },
    {
      "id": "90200ebb-eb96-4724-a924-80a5159bb83e",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        1264,
        336
      ],
      "parameters": {
        "jsonSchemaExample": "{ \"rationale\": \"brief reasoning for the rep\", \"reengagementAngle\": \"drafted re-engagement opener\" }",
        "autoFix": false
      }
    },
    {
      "id": "39ff35dc-26ab-4314-8257-f2706228e976",
      "name": "Send for Approval",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.7,
      "position": [
        1472,
        112
      ],
      "parameters": {
        "approvalOptions": {
          "values": {
            "approvalType": "double",
            "approveLabel": "Create Opportunity",
            "disapproveLabel": "Skip"
          }
        },
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "C0BQ3G96HL6"
        },
        "message": "=🔄 Champion job change detected\n\n{{ $('Look Up Champion').item.json.contactName }} moved from {{ $('Look Up Champion').item.json.lastKnownCompany }} to {{ $('Champion Recheck Submitted').item.json['Current Company'] }}\n\nWhy now: {{ $json.output.rationale }}\n\nSuggested re-engagement:\n{{ $json.output.reengagementAngle }}",
        "operation": "sendAndWait",
        "options": {},
        "resource": "message",
        "responseType": "approval",
        "select": "channel"
      },
      "credentials": {
        "slackApi": {
          "name": "Slack account"
        }
      }
    },
    {
      "id": "03a9028d-e691-49d9-ae06-a2d0d6814187",
      "name": "Approved?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1696,
        112
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 1
          },
          "conditions": [
            {
              "leftValue": "={{ $json.data.approved }}",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "rightValue": true
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "204f4710-c4ee-4593-a955-378914956514",
      "name": "Create New Account",
      "type": "n8n-nodes-base.salesforce",
      "typeVersion": 1.1,
      "position": [
        1920,
        16
      ],
      "parameters": {
        "additionalFields": {
          "description": "=New company for re-engaged champion {{ $('Look Up Champion').item.json.contactName }}, formerly at {{ $('Look Up Champion').item.json.lastKnownCompany }}."
        },
        "name": "={{ $('Champion Recheck Submitted').item.json['Current Company'] }}",
        "operation": "create",
        "resource": "account"
      },
      "credentials": {
        "salesforceOAuth2Api": {
          "name": "Salesforce account"
        }
      }
    },
    {
      "id": "5bf92936-0a3a-4cc0-90a1-333e3b1e683f",
      "name": "Create New Opportunity",
      "type": "n8n-nodes-base.salesforce",
      "typeVersion": 1.1,
      "position": [
        2144,
        16
      ],
      "parameters": {
        "additionalFields": {
          "accountId": {
            "__rl": true,
            "mode": "id",
            "value": "={{ $('Create New Account').item.json.id }}"
          },
          "description": "={{ $('Job-Change Rationale Drafter').item.json.output.reengagementAngle }}"
        },
        "closeDate": "={{ $now.plus(90, \"days\").toFormat(\"yyyy-MM-dd\") }}",
        "name": "={{ $('Look Up Champion').item.json.contactName }} - {{ $('Champion Recheck Submitted').item.json['Current Company'] }} (Champion Re-engagement)",
        "operation": "create",
        "resource": "opportunity",
        "stageName": "Qualification"
      },
      "credentials": {
        "salesforceOAuth2Api": {
          "name": "Salesforce account"
        }
      }
    },
    {
      "id": "160d79cb-4ce9-41d6-bf81-d27e94d32727",
      "name": "Log Approved",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        2368,
        16
      ],
      "parameters": {
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "approvedAt": "={{ $now.toISO() }}",
            "channel": "C0BQ3G96HL6",
            "contactName": "={{ $('Look Up Champion').item.json.contactName }}",
            "email": "={{ $('Look Up Champion').item.json.email }}",
            "flaggedAt": "={{ $now.toISO() }}",
            "newAccountId": "={{ $('Create New Account').item.json.id }}",
            "newCompany": "={{ $('Champion Recheck Submitted').item.json['Current Company'] }}",
            "oldCompany": "={{ $('Look Up Champion').item.json.lastKnownCompany }}",
            "opportunityId": "={{ $('Create New Opportunity').item.json.id }}",
            "opportunityName": "={{ $('Look Up Champion').item.json.contactName }} - {{ $('Champion Recheck Submitted').item.json['Current Company'] }} (Champion Re-engagement)",
            "rationale": "={{ $('Job-Change Rationale Drafter').item.json.output.rationale }}",
            "reengagementAngle": "={{ $('Job-Change Rationale Drafter').item.json.output.reengagementAngle }}",
            "status": "approved"
          }
        },
        "dataTableId": {
          "__rl": true,
          "cachedResultName": "Champion Job-Change Log",
          "mode": "id",
          "value": "NBW8pAwDUjbDtn19"
        },
        "operation": "insert",
        "options": {},
        "resource": "row"
      }
    },
    {
      "id": "18643864-d922-4877-a006-7c4a69200b96",
      "name": "Update Roster - Approved",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        2592,
        16
      ],
      "parameters": {
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "lastCheckedAt": "={{ $now.toISO() }}",
            "lastKnownCompany": "={{ $('Champion Recheck Submitted').item.json['Current Company'] }}"
          }
        },
        "dataTableId": {
          "__rl": true,
          "cachedResultName": "Champion Roster",
          "mode": "id",
          "value": "ognnl0Ng9MUnB9E8"
        },
        "filters": {
          "conditions": [
            {
              "condition": "eq",
              "keyName": "email",
              "keyValue": "={{ $('Look Up Champion').item.json.email }}"
            }
          ]
        },
        "matchType": "allConditions",
        "operation": "update",
        "options": {},
        "resource": "row"
      }
    },
    {
      "id": "e5731ce3-071c-41bc-84f4-61a016a6be25",
      "name": "Log Declined",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1920,
        208
      ],
      "parameters": {
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "channel": "C0BQ3G96HL6",
            "contactName": "={{ $('Look Up Champion').item.json.contactName }}",
            "email": "={{ $('Look Up Champion').item.json.email }}",
            "flaggedAt": "={{ $now.toISO() }}",
            "newCompany": "={{ $('Champion Recheck Submitted').item.json['Current Company'] }}",
            "oldCompany": "={{ $('Look Up Champion').item.json.lastKnownCompany }}",
            "rationale": "={{ $('Job-Change Rationale Drafter').item.json.output.rationale }}",
            "reengagementAngle": "={{ $('Job-Change Rationale Drafter').item.json.output.reengagementAngle }}",
            "status": "declined"
          }
        },
        "dataTableId": {
          "__rl": true,
          "cachedResultName": "Champion Job-Change Log",
          "mode": "id",
          "value": "NBW8pAwDUjbDtn19"
        },
        "operation": "insert",
        "options": {},
        "resource": "row"
      }
    },
    {
      "id": "50f134fa-5500-4c4e-8ce0-0415af960deb",
      "name": "Update Roster - Declined",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        2144,
        208
      ],
      "parameters": {
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "lastCheckedAt": "={{ $now.toISO() }}",
            "lastKnownCompany": "={{ $('Champion Recheck Submitted').item.json['Current Company'] }}"
          }
        },
        "dataTableId": {
          "__rl": true,
          "cachedResultName": "Champion Roster",
          "mode": "id",
          "value": "ognnl0Ng9MUnB9E8"
        },
        "filters": {
          "conditions": [
            {
              "condition": "eq",
              "keyName": "email",
              "keyValue": "={{ $('Look Up Champion').item.json.email }}"
            }
          ]
        },
        "matchType": "allConditions",
        "operation": "update",
        "options": {},
        "resource": "row"
      }
    },
    {
      "id": "b40a3413-f325-45ce-b39e-20cf89df66c7",
      "name": "Update Roster - No Change",
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        672,
        304
      ],
      "parameters": {
        "resource": "row",
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "mode": "id",
          "value": "ognnl0Ng9MUnB9E8",
          "cachedResultName": "Champion Roster"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "email",
              "condition": "eq",
              "keyValue": "={{ $json.email }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "lastCheckedAt": "={{ $now.toISO() }}"
          }
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Look Up Champion": {
      "main": [
        [
          {
            "node": "Job Change Detected?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Job Change Detected?": {
      "main": [
        [
          {
            "node": "Find Deal History",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Roster - No Change",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Deal History": {
      "main": [
        [
          {
            "node": "Summarize Deal History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize Deal History": {
      "main": [
        [
          {
            "node": "Job-Change Rationale Drafter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Job-Change Rationale Drafter": {
      "main": [
        [
          {
            "node": "Send for Approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Job-Change Rationale Drafter",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Job-Change Rationale Drafter",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Send for Approval": {
      "main": [
        [
          {
            "node": "Approved?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approved?": {
      "main": [
        [
          {
            "node": "Create New Account",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Declined",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create New Account": {
      "main": [
        [
          {
            "node": "Create New Opportunity",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create New Opportunity": {
      "main": [
        [
          {
            "node": "Log Approved",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Approved": {
      "main": [
        [
          {
            "node": "Update Roster - Approved",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Declined": {
      "main": [
        [
          {
            "node": "Update Roster - Declined",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Champion Recheck Submitted": {
      "main": [
        [
          {
            "node": "Look Up Champion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}