{
  "id": "6pajoyXG2nGIC53WlZYcw",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI-Powered PLG Revenue Engine: Segment, Attio & Outreach Sync",
  "tags": [],
  "nodes": [
    {
      "id": "8448ad19-5459-4fe4-8542-8a2b5e79b704",
      "name": "Flow 1 Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        -256
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 348,
        "content": "\ud83d\udce1 FLOW 1 \u2014 SEGMENT PRODUCT EVENT \u2192 INTENT ROUTER\n\nTrigger: Segment webhook fires on product events\n(feature used, upgrade clicked, invite sent, export triggered)\n\nProcess:\n1. Normalize Segment event payload\n2. Enrich contact from Attio CRM\n3. Claude classifies PQL intent + recommends action\n4. High PQL \u2192 Lemlist sequence + Attio task\n5. Mid PQL \u2192 ActiveCampaign upgrade nurture list\n6. Low PQL \u2192 Update Attio attributes only"
      },
      "typeVersion": 1
    },
    {
      "id": "f05bdf2d-1cdb-479d-8850-572a1d3d752f",
      "name": "Flow 2 Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        400
      ],
      "parameters": {
        "color": 2,
        "width": 380,
        "height": 348,
        "content": "\ud83d\udd04 FLOW 2 \u2014 ATTIO DEAL STAGE \u2192 ACTIVECAMPAIGN + LEMLIST SYNC\n\nTrigger: Attio webhook on deal stage change\n\nProcess:\n1. Pull full contact + company from Attio\n2. Query Segment for product usage profile\n3. Upsert ActiveCampaign contact with 15+ attributes\n4. Move to correct AC list by lifecycle stage\n5. If Closed Won \u2192 pause Lemlist + start onboarding AC sequence\n6. If Closed Lost \u2192 add to Lemlist re-engagement campaign"
      },
      "typeVersion": 1
    },
    {
      "id": "cff0d335-ba57-4ba5-8506-43b2d77ddb09",
      "name": "Flow 3 Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        1056
      ],
      "parameters": {
        "color": 5,
        "width": 380,
        "height": 364,
        "content": "\ud83d\udcac FLOW 3 \u2014 INTERCOM CONVERSATION \u2192 REVENUE SIGNAL\n\nTrigger: Intercom webhook on conversation events\n(new conversation, tag added, CSAT scored)\n\nProcess:\n1. Filter for sales-intent or churn-risk conversations\n2. Claude reads transcript + extracts buying signals\n3. Buying signal \u2192 create Attio deal + enroll Lemlist sequence\n4. Churn signal \u2192 Attio churn flag + AC churn prevention list\n5. All signals update Attio contact attributes\n6. High-value accounts alert Slack"
      },
      "typeVersion": 1
    },
    {
      "id": "9e504db8-92ef-474c-94c9-5c0c5d44601a",
      "name": "Flow 4 Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        1792
      ],
      "parameters": {
        "color": 6,
        "width": 380,
        "height": 380,
        "content": "\ud83d\udcca FLOW 4 \u2014 DAILY PQL SCORING + OUTREACH ACTIVATION\n\nTrigger: Scheduled daily at 7AM\n\nProcess:\n1. Pull all active trial/free users from Attio\n2. Query Segment API for 14-day product usage per user\n3. Score each user: activation, depth, breadth, recency\n4. PQL threshold crossed \u2192 enroll in Lemlist sequence\n5. Already customer \u2192 move to AC expansion list\n6. Stale trials \u2192 AC re-engagement sequence\n7. Update all Attio records with fresh scores"
      },
      "typeVersion": 1
    },
    {
      "id": "2f3673c4-053b-4926-9344-b666b7017595",
      "name": "Segment Event Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        736,
        -48
      ],
      "parameters": {
        "path": "segment-events",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "51fc3e37-9884-4f26-b2b4-8f23f65af864",
      "name": "Segment Webhook ACK",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        960,
        48
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={ \"received\": true }"
      },
      "typeVersion": 1.1
    },
    {
      "id": "cda06ab6-b1a8-4184-8388-bf7fdce4118e",
      "name": "Parse Segment Event",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        -144
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Normalize Segment track/identify/page event\nconst body = $input.item.json.body ?? $input.item.json;\n\nconst eventType = body.type || 'track'; // track | identify | page\nconst event = body.event || body.name || 'unknown';\nconst userId = body.userId || body.anonymousId || '';\nconst email = body.traits?.email || body.context?.traits?.email || body.properties?.email || '';\nconst properties = body.properties || {};\nconst traits = body.traits || body.context?.traits || {};\n\n// High-value product signals that indicate upgrade intent\nconst HIGH_INTENT_EVENTS = [\n  'upgrade_clicked', 'pricing_viewed', 'billing_viewed',\n  'export_triggered', 'api_key_created', 'team_invite_sent',\n  'integration_connected', 'limit_reached', 'feature_gate_hit'\n];\n\n// Activation signals\nconst ACTIVATION_EVENTS = [\n  'onboarding_completed', 'first_project_created', 'first_export',\n  'first_integration', 'key_action_completed'\n];\n\nconst isHighIntent = HIGH_INTENT_EVENTS.includes(event);\nconst isActivation = ACTIVATION_EVENTS.includes(event);\n\n// Base signal score\nconst EVENT_SCORES = {\n  'upgrade_clicked': 90, 'pricing_viewed': 60, 'billing_viewed': 55,\n  'export_triggered': 45, 'api_key_created': 50, 'team_invite_sent': 65,\n  'integration_connected': 55, 'limit_reached': 80, 'feature_gate_hit': 75,\n  'onboarding_completed': 40, 'first_project_created': 30,\n  'first_export': 35, 'key_action_completed': 45\n};\n\nconst signalScore = EVENT_SCORES[event] || 10;\n\nreturn [{\n  json: {\n    event_type: eventType,\n    event_name: event,\n    user_id: userId,\n    email,\n    properties,\n    traits,\n    signal_score: signalScore,\n    is_high_intent: isHighIntent,\n    is_activation: isActivation,\n    received_at: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "e5394d43-6ad6-4d61-9fc6-d8dcf5050164",
      "name": "Get Contact from Attio",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1184,
        -144
      ],
      "parameters": {
        "url": "=https://api.attio.com/v2/contacts/{{ $json.email }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "066bf0c1-0508-4eb5-a537-26e192238cb5",
      "name": "Pull Segment User Profile",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1408,
        -144
      ],
      "parameters": {
        "url": "https://api.segment.io/v1/segment/profiles/contacts",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "filter",
              "value": "=userId={{ $json.user_id }}"
            },
            {
              "name": "include",
              "value": "traits,events"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "43ecae9d-7fca-4205-afd7-da414815abfd",
      "name": "Merge PQL Context",
      "type": "n8n-nodes-base.code",
      "position": [
        1632,
        -144
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const segEvent = $('Parse Segment Event').item.json;\nconst attioContact = $('Get Contact from Attio').item.json;\nconst segProfile = $input.item.json;\n\nconst contact = attioContact?.data || {};\nconst attrs = contact?.values || {};\n\nconst profileTraits = segProfile?.data?.[0]?.traits || {};\n\nreturn [{\n  json: {\n    // Identity\n    email: segEvent.email,\n    user_id: segEvent.user_id,\n    first_name: attrs.first_name?.[0]?.value || profileTraits.firstName || '',\n    last_name: attrs.last_name?.[0]?.value || profileTraits.lastName || '',\n    company: attrs.company?.[0]?.referenced_object?.values?.name?.[0]?.value || profileTraits.company || '',\n    job_title: attrs.job_title?.[0]?.value || profileTraits.title || '',\n    // Attio CRM state\n    attio_contact_id: contact.id?.record_id || null,\n    attio_stage: attrs.stage?.[0]?.value || 'unknown',\n    attio_plan: attrs.plan?.[0]?.value || 'free',\n    attio_mrr: parseFloat(attrs.mrr?.[0]?.value || 0),\n    attio_owner_id: attrs.owner?.[0]?.referenced_actor?.id || null,\n    pql_score: parseFloat(attrs.pql_score?.[0]?.value || 0),\n    // Segment profile\n    total_events_30d: profileTraits.total_events_30d || 0,\n    features_used: profileTraits.features_used || 0,\n    last_seen_at: profileTraits.last_seen_at || null,\n    // Current signal\n    event_name: segEvent.event_name,\n    signal_score: segEvent.signal_score,\n    is_high_intent: segEvent.is_high_intent,\n    is_activation: segEvent.is_activation,\n    event_properties: segEvent.properties\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "21433c2f-b2ad-4d28-900e-7b2a4a027915",
      "name": "Parse Claude PQL Output",
      "type": "n8n-nodes-base.code",
      "position": [
        2080,
        -144
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const raw = $input.item.json?.content?.[0]?.text ?? '';\nconst ctx = $('Merge PQL Context').item.json;\nlet ai;\ntry {\n  ai = JSON.parse(raw.replace(/```json\\n?/g, '').replace(/```\\n?/g, '').trim());\n} catch(e) {\n  throw new Error('Claude JSON parse failed: ' + raw.slice(0, 200));\n}\nreturn [{ json: { ...ctx, ai } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "0e48ecf3-df3d-4b50-be71-14cc44324db4",
      "name": "PQL Action Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        2304,
        -176
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "lemlist",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3eeafcaa-2ece-46ec-9fa7-01e906f54e08",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ai.recommended_action }}",
                    "rightValue": "lemlist_sequence"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "activecampaign",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "23625640-cdfd-4a70-9f17-1d6f519d4a0d",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ai.recommended_action }}",
                    "rightValue": "activecampaign_nurture"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "attio_only",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b8bac62e-ab51-4b9c-9fd3-fdcb39299313",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ai.recommended_action }}",
                    "rightValue": "attio_update_only"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cec64faa-f63b-41ec-b646-2eaf24efb0a5",
      "name": "Lemlist \u2014 Enroll in Sequence",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2528,
        -416
      ],
      "parameters": {
        "url": "https://api.lemlist.com/api/campaigns/{{ $json.ai.lemlist_campaign_id }}/leads/{{ $json.email }}",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"firstName\": {{ JSON.stringify($json.first_name) }},\n  \"lastName\": {{ JSON.stringify($json.last_name) }},\n  \"companyName\": {{ JSON.stringify($json.company) }},\n  \"jobTitle\": {{ JSON.stringify($json.job_title) }},\n  \"plan\": {{ JSON.stringify($json.attio_plan) }},\n  \"pqlScore\": {{ $json.ai.updated_pql_score }},\n  \"personalizationHook\": {{ JSON.stringify($json.ai.personalization_hook) }},\n  \"eventTrigger\": {{ JSON.stringify($json.event_name) }},\n  \"icebreaker\": {{ JSON.stringify($json.ai.personalization_hook) }}\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "bfa4abce-0e1b-4453-a82e-c90096be16b9",
      "name": "Attio \u2014 Create Sales Task",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2528,
        -224
      ],
      "parameters": {
        "url": "https://api.attio.com/v2/tasks",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"data\": {\n    \"content\": {{ JSON.stringify(`\ud83d\udd25 PQL Alert: ${$json.first_name} ${$json.last_name} triggered '${$json.event_name}' \u2014 ${$json.ai.personalization_hook}`) }},\n    \"deadline_at\": {{ JSON.stringify($now.plus({ hours: 4 }).toISO()) }},\n    \"is_completed\": false,\n    \"linked_records\": [\n      { \"target_object\": \"people\", \"target_record_id\": {{ JSON.stringify($json.attio_contact_id) }} }\n    ]\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "4a1197b5-4b60-4b7c-85b2-0bcfc2d243d6",
      "name": "ActiveCampaign \u2014 Add to Upgrade Nurture",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2528,
        64
      ],
      "parameters": {
        "url": "https://api.activecampaign.com/api/3/contactLists",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"contactList\": {\n    \"list\": \"YOUR_AC_UPGRADE_NURTURE_LIST_ID\",\n    \"contact\": {{ JSON.stringify($json.email) }},\n    \"status\": \"1\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "3241bed8-296e-4cdc-a528-919bd919162c",
      "name": "Attio \u2014 Update PQL Attributes",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2752,
        -144
      ],
      "parameters": {
        "url": "=https://api.attio.com/v2/contacts/{{ $json.attio_contact_id }}",
        "method": "PATCH",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"data\": {\n    \"values\": {\n      \"pql_score\": [{ \"value\": {{ $json.ai.updated_pql_score }} }],\n      \"last_product_signal\": [{ \"value\": {{ JSON.stringify($json.event_name) }} }],\n      \"churn_risk_score\": [{ \"value\": {{ $json.ai.churn_risk }} }],\n      \"expansion_signal\": [{ \"value\": {{ $json.ai.expansion_signal }} }],\n      \"pql_classification\": [{ \"value\": {{ JSON.stringify($json.ai.pql_classification) }} }],\n      \"last_signal_at\": [{ \"value\": {{ JSON.stringify($json.received_at) }} }]\n    }\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "7e954721-5cb2-4d8a-921f-9cd2fe55e76f",
      "name": "Attio Deal Stage Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        704,
        592
      ],
      "parameters": {
        "path": "attio-deal-stage",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "d958797e-297a-40b9-abb9-d132fb5dfc62",
      "name": "Deal Webhook ACK",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        928,
        688
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={ \"received\": true }"
      },
      "typeVersion": 1.1
    },
    {
      "id": "2c3c2285-559f-4c17-9465-8ff766e3c919",
      "name": "Parse Attio Deal Event",
      "type": "n8n-nodes-base.code",
      "position": [
        928,
        496
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const body = $input.item.json.body ?? $input.item.json;\nconst event = body.event_type || '';\nconst deal = body.data || {};\nconst newStage = deal.values?.stage?.[0]?.value || deal.stage || '';\nconst oldStage = body.previous_data?.values?.stage?.[0]?.value || '';\nconst contactId = deal.values?.contacts?.[0]?.referenced_object?.id?.record_id || null;\nconst email = deal.values?.contact_email?.[0]?.email_address || deal.email || '';\nconst dealId = deal.id?.record_id || '';\nconst dealValue = parseFloat(deal.values?.value?.[0]?.amount || 0);\n\nconst STAGE_AC_LIST_MAP = {\n  'Qualified': 'YOUR_AC_QUALIFIED_LIST_ID',\n  'Demo Scheduled': 'YOUR_AC_DEMO_LIST_ID',\n  'Proposal Sent': 'YOUR_AC_PROPOSAL_LIST_ID',\n  'Negotiation': 'YOUR_AC_NEGOTIATION_LIST_ID',\n  'Closed Won': 'YOUR_AC_CUSTOMERS_LIST_ID',\n  'Closed Lost': 'YOUR_AC_LOST_LIST_ID'\n};\n\nreturn [{\n  json: {\n    deal_id: dealId,\n    contact_id: contactId,\n    email,\n    new_stage: newStage,\n    old_stage: oldStage,\n    deal_value: dealValue,\n    is_closed_won: newStage === 'Closed Won',\n    is_closed_lost: newStage === 'Closed Lost',\n    ac_target_list: STAGE_AC_LIST_MAP[newStage] || null,\n    changed_at: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "00859519-f429-44b6-a19b-00b5e26d620f",
      "name": "Get Full Contact from Attio",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1152,
        496
      ],
      "parameters": {
        "url": "=https://api.attio.com/v2/contacts/{{ $json.contact_id }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true
      },
      "typeVersion": 4.3
    },
    {
      "id": "7859e659-a2d8-4fb6-9415-82dd6117fd39",
      "name": "Get Segment Profile for Deal Contact",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1376,
        496
      ],
      "parameters": {
        "url": "=https://profiles.segment.com/v1/spaces/{{ $vars.SEGMENT_SPACE_ID }}/collections/users/profiles/email:{{ $json.email }}/traits",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true
      },
      "typeVersion": 4.3
    },
    {
      "id": "3ef02f6c-8bcd-4160-a5e0-fc797cc7b968",
      "name": "Merge Deal Context",
      "type": "n8n-nodes-base.code",
      "position": [
        1600,
        496
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const deal = $('Parse Attio Deal Event').item.json;\nconst attio = $('Get Full Contact from Attio').item.json?.data?.values || {};\nconst seg = $input.item.json?.traits || {};\n\nreturn [{\n  json: {\n    ...deal,\n    first_name: attio.first_name?.[0]?.value || seg.firstName || '',\n    last_name: attio.last_name?.[0]?.value || seg.lastName || '',\n    company: attio.company?.[0]?.referenced_object?.values?.name?.[0]?.value || seg.company || '',\n    job_title: attio.job_title?.[0]?.value || seg.title || '',\n    phone: attio.phone?.[0]?.value || '',\n    plan: attio.plan?.[0]?.value || 'free',\n    pql_score: parseFloat(attio.pql_score?.[0]?.value || 0),\n    // Segment product usage\n    sessions_14d: seg.sessions_14d || 0,\n    features_used: seg.features_used || 0,\n    key_actions: seg.key_actions_completed || 0,\n    last_seen: seg.last_seen_at || null\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "832e831f-5ddd-44b2-9b4a-a7da2b28fc9e",
      "name": "ActiveCampaign \u2014 Upsert Contact",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1824,
        496
      ],
      "parameters": {
        "url": "=https://{{ $vars.ACTIVECAMPAIGN_ACCOUNT }}.api-us1.com/api/3/contacts",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"contact\": {\n    \"email\": {{ JSON.stringify($json.email) }},\n    \"firstName\": {{ JSON.stringify($json.first_name) }},\n    \"lastName\": {{ JSON.stringify($json.last_name) }},\n    \"phone\": {{ JSON.stringify($json.phone) }},\n    \"fieldValues\": [\n      { \"field\": \"COMPANY\", \"value\": {{ JSON.stringify($json.company) }} },\n      { \"field\": \"JOB_TITLE\", \"value\": {{ JSON.stringify($json.job_title) }} },\n      { \"field\": \"PLAN\", \"value\": {{ JSON.stringify($json.plan) }} },\n      { \"field\": \"DEAL_STAGE\", \"value\": {{ JSON.stringify($json.new_stage) }} },\n      { \"field\": \"DEAL_VALUE\", \"value\": {{ JSON.stringify($json.deal_value) }} },\n      { \"field\": \"PQL_SCORE\", \"value\": {{ JSON.stringify($json.pql_score) }} },\n      { \"field\": \"SESSIONS_14D\", \"value\": {{ JSON.stringify($json.sessions_14d) }} },\n      { \"field\": \"FEATURES_USED\", \"value\": {{ JSON.stringify($json.features_used) }} },\n      { \"field\": \"ATTIO_DEAL_ID\", \"value\": {{ JSON.stringify($json.deal_id) }} },\n      { \"field\": \"STAGE_CHANGED_AT\", \"value\": {{ JSON.stringify($json.changed_at) }} }\n    ]\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "32716982-140e-4063-af18-2b343fface6a",
      "name": "Closed Won or Lost?",
      "type": "n8n-nodes-base.if",
      "position": [
        2048,
        496
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ff462482-9333-4e2f-8668-8579bb4176e2",
              "operator": {
                "type": "boolean",
                "operation": "true"
              },
              "leftValue": "={{ $json.is_closed_won }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "fdd6191b-5df4-4941-b033-c9e0eacc73f7",
      "name": "Lemlist \u2014 Remove from Prospect Campaign",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2272,
        400
      ],
      "parameters": {
        "url": "=https://api.lemlist.com/api/campaigns/YOUR_LEMLIST_PROSPECT_CAMPAIGN/leads/{{ $json.email }}",
        "method": "DELETE",
        "options": {},
        "sendHeaders": true
      },
      "typeVersion": 4.3
    },
    {
      "id": "6d678aca-0e16-4db8-bb85-03945076b7cb",
      "name": "Lemlist \u2014 Enroll in Re-engagement",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2272,
        592
      ],
      "parameters": {
        "url": "=https://api.lemlist.com/api/campaigns/YOUR_LEMLIST_REENGAGEMENT_CAMPAIGN/leads/{{ $json.email }}",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"firstName\": {{ JSON.stringify($json.first_name) }},\n  \"companyName\": {{ JSON.stringify($json.company) }},\n  \"lostStage\": {{ JSON.stringify($json.old_stage) }},\n  \"dealValue\": {{ $json.deal_value }}\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "2bc38e2e-2a83-4d7f-bce9-da491a69b710",
      "name": "Intercom Conversation Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        720,
        1280
      ],
      "parameters": {
        "path": "intercom-events",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "68bb6918-7c36-4b8d-9eb8-11c7c5ff9105",
      "name": "Intercom Webhook ACK",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        944,
        1376
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={ \"received\": true }"
      },
      "typeVersion": 1.1
    },
    {
      "id": "03ccf13c-70ea-40d3-9088-4d7cd8652d42",
      "name": "Parse Intercom Conversation",
      "type": "n8n-nodes-base.code",
      "position": [
        944,
        1184
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const body = $input.item.json.body ?? $input.item.json;\nconst topic = body.topic || '';\nconst data = body.data?.item || {};\n\n// Extract conversation details\nconst conversationId = data.id || '';\nconst contact = data.contacts?.contacts?.[0] || {};\nconst email = contact.email || data.source?.author?.email || '';\nconst contactId = contact.id || '';\n\n// Get conversation parts/messages\nconst parts = data.conversation_parts?.conversation_parts || [];\nconst latestMessage = parts[parts.length - 1]?.body || data.source?.body || '';\nconst allMessages = parts.map(p => p.body || '').filter(Boolean).join(' | ');\n\n// Tags on conversation\nconst tags = data.tags?.tags?.map(t => t.name) || [];\n\n// CSAT score if present\nconst csatRating = data.statistics?.csat_rating || null;\n\n// Filter for meaningful signals\nconst SALES_TAGS = ['sales-inquiry', 'upgrade-question', 'pricing', 'demo-request'];\nconst CHURN_TAGS = ['cancellation', 'churn-risk', 'unhappy', 'refund-request'];\n\nconst hasSalesTag = tags.some(t => SALES_TAGS.includes(t.toLowerCase()));\nconst hasChurnTag = tags.some(t => CHURN_TAGS.includes(t.toLowerCase()));\nconst isNewConversation = topic === 'conversation.user.created';\nconst isTagAdded = topic === 'conversation.tag.created';\n\nif (!hasSalesTag && !hasChurnTag && !isNewConversation) return [];\n\nreturn [{\n  json: {\n    topic,\n    conversation_id: conversationId,\n    email,\n    contact_id: contactId,\n    latest_message: latestMessage,\n    all_messages: allMessages.slice(0, 3000),\n    tags,\n    has_sales_tag: hasSalesTag,\n    has_churn_tag: hasChurnTag,\n    csat_rating: csatRating,\n    received_at: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "9d3c41a8-3d20-428b-85f5-da81ae43f241",
      "name": "Parse Intercom AI Output",
      "type": "n8n-nodes-base.code",
      "position": [
        1392,
        1184
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const raw = $input.item.json?.content?.[0]?.text ?? '';\nconst ctx = $('Parse Intercom Conversation').item.json;\nlet ai;\ntry {\n  ai = JSON.parse(raw.replace(/```json\\n?/g, '').replace(/```\\n?/g, '').trim());\n} catch(e) {\n  throw new Error('Claude parse failed: ' + raw.slice(0, 200));\n}\nreturn [{ json: { ...ctx, ai } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "c9a7378b-831e-4360-91c3-67ad5c7bdc8a",
      "name": "Intercom Signal Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        1616,
        1184
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "buying_intent",
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ai.signal_type }}",
                    "rightValue": "buying_intent"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "churn_risk",
              "conditions": {
                "options": {
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.ai.signal_type }}",
                    "rightValue": "churn_risk"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "none"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6e86f01e-38e5-4cdc-aa62-3091fb13a7b4",
      "name": "Attio \u2014 Create Deal from Intercom",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1840,
        992
      ],
      "parameters": {
        "url": "https://api.attio.com/v2/deals",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"data\": {\n    \"name\": {{ JSON.stringify(`Inbound: ${$json.email} via Intercom`) }},\n    \"stage\": \"Qualified\",\n    \"values\": {\n      \"source\": [{ \"value\": \"intercom-inbound\" }],\n      \"notes\": [{ \"value\": {{ JSON.stringify($json.ai.sales_note) }} }]\n    }\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "60c4857f-e140-4b0e-a011-64db8e611cfa",
      "name": "Lemlist \u2014 Enroll Inbound Lead",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1840,
        1184
      ],
      "parameters": {
        "url": "=https://api.lemlist.com/api/campaigns/YOUR_LEMLIST_INBOUND_CAMPAIGN/leads/{{ $json.email }}",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"icebreaker\": {{ JSON.stringify($json.ai.buying_signal_summary) }},\n  \"source\": \"intercom\",\n  \"conversationId\": {{ JSON.stringify($json.conversation_id) }}\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "1ad7d52b-85bf-4cf8-8c9a-752dff40110f",
      "name": "ActiveCampaign \u2014 Add to Churn Prevention",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1840,
        1376
      ],
      "parameters": {
        "url": "=https://{{ $vars.ACTIVECAMPAIGN_ACCOUNT }}.api-us1.com/api/3/contactLists",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contactList\": {\n    \"list\": \"YOUR_AC_CHURN_PREVENTION_LIST_ID\",\n    \"contact\": {{ JSON.stringify($json.email) }},\n    \"status\": \"1\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "04c08927-f32f-46a1-a5ac-a369b4556734",
      "name": "Daily 7AM \u2014 PQL Score Run",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        736,
        1904
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "2cdd69f2-4da6-4ae6-bd74-519eccc4f966",
      "name": "Get All Trial + Free Users from Attio",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        960,
        1904
      ],
      "parameters": {
        "url": "https://api.attio.com/v2/contacts",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "filter[stage][in]",
              "value": "Trial,Free"
            },
            {
              "name": "limit",
              "value": "200"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "6987c7a8-a526-43fa-8ec3-5f47ae3c3be6",
      "name": "Split Trial Users",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1184,
        1904
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "data"
      },
      "typeVersion": 1
    },
    {
      "id": "e14274f0-8411-41f8-bc33-6c6717e737ff",
      "name": "Fetch Segment Profile per User",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1408,
        1904
      ],
      "parameters": {
        "url": "=https://profiles.segment.com/v1/spaces/{{ $vars.SEGMENT_SPACE_ID }}/collections/users/profiles/email:{{ $json.values?.email?.[0]?.email_address }}/traits",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true
      },
      "typeVersion": 4.3
    },
    {
      "id": "241745b4-005e-49da-9582-09cf64ec97e3",
      "name": "Calculate PQL Score per User",
      "type": "n8n-nodes-base.code",
      "position": [
        1632,
        1904
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const attio = $('Split Trial Users').item.json?.values || {};\nconst seg = $input.item.json?.traits || {};\n\nconst email = attio.email?.[0]?.email_address || '';\nconst accountAgeDays = Math.floor((Date.now() - new Date(attio.created_at?.[0]?.value || Date.now())) / 86400000);\n\n// PQL scoring model\nconst sessions = seg.sessions_14d || 0;\nconst features = seg.features_used || 0;\nconst keyActions = seg.key_actions_completed || 0;\nconst invitesSent = seg.invites_sent || 0;\nconst daysSinceLastSeen = seg.days_since_last_seen || 99;\n\n// Weighted score\nconst activationScore = Math.min(30, keyActions * 10);\nconst depthScore = Math.min(25, features * 5);\nconst breadthScore = Math.min(20, sessions * 2);\nconst viralScore = Math.min(15, invitesSent * 5);\nconst recencyScore = daysSinceLastSeen <= 3 ? 10 : daysSinceLastSeen <= 7 ? 6 : daysSinceLastSeen <= 14 ? 3 : 0;\n\nconst pqlScore = activationScore + depthScore + breadthScore + viralScore + recencyScore;\n\n// Classify\nlet pqlTier;\nif (pqlScore >= 70) pqlTier = 'hot';\nelse if (pqlScore >= 40) pqlTier = 'warm';\nelse pqlTier = 'cold';\n\n// Trial expiry check\nconst trialEndsAt = attio.trial_ends_at?.[0]?.value || null;\nconst daysUntilExpiry = trialEndsAt\n  ? Math.floor((new Date(trialEndsAt) - Date.now()) / 86400000)\n  : null;\n\nconst isTrialExpiringSoon = daysUntilExpiry !== null && daysUntilExpiry <= 3 && daysUntilExpiry >= 0;\n\nreturn [{\n  json: {\n    email,\n    attio_contact_id: $('Split Trial Users').item.json?.id?.record_id || null,\n    first_name: attio.first_name?.[0]?.value || '',\n    company: attio.company?.[0]?.referenced_object?.values?.name?.[0]?.value || '',\n    account_age_days: accountAgeDays,\n    pql_score: pqlScore,\n    pql_tier: pqlTier,\n    activation_score: activationScore,\n    depth_score: depthScore,\n    sessions_14d: sessions,\n    features_used: features,\n    key_actions: keyActions,\n    days_since_last_seen: daysSinceLastSeen,\n    trial_ends_at: trialEndsAt,\n    days_until_expiry: daysUntilExpiry,\n    is_trial_expiring_soon: isTrialExpiringSoon,\n    should_enroll_lemlist: pqlScore >= 70,\n    should_reengage: daysSinceLastSeen > 14 && pqlScore < 30\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "6010a766-9e25-4998-8813-9e24ec69967e",
      "name": "Attio \u2014 Update Daily PQL Score",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1856,
        1904
      ],
      "parameters": {
        "url": "=https://api.attio.com/v2/contacts/{{ $json.attio_contact_id }}",
        "method": "PATCH",
        "options": {},
        "jsonBody": "={\n  \"data\": {\n    \"values\": {\n      \"pql_score\": [{ \"value\": {{ $json.pql_score }} }],\n      \"pql_tier\": [{ \"value\": {{ JSON.stringify($json.pql_tier) }} }],\n      \"sessions_14d\": [{ \"value\": {{ $json.sessions_14d }} }],\n      \"features_used\": [{ \"value\": {{ $json.features_used }} }],\n      \"days_since_last_seen\": [{ \"value\": {{ $json.days_since_last_seen }} }],\n      \"pql_scored_at\": [{ \"value\": {{ JSON.stringify(new Date().toISOString()) }} }]\n    }\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "5e1575f6-a54a-4fb0-b600-f07fba9c8342",
      "name": "Hot PQL \u2014 Enroll Lemlist?",
      "type": "n8n-nodes-base.if",
      "position": [
        2080,
        1808
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "boolean",
                "operation": "true"
              },
              "leftValue": "={{ $json.should_enroll_lemlist }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "58b75b48-6d5f-4adf-8f8e-62c747ccd393",
      "name": "Lemlist \u2014 Trial Conversion Sequence",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2304,
        1808
      ],
      "parameters": {
        "url": "=https://api.lemlist.com/api/campaigns/YOUR_LEMLIST_TRIAL_CONVERSION_CAMPAIGN/leads/{{ $json.email }}",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"firstName\": {{ JSON.stringify($json.first_name) }},\n  \"companyName\": {{ JSON.stringify($json.company) }},\n  \"pqlScore\": {{ $json.pql_score }},\n  \"featuresUsed\": {{ $json.features_used }},\n  \"daysUntilExpiry\": {{ $json.days_until_expiry || 0 }},\n  \"trialExpiringSoon\": {{ $json.is_trial_expiring_soon }}\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "7cb334ea-7d9a-4ea7-9f2d-30fb591a4ad8",
      "name": "Stale Trial \u2014 Re-engage?",
      "type": "n8n-nodes-base.if",
      "position": [
        2080,
        2000
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "boolean",
                "operation": "true"
              },
              "leftValue": "={{ $json.should_reengage }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bdb4869c-fc74-45d6-838d-c1d4d5198ddb",
      "name": "ActiveCampaign \u2014 Stale Trial Re-engage",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2304,
        2000
      ],
      "parameters": {
        "url": "=https://{{ $vars.ACTIVECAMPAIGN_ACCOUNT }}.api-us1.com/api/3/contactLists",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contactList\": {\n    \"list\": \"YOUR_AC_TRIAL_REENGAGEMENT_LIST_ID\",\n    \"contact\": {{ JSON.stringify($json.email) }},\n    \"status\": \"1\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "e630e60d-0362-4e0e-a523-0214ce129fa3",
      "name": "Analyze document",
      "type": "@n8n/n8n-nodes-langchain.anthropic",
      "position": [
        1856,
        -144
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "claude-opus-4-7",
          "cachedResultName": "claude-opus-4-7"
        },
        "options": {},
        "resource": "document"
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "da162410-ddca-4110-9e54-0997febb1f2d",
      "name": "Get a conversation",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1168,
        1184
      ],
      "parameters": {
        "resource": "conversation",
        "operation": "get",
        "conversationId": "{{ $vars.CONVERSATION_ID }}"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "aaa1b72b-934f-4f0d-aa35-2ea2d463bd33",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -256
      ],
      "parameters": {
        "width": 656,
        "height": 1088,
        "content": "## AI-Powered PLG Revenue Engine: Segment, Attio & Outreach Sync\n\nThis workflow bridges the gap between raw product data and revenue sales tools. It automates the entire Product Qualified Lead (PQL) lifecycle\u2014from real-time intent routing to churn prevention\u2014reducing SalesOps overhead by 80%.\n\n## Who\u2019s it for\n* **B2B SaaS Teams** looking to automate PQL outreach based on product usage.\n* **Revenue Ops** needing to sync Attio CRM, ActiveCampaign, and Lemlist.\n* **Growth Teams** requiring real-time AI classification of user intent.\n\n## How it works\n* **Real-Time Intent Routing:** Segment webhooks trigger Claude AI to classify PQLs. High-intent users are instantly moved to Lemlist for outreach.\n* **Deal Progression Sync:** Changes in Attio deal stages automatically update ActiveCampaign nurture lists and Segment profiles.\n* **Intercom Revenue Signals:** AI scans Intercom conversations for buying signals or churn risks, creating Attio deals or churn prevention tasks.\n* **Daily PQL Scoring:** Every morning at 7 AM, the workflow scores trial users across 5 dimensions, enrolling \"Hot\" leads into conversion sequences.\n\n## How to set up\n1. **Node Configuration:** Manually enter your specific **Campaign IDs** in the Lemlist nodes and **List IDs** in the ActiveCampaign nodes.\n2. **Credentials:** Set up official n8n credentials for Attio, Segment, Anthropic (Claude), Lemlist, Intercom, and ActiveCampaign.\n3. **Webhook Mapping:** Connect your Segment and Intercom webhook URLs to the respective Trigger nodes.\n4. **Attio Schema:** Ensure your Attio workspace includes custom attributes for `pql_score`, `pql_tier`, and `churn_risk_score`.\n\n## Requirements\n* **n8n version:** 1.0+\n* **AI Credits:** Anthropic (Claude) and OpenAI (for Intercom analysis).\n* **Tech Stack:** Segment, Attio CRM, ActiveCampaign, Lemlist, and Intercom.\n\n## Results\n* **65% Increase** in trial-to-PQL conversion rates.\n* **Outreach speed** improved from 3 days to under 10 minutes.\n* **80% reduction** in manual SalesOps and Revenue Ops overhead."
      },
      "typeVersion": 1
    },
    {
      "id": "b5af78e8-27a4-434d-9289-9ba7e1c10f9c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1824,
        -256
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 348,
        "content": "## 2. AI Classification\nClaude AI analyzes the merged data context to classify the user's intent and recommend the next sales action."
      },
      "typeVersion": 1
    },
    {
      "id": "93673fa6-9e7c-4e9d-8af7-f2086044bcff",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2208,
        -512
      ],
      "parameters": {
        "color": 7,
        "width": 800,
        "height": 788,
        "content": "## 3. Revenue Routing\nExecutes the recommended outreach (Lemlist/AC) and syncs the updated PQL scores back to the Attio record."
      },
      "typeVersion": 1
    },
    {
      "id": "66feb84f-c92c-4c9f-af97-b603f51e1d0f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        -256
      ],
      "parameters": {
        "color": 7,
        "width": 1112,
        "height": 476,
        "content": "## 1. Trigger & Enrichment\nCaptures the Segment webhook and enriches the lead with CRM data from Attio and profile traits from Segment."
      },
      "typeVersion": 1
    },
    {
      "id": "114aca6e-8098-46ae-9675-12f987815672",
      "name": "Flow 2 Section 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        400
      ],
      "parameters": {
        "color": 7,
        "width": 1056,
        "height": 444,
        "content": "## 1. CRM & Profile Enrichment\nTriggers on Attio deal changes and pulls the complete contact profile from both Attio and Segment to build a full data context."
      },
      "typeVersion": 1
    },
    {
      "id": "93d771c6-133c-47e4-9599-f23d9c4a98af",
      "name": "Flow 2 Section 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        304
      ],
      "parameters": {
        "color": 7,
        "width": 840,
        "height": 452,
        "content": "## 2. Marketing Sync & Outcome Routing\nUpserts data to ActiveCampaign and routes the user to either the Onboarding or Re-engagement sequence based on the deal outcome."
      },
      "typeVersion": 1
    },
    {
      "id": "2cbba09d-920e-42fd-9940-f84ec8467505",
      "name": "Flow 3 Section 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        1056
      ],
      "parameters": {
        "color": 7,
        "width": 888,
        "height": 540,
        "content": "## 1. AI Transcript Analysis\nReceives Intercom webhooks and uses AI to parse conversation transcripts, identifying key signals like buying intent or churn risk."
      },
      "typeVersion": 1
    },
    {
      "id": "eae870ea-aca4-4ec3-9125-cc00e6927c19",
      "name": "Flow 3 Section 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        880
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 724,
        "content": "## 2. Intent-Based Routing\nRoutes signals to the appropriate revenue stack action: creating deals in Attio, enrolling leads in Lemlist, or triggering churn prevention in ActiveCampaign."
      },
      "typeVersion": 1
    },
    {
      "id": "4b82289b-510f-4c4e-8379-27b34bb1c54f",
      "name": "Flow 4 Section 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        1792
      ],
      "parameters": {
        "color": 7,
        "width": 1320,
        "height": 332,
        "content": "## 1. Batch Data Processing & Scoring\nRuns daily to fetch all trial/free users, enrich them with Segment product usage data, and calculate a multi-dimensional PQL score."
      },
      "typeVersion": 1
    },
    {
      "id": "18513bf6-71ae-4ad1-9c3f-bd5e71854dd5",
      "name": "Flow 4 Section 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2032,
        1648
      ],
      "parameters": {
        "color": 7,
        "width": 460,
        "height": 560,
        "content": "## 2. Automated outreach Logic\nFilters users based on their fresh PQL scores to either trigger a conversion sequence in Lemlist or a re-engagement flow in ActiveCampaign."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "f97d1bef-734d-4d24-be8b-d13f8d130bf2",
  "connections": {
    "Analyze document": {
      "main": [
        [
          {
            "node": "Parse Claude PQL Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge PQL Context": {
      "main": [
        [
          {
            "node": "Analyze document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PQL Action Router": {
      "main": [
        [
          {
            "node": "Lemlist \u2014 Enroll in Sequence",
            "type": "main",
            "index": 0
          },
          {
            "node": "Attio \u2014 Create Sales Task",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ActiveCampaign \u2014 Add to Upgrade Nurture",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Attio \u2014 Update PQL Attributes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Trial Users": {
      "main": [
        [
          {
            "node": "Fetch Segment Profile per User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a conversation": {
      "main": [
        [
          {
            "node": "Parse Intercom AI Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Deal Context": {
      "main": [
        [
          {
            "node": "ActiveCampaign \u2014 Upsert Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Closed Won or Lost?": {
      "main": [
        [
          {
            "node": "Lemlist \u2014 Remove from Prospect Campaign",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Lemlist \u2014 Enroll in Re-engagement",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Segment Event": {
      "main": [
        [
          {
            "node": "Get Contact from Attio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Segment Event Webhook": {
      "main": [
        [
          {
            "node": "Parse Segment Event",
            "type": "main",
            "index": 0
          },
          {
            "node": "Segment Webhook ACK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Contact from Attio": {
      "main": [
        [
          {
            "node": "Pull Segment User Profile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Intercom Signal Router": {
      "main": [
        [
          {
            "node": "Attio \u2014 Create Deal from Intercom",
            "type": "main",
            "index": 0
          },
          {
            "node": "Lemlist \u2014 Enroll Inbound Lead",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "ActiveCampaign \u2014 Add to Churn Prevention",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Attio Deal Event": {
      "main": [
        [
          {
            "node": "Get Full Contact from Attio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Claude PQL Output": {
      "main": [
        [
          {
            "node": "PQL Action Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Attio Deal Stage Webhook": {
      "main": [
        [
          {
            "node": "Parse Attio Deal Event",
            "type": "main",
            "index": 0
          },
          {
            "node": "Deal Webhook ACK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Intercom AI Output": {
      "main": [
        [
          {
            "node": "Intercom Signal Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pull Segment User Profile": {
      "main": [
        [
          {
            "node": "Merge PQL Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stale Trial \u2014 Re-engage?": {
      "main": [
        [
          {
            "node": "ActiveCampaign \u2014 Stale Trial Re-engage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily 7AM \u2014 PQL Score Run": {
      "main": [
        [
          {
            "node": "Get All Trial + Free Users from Attio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Full Contact from Attio": {
      "main": [
        [
          {
            "node": "Get Segment Profile for Deal Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hot PQL \u2014 Enroll Lemlist?": {
      "main": [
        [
          {
            "node": "Lemlist \u2014 Trial Conversion Sequence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Intercom Conversation": {
      "main": [
        [
          {
            "node": "Get a conversation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate PQL Score per User": {
      "main": [
        [
          {
            "node": "Attio \u2014 Update Daily PQL Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Intercom Conversation Webhook": {
      "main": [
        [
          {
            "node": "Parse Intercom Conversation",
            "type": "main",
            "index": 0
          },
          {
            "node": "Intercom Webhook ACK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Segment Profile per User": {
      "main": [
        [
          {
            "node": "Calculate PQL Score per User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lemlist \u2014 Enroll in Sequence": {
      "main": [
        [
          {
            "node": "Attio \u2014 Update PQL Attributes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Attio \u2014 Update Daily PQL Score": {
      "main": [
        [
          {
            "node": "Hot PQL \u2014 Enroll Lemlist?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Stale Trial \u2014 Re-engage?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ActiveCampaign \u2014 Upsert Contact": {
      "main": [
        [
          {
            "node": "Closed Won or Lost?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Segment Profile for Deal Contact": {
      "main": [
        [
          {
            "node": "Merge Deal Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All Trial + Free Users from Attio": {
      "main": [
        [
          {
            "node": "Split Trial Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ActiveCampaign \u2014 Add to Upgrade Nurture": {
      "main": [
        [
          {
            "node": "Attio \u2014 Update PQL Attributes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}