{
  "format": "revenanas.clay-workflow/v1",
  "name": "Revenanas Library - Qualified Account to Gated Lemlist",
  "slug": "clay-qualified-account-gated-lemlist",
  "description": "For each account entering a qualified Audiences segment, find and rank a security or compliance buyer, verify a work email, write a signal-led message, record it in HubSpot, and add the lead to Lemlist only behind an explicit three-condition gate.",
  "source": {
    "builder": "Clay official Terracotta CLI",
    "workspace_type": "Revenanas enterprise test",
    "workflow_id": "wf_0tltie754YuTMbftgpq",
    "exported": "2026-09-25",
    "last_tested": "2026-09-23",
    "published": false
  },
  "verification": {
    "graph_valid": true,
    "passing_run_ids": [
      "wfr_088c365f665ab4ad0c30f3d535d44ec4",
      "wfr_d4461f21867ded73c054863e66bdc196"
    ],
    "changes_from_tested_build": [
      "Lemlist approval flag ships False and the campaign ID ships blank; the demo build hard-coded both against a paused campaign.",
      "Removed an unapproved vendor proof point from the message copy."
    ]
  },
  "requires": [
    "A Clay Audiences company segment of Qualified accounts, passed with --set qualified_segment_id=<id>.",
    "HubSpot and Lemlist connected in Clay; a paused Lemlist campaign."
  ],
  "trigger": {
    "key": "trigger",
    "spec": {
      "triggerType": "audience_segment",
      "entityType": "ACCOUNT",
      "segmentId": "{{set:qualified_segment_id}}"
    }
  },
  "nodes": [
    {
      "key": "find_security_and_compliance_buyers",
      "spec": {
        "name": "Find security and compliance buyers",
        "description": "Finds up to five current security, compliance, privacy, risk, or technology leaders for every account entering the dynamic Claygent-qualified audience.",
        "nodeType": "tool",
        "tools": [
          {
            "toolType": "clay_action",
            "actionKey": "cpj-find-lists-of-people-v2",
            "actionPackageId": "e251a70e-46d7-4f3a-b3ef-a211ad3d8bd2",
            "inputMappingConfig": {
              "limit": {
                "type": "static",
                "value": 5
              },
              "job_title_mode": {
                "type": "static",
                "value": "smart"
              },
              "identifiers_only": {
                "type": "static",
                "value": false
              },
              "company_identifier": {
                "type": "reference",
                "expression": "{{target_domain}}"
              },
              "job_title_keywords": {
                "type": "static",
                "value": "chief information security officer, director of information security, information security manager, compliance and data protection, chief technology officer, chief information officer, CISO, CTO, CIO, compliance, privacy, risk"
              },
              "company_identifier_type": {
                "type": "static",
                "value": "company_domain"
              },
              "include_past_experiences": {
                "type": "static",
                "value": false
              }
            }
          }
        ],
        "inputSchema": {
          "type": "object",
          "properties": {
            "target_domain": {
              "type": "string",
              "sourceNodeId": "{{trigger}}",
              "sourcePath": "$.fields.Domain"
            }
          }
        },
        "incomingEdges": [
          {
            "sourceNode": "{{trigger}}"
          }
        ]
      }
    },
    {
      "key": "select_the_best_security_buyer",
      "spec": {
        "name": "Select the best security buyer",
        "description": "Ranks security and compliance professionals by job title relevance and selects the highest-scoring prospect. CISOs and directors of information security score highest, while junior and assistant roles score lower. Returns the selected person's details, cleaned name and title, LinkedIn URL, and selection score along with campaign information for outreach.",
        "nodeType": "code",
        "inputSchema": {
          "type": "object",
          "properties": {
            "people": {
              "type": "array",
              "items": {
                "type": "object"
              },
              "sourceNodeId": "{{find_security_and_compliance_buyers}}",
              "sourcePath": "$.result.people"
            },
            "target_domain": {
              "type": "string",
              "sourceNodeId": "{{trigger}}",
              "sourcePath": "$.fields.Domain"
            },
            "signal_summary": {
              "type": "string",
              "sourceNodeId": "{{trigger}}",
              "sourcePath": "$[\"fields\"][\"[DEMO] Vanta Signal Summary\"]"
            },
            "target_company": {
              "type": "string",
              "sourceNodeId": "{{trigger}}",
              "sourcePath": "$[\"fields\"][\"Company name\"]"
            },
            "signal_evidence_url": {
              "type": "string",
              "sourceNodeId": "{{trigger}}",
              "sourcePath": "$[\"fields\"][\"[DEMO] Vanta Evidence URL\"]"
            },
            "inherited_why_we_won": {
              "type": "string",
              "sourceNodeId": "{{trigger}}",
              "sourcePath": "$[\"fields\"][\"[DEMO] Vanta HubSpot Why We Won\"]"
            }
          }
        },
        "outputSchema": {
          "campaign_id": {
            "type": "string",
            "description": "Workflow output: campaign_id"
          },
          "people_found": {
            "type": "number",
            "description": "Workflow output: people_found"
          },
          "selected_name": {
            "type": "string",
            "description": "Workflow output: selected_name"
          },
          "target_domain": {
            "type": "string",
            "description": "Workflow output: target_domain"
          },
          "selected_title": {
            "type": "string",
            "description": "Workflow output: selected_title"
          },
          "signal_summary": {
            "type": "string",
            "description": "Workflow output: signal_summary"
          },
          "target_company": {
            "type": "string",
            "description": "Workflow output: target_company"
          },
          "selection_score": {
            "type": "number",
            "description": "Workflow output: selection_score"
          },
          "send_to_lemlist": {
            "type": "boolean",
            "description": "Workflow output: send_to_lemlist"
          },
          "selected_last_name": {
            "type": "string",
            "description": "Workflow output: selected_last_name"
          },
          "selected_first_name": {
            "type": "string",
            "description": "Workflow output: selected_first_name"
          },
          "signal_evidence_url": {
            "type": "string",
            "description": "Workflow output: signal_evidence_url"
          },
          "inherited_why_we_won": {
            "type": "string",
            "description": "Workflow output: inherited_why_we_won"
          },
          "selected_linkedin_url": {
            "type": "string",
            "description": "Workflow output: selected_linkedin_url"
          }
        },
        "code": "def score(person):\n    title = str(person.get('title') or '').lower()\n    points = 0\n    if 'chief information security' in title or 'ciso' in title:\n        points += 120\n    if 'director of information security' in title:\n        points += 115\n    if 'information security manager' in title:\n        points += 110\n    if 'data protection' in title:\n        points += 105\n    if 'compliance' in title:\n        points += 90\n    if 'chief technology' in title or title.strip() == 'cto':\n        points += 80\n    if 'chief information officer' in title or title.strip() == 'cio':\n        points += 75\n    if 'risk' in title:\n        points += 65\n    if 'junior' in title or 'assistant' in title:\n        points -= 70\n    return points\n\ndef handler(context):\n    people = context.get_input('people') or []\n    ranked = sorted(people, key=lambda item: (-score(item), str(item.get('name') or '')))\n    person = ranked[0] if ranked else {}\n    name = str(person.get('name') or '').strip()\n    clean_name = name\n    for marker in [' CIPP', ' CIPM', ' CIS ', ' CISM', ' MA,', ' MBA', ' PhD']:\n        if marker in clean_name:\n            clean_name = clean_name.split(marker, 1)[0].strip()\n    parts = clean_name.split()\n    return {\n        'target_company': str(context.get_input('target_company') or ''),\n        'target_domain': str(context.get_input('target_domain') or ''),\n        'signal_summary': str(context.get_input('signal_summary') or ''),\n        'signal_evidence_url': str(context.get_input('signal_evidence_url') or ''),\n        'inherited_why_we_won': str(context.get_input('inherited_why_we_won') or ''),\n        'campaign_id': str(context.get_input('campaign_id') or ''),\n        'send_to_lemlist': bool(context.get_input('send_to_lemlist') or False),\n        'people_found': len(people),\n        'selected_name': clean_name,\n        'selected_first_name': parts[0] if parts else '',\n        'selected_last_name': ' '.join(parts[1:]) if len(parts) > 1 else '',\n        'selected_title': str(person.get('title') or ''),\n        'selected_linkedin_url': str(person.get('url') or ''),\n        'selection_score': score(person) if person else 0\n    }",
        "incomingEdges": [
          {
            "sourceNode": "{{find_security_and_compliance_buyers}}"
          }
        ]
      }
    },
    {
      "key": "find_verified_work_email",
      "spec": {
        "name": "Find verified work email",
        "description": "Finds a verified work email address for the person identified by their LinkedIn profile. Uses the LinkedIn URL from the previous node to locate a valid business email.",
        "nodeType": "tool",
        "tools": [
          {
            "toolType": "clay_action",
            "actionKey": "findymail-find-work-email-from-linkedin",
            "actionPackageId": "9515bb04-4267-4074-94eb-653545c3c38f",
            "inputMappingConfig": {
              "profile_url": {
                "type": "reference",
                "expression": "{{selected_linkedin_url}}"
              }
            }
          }
        ],
        "inputSchema": {
          "type": "object",
          "properties": {
            "selected_linkedin_url": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.selected_linkedin_url"
            }
          }
        },
        "incomingEdges": [
          {
            "sourceNode": "{{select_the_best_security_buyer}}"
          }
        ]
      }
    },
    {
      "key": "write_tender_led_vanta_message",
      "spec": {
        "name": "Write tender-led Vanta message",
        "description": "Generates a personalized cold email to security buyers at companies with active public-sector procurement activity, using their procurement signal and role to position Vanta's evidence automation. The email includes a subject line, opening hook, and call to compare Vanta's compliance capabilities. Marks the message ready to send only if a verified email address is available.",
        "nodeType": "code",
        "inputSchema": {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "sourceNodeId": "{{find_verified_work_email}}",
              "sourcePath": "$.result.email"
            },
            "full_name": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.selected_name"
            },
            "last_name": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.selected_last_name"
            },
            "first_name": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.selected_first_name"
            },
            "campaign_id": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.campaign_id"
            },
            "email_status": {
              "type": "string",
              "sourceNodeId": "{{find_verified_work_email}}",
              "sourcePath": "$.result.status"
            },
            "linkedin_url": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.selected_linkedin_url"
            },
            "target_domain": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.target_domain"
            },
            "selected_title": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.selected_title"
            },
            "signal_summary": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.signal_summary"
            },
            "target_company": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.target_company"
            },
            "send_to_lemlist": {
              "type": "boolean",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.send_to_lemlist"
            },
            "signal_evidence_url": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.signal_evidence_url"
            },
            "inherited_why_we_won": {
              "type": "string",
              "sourceNodeId": "{{select_the_best_security_buyer}}",
              "sourcePath": "$.inherited_why_we_won"
            }
          }
        },
        "outputSchema": {
          "email": {
            "type": "string",
            "description": "Workflow output: email"
          },
          "title": {
            "type": "string",
            "description": "Workflow output: title"
          },
          "subject": {
            "type": "string",
            "description": "Workflow output: subject"
          },
          "full_name": {
            "type": "string",
            "description": "Workflow output: full_name"
          },
          "last_name": {
            "type": "string",
            "description": "Workflow output: last_name"
          },
          "email_body": {
            "type": "string",
            "description": "Workflow output: email_body"
          },
          "first_name": {
            "type": "string",
            "description": "Workflow output: first_name"
          },
          "icebreaker": {
            "type": "string",
            "description": "Workflow output: icebreaker"
          },
          "campaign_id": {
            "type": "string",
            "description": "Workflow output: campaign_id"
          },
          "email_status": {
            "type": "string",
            "description": "Workflow output: email_status"
          },
          "linkedin_url": {
            "type": "string",
            "description": "Workflow output: linkedin_url"
          },
          "target_domain": {
            "type": "string",
            "description": "Workflow output: target_domain"
          },
          "signal_summary": {
            "type": "string",
            "description": "Workflow output: signal_summary"
          },
          "target_company": {
            "type": "string",
            "description": "Workflow output: target_company"
          },
          "delivery_status": {
            "type": "string",
            "description": "Workflow output: delivery_status"
          },
          "demo_disclaimer": {
            "type": "string",
            "description": "Workflow output: demo_disclaimer"
          },
          "send_to_lemlist": {
            "type": "boolean",
            "description": "Workflow output: send_to_lemlist"
          },
          "signal_evidence_url": {
            "type": "string",
            "description": "Workflow output: signal_evidence_url"
          }
        },
        "code": "import re\n\ndef handler(context):\n    first = str(context.get_input('first_name') or '').strip()\n    company = str(context.get_input('target_company') or '').strip()\n    title = str(context.get_input('selected_title') or '').strip()\n    raw_signal = str(context.get_input('signal_summary') or '').strip().rstrip('.')\n    email = str(context.get_input('email') or '').strip()\n    domain = str(context.get_input('target_domain') or '').strip().lower()\n    slug = ''.join(ch if ch.isalnum() else '_' for ch in domain).strip('_')\n\n    internal_terms = ('hubspot', 'win pattern', 'aligning', 'official notice', 'procurement notice', 'supplier identity', 'qualification')\n    signal_line = raw_signal\n    if not signal_line or len(signal_line.split()) > 24 or any(term in signal_line.lower() for term in internal_terms):\n        quoted = re.search(r'[\\\"“]([^\\\"”]{5,100})[\\\"”]', raw_signal)\n        parenthetical = re.search(r'\\(([^()]{5,100})\\)', raw_signal)\n        tender_name = (quoted.group(1) if quoted else (parenthetical.group(1) if parenthetical else '')).strip()\n        tender_name = re.sub(r'^(the\\s+)', '', tender_name, flags=re.I)\n        signal_line = f'{company} won the {tender_name} tender' if tender_name else f'{company} won a recent public-sector software tender'\n\n    subject = f'{company} public-sector assurance'\n    icebreaker = f'I saw {signal_line}'\n    role_line = f'Given your role as {title},' if title else 'Given your remit,'\n    body = (\n        f'Hi {first or \"there\"},\\n\\n'\n        f'{icebreaker}. That usually creates a second deadline: keeping ISO 27001 evidence, supplier controls and security questionnaires current throughout delivery.\\n\\n'\n        'Teams in this position usually automate that evidence collection so assurance is ready by contract signature rather than rebuilt afterwards.\\n\\n'\n        f'{role_line} would a 15-minute comparison be useful?'\n    )\n    evidence_url = str(context.get_input('signal_evidence_url') or '')\n    return {\n        'target_company': company,\n        'target_domain': domain,\n        'safe_crm_domain': f'qualified-{slug.replace(\"_\", \"-\")}.example.com',\n        'demo_key': f'qualified_live_{slug}',\n        'first_name': first,\n        'last_name': str(context.get_input('last_name') or ''),\n        'full_name': str(context.get_input('full_name') or ''),\n        'title': title,\n        'linkedin_url': str(context.get_input('linkedin_url') or ''),\n        'email': email,\n        'email_status': str(context.get_input('email_status') or ''),\n        'campaign_id': '',  # paste a PAUSED Lemlist campaign ID\n        'send_to_lemlist': False,  # set True only after reviewing the copy\n        'signal_summary': signal_line + '.',\n        'signal_evidence_url': evidence_url,\n        'inherited_why_we_won': str(context.get_input('inherited_why_we_won') or ''),\n        'subject': subject,\n        'icebreaker': icebreaker,\n        'email_body': body,\n        'delivery_status': 'ready_for_paused_campaign' if email else 'held_no_verified_email',\n        'custom_fields': {\n            'clay_subject': subject,\n            'clay_message': body,\n            'signal_url': evidence_url,\n            'job_title': title\n        },\n        'demo_disclaimer': 'Synthetic demo draft generated from public procurement evidence; have a person review the copy before any real send.'\n    }",
        "incomingEdges": [
          {
            "sourceNode": "{{find_verified_work_email}}"
          }
        ]
      }
    },
    {
      "key": "create_qualified_company_in_hubspot",
      "spec": {
        "name": "Create qualified company in HubSpot",
        "description": "Creates the synthetic qualified lookalike in HubSpot from the Clay audience record, including the inherited closed-won context, live tender signal, selected buyer, and drafted message.",
        "nodeType": "tool",
        "tools": [
          {
            "toolType": "clay_action",
            "actionKey": "hubspot-create-object",
            "actionPackageId": "a2584689-b965-4a25-847d-17b7abcddca3",
            "appAccountName": "Jack- Test ",
            "inputMappingConfig": {
              "fields|name": {
                "type": "reference",
                "expression": "[DEMO] {{target_company}} — Qualified Vanta Lookalike"
              },
              "fields|type": {
                "type": "static",
                "value": "PROSPECT"
              },
              "objectTypeId": {
                "type": "static",
                "value": "0-2"
              },
              "fields|domain": {
                "type": "reference",
                "expression": "{{safe_crm_domain}}"
              },
              "includeSubdomains": {
                "type": "static",
                "value": true
              },
              "fields|description": {
                "type": "static",
                "value": "SYNTHETIC DEMO PROSPECT — qualification evidence is public; CRM status and outreach are demo-only."
              },
              "fields|demo_vanta_key": {
                "type": "reference",
                "expression": "{{demo_key}}"
              },
              "fields|demo_vanta_record": {
                "type": "static",
                "value": "true"
              },
              "fields|demo_vanta_why_we_won": {
                "type": "reference",
                "expression": "{{inherited_why_we_won}}"
              },
              "fields|demo_vanta_clay_domain": {
                "type": "reference",
                "expression": "{{target_domain}}"
              },
              "fields|demo_vanta_message_body": {
                "type": "reference",
                "expression": "{{email_body}}"
              },
              "fields|demo_vanta_target_email": {
                "type": "reference",
                "expression": "{{email}}"
              },
              "fields|demo_vanta_target_title": {
                "type": "reference",
                "expression": "{{title}}"
              },
              "fields|demo_vanta_target_person": {
                "type": "reference",
                "expression": "{{full_name}}"
              },
              "fields|demo_vanta_segment_status": {
                "type": "static",
                "value": "lookalike_qualified"
              },
              "fields|demo_vanta_winning_signal": {
                "type": "static",
                "value": "public_sector_tender"
              },
              "fields|demo_vanta_meddpic_summary": {
                "type": "static",
                "value": "Pre-discovery hypothesis: public procurement increases the volume, freshness, and auditability requirements for security evidence. Validate metrics, decision process, and economic buyer in discovery."
              },
              "fields|demo_vanta_message_subject": {
                "type": "reference",
                "expression": "{{subject}}"
              },
              "fields|demo_vanta_signal_evidence": {
                "type": "reference",
                "expression": "{{signal_summary}} Source: {{signal_evidence_url}}"
              },
              "fields|demo_vanta_signal_keywords": {
                "type": "static",
                "value": "public-sector contract award; government customer; tender; procurement assurance; security evidence"
              },
              "fields|demo_vanta_target_linkedin": {
                "type": "reference",
                "expression": "{{linkedin_url}}"
              },
              "fields|demo_vanta_workflow_status": {
                "type": "static",
                "value": "message_ready"
              }
            }
          }
        ],
        "inputSchema": {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.email"
            },
            "title": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.title"
            },
            "subject": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.subject"
            },
            "demo_key": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.demo_key"
            },
            "full_name": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.full_name"
            },
            "email_body": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.email_body"
            },
            "linkedin_url": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.linkedin_url"
            },
            "target_domain": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.target_domain"
            },
            "signal_summary": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.signal_summary"
            },
            "target_company": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.target_company"
            },
            "safe_crm_domain": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.safe_crm_domain"
            },
            "signal_evidence_url": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.signal_evidence_url"
            },
            "inherited_why_we_won": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.inherited_why_we_won"
            }
          }
        },
        "incomingEdges": [
          {
            "sourceNode": "{{write_tender_led_vanta_message}}"
          }
        ]
      }
    },
    {
      "key": "find_existing_demo_buyer_contact_in_hubspot",
      "spec": {
        "name": "Find existing demo buyer contact in HubSpot",
        "description": "Finds the isolated synthetic buyer contact by its Clay-verified work email so the new company can be linked without creating a duplicate contact.",
        "nodeType": "tool",
        "tools": [
          {
            "toolType": "clay_action",
            "actionKey": "hubspot-lookup-object",
            "actionPackageId": "a2584689-b965-4a25-847d-17b7abcddca3",
            "appAccountName": "Jack- Test ",
            "inputMappingConfig": {
              "limit": {
                "type": "static",
                "value": 1
              },
              "objectTypeId": {
                "type": "static",
                "value": "0-1"
              },
              "removeBlankValues": {
                "type": "static",
                "value": true
              },
              "fields|fieldsToFilterBy": {
                "type": "static",
                "value": [
                  "demo_vanta_verified_work_email"
                ]
              },
              "fields|demo_vanta_verified_work_email": {
                "type": "reference",
                "expression": "{{email}}"
              }
            }
          }
        ],
        "inputSchema": {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.email"
            }
          }
        },
        "incomingEdges": [
          {
            "sourceNode": "{{create_qualified_company_in_hubspot}}"
          }
        ]
      }
    },
    {
      "key": "link_buyer_to_qualified_company_in_hubspot",
      "spec": {
        "name": "Link buyer to qualified company in HubSpot",
        "description": "Associates the existing synthetic buyer contact to the newly created qualified lookalike company as the primary company relationship.",
        "nodeType": "tool",
        "tools": [
          {
            "toolType": "clay_action",
            "actionKey": "hubspot-create-association",
            "actionPackageId": "a2584689-b965-4a25-847d-17b7abcddca3",
            "appAccountName": "Jack- Test ",
            "inputMappingConfig": {
              "fields|toObjectId": {
                "type": "reference",
                "expression": "{{company_id}}"
              },
              "fields|fromObjectId": {
                "type": "reference",
                "expression": "{{contact_id}}"
              },
              "fields|toObjectTypeId": {
                "type": "static",
                "value": "0-2"
              },
              "fields|associationType": {
                "type": "static",
                "value": "1|HUBSPOT_DEFINED"
              },
              "fields|fromObjectTypeId": {
                "type": "static",
                "value": "0-1"
              }
            }
          }
        ],
        "inputSchema": {
          "type": "object",
          "properties": {
            "company_id": {
              "type": "string",
              "sourceNodeId": "{{create_qualified_company_in_hubspot}}",
              "sourcePath": "$.result.id"
            },
            "contact_id": {
              "type": "string",
              "sourceNodeId": "{{find_existing_demo_buyer_contact_in_hubspot}}",
              "sourcePath": "$.result.results[0].id"
            }
          }
        },
        "incomingEdges": [
          {
            "sourceNode": "{{find_existing_demo_buyer_contact_in_hubspot}}"
          }
        ]
      }
    },
    {
      "key": "is_a_paused_lemlist_campaign_explicitly_approved",
      "spec": {
        "name": "Is a paused Lemlist campaign explicitly approved?",
        "description": "Checks whether a paused Lemlist campaign has been explicitly approved to send. The campaign is approved only if an email address and campaign ID are both present and the approval flag is set to true.",
        "nodeType": "conditional",
        "inputSchema": {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.email"
            },
            "campaign_id": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.campaign_id"
            },
            "send_to_lemlist": {
              "type": "boolean",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.send_to_lemlist"
            }
          }
        },
        "conditionalMode": "rules",
        "rulesConditionalConfig": {
          "rules": [
            {
              "id": "approved",
              "name": "Approved paused campaign",
              "condition": {
                "type": "GroupOp",
                "items": [
                  {
                    "type": "BinOp",
                    "dataPath": [
                      "email"
                    ],
                    "operator": "NotEmpty"
                  },
                  {
                    "type": "BinOp",
                    "dataPath": [
                      "campaign_id"
                    ],
                    "operator": "NotEmpty"
                  },
                  {
                    "type": "BinOp",
                    "dataPath": [
                      "send_to_lemlist"
                    ],
                    "operator": "True"
                  }
                ],
                "combinationMode": "And"
              }
            }
          ]
        },
        "incomingEdges": [
          {
            "sourceNode": "{{link_buyer_to_qualified_company_in_hubspot}}"
          }
        ]
      }
    },
    {
      "key": "add_approved_lead_to_lemlist",
      "spec": {
        "name": "Add approved lead to Lemlist",
        "description": "Adds the approved lead to the paused Vanta public-tender campaign with the Clay-generated subject, complete message, public evidence URL, and buyer title.",
        "nodeType": "tool",
        "tools": [
          {
            "toolType": "clay_action",
            "actionKey": "lemlist-add-lead-to-campaign-v2",
            "actionPackageId": "0b5a7417-ebe5-4a7a-af0d-d982e226b8c2",
            "appAccountName": "Jack- Braze test ",
            "inputMappingConfig": {
              "email": {
                "type": "reference",
                "expression": "{{email}}"
              },
              "lastName": {
                "type": "reference",
                "expression": "{{last_name}}"
              },
              "findEmail": {
                "type": "static",
                "value": false
              },
              "findPhone": {
                "type": "static",
                "value": false
              },
              "firstName": {
                "type": "reference",
                "expression": "{{first_name}}"
              },
              "icebreaker": {
                "type": "reference",
                "expression": "{{icebreaker}}"
              },
              "campaign_id": {
                "type": "reference",
                "expression": "{{campaign_id}}"
              },
              "companyName": {
                "type": "reference",
                "expression": "{{target_company}}"
              },
              "linkedinUrl": {
                "type": "reference",
                "expression": "{{linkedin_url}}"
              },
              "verifyEmail": {
                "type": "static",
                "value": false
              },
              "customFields": {
                "type": "reference",
                "expression": "{{custom_fields}}"
              },
              "allowDuplicates": {
                "type": "static",
                "value": false
              },
              "linkedInEnrichment": {
                "type": "static",
                "value": false
              }
            }
          }
        ],
        "inputSchema": {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "title": "Email Address",
              "description": "The email address of the lead.",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.email"
            },
            "icebreaker": {
              "type": "string",
              "title": "Icebreaker",
              "description": "Icebreaker text of the lead",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.icebreaker"
            },
            "campaign_id": {
              "type": "string",
              "title": "Campaign ID",
              "description": "The Campaign you want to add the lead to.",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.campaign_id"
            },
            "last_name": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.last_name"
            },
            "first_name": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.first_name"
            },
            "linkedin_url": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.linkedin_url"
            },
            "custom_fields": {
              "type": "object",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.custom_fields"
            },
            "target_company": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.target_company"
            }
          }
        },
        "incomingEdges": [
          {
            "sourceNode": "{{is_a_paused_lemlist_campaign_explicitly_approved}}",
            "ruleId": "approved",
            "ruleName": "Approved paused campaign"
          }
        ]
      }
    },
    {
      "key": "hold_lead_for_safe_campaign_review",
      "spec": {
        "name": "Hold lead for safe campaign review",
        "description": "Evaluates whether a lead is ready to send to Lemlist by checking for a verified email address and explicit approval to upload. Flags leads missing an email for manual enrichment, holds those awaiting campaign configuration, and marks those ready for upload to a paused campaign.",
        "nodeType": "code",
        "inputSchema": {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.email"
            },
            "title": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.title"
            },
            "subject": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.subject"
            },
            "full_name": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.full_name"
            },
            "email_body": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.email_body"
            },
            "linkedin_url": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.linkedin_url"
            },
            "target_company": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.target_company"
            },
            "demo_disclaimer": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.demo_disclaimer"
            },
            "send_to_lemlist": {
              "type": "boolean",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.send_to_lemlist"
            },
            "signal_evidence_url": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.signal_evidence_url"
            }
          }
        },
        "outputSchema": {
          "email": {
            "type": "string",
            "description": "Workflow output: email"
          },
          "title": {
            "type": "string",
            "description": "Workflow output: title"
          },
          "reason": {
            "type": "string",
            "description": "Workflow output: reason"
          },
          "subject": {
            "type": "string",
            "description": "Workflow output: subject"
          },
          "full_name": {
            "type": "string",
            "description": "Workflow output: full_name"
          },
          "email_body": {
            "type": "string",
            "description": "Workflow output: email_body"
          },
          "linkedin_url": {
            "type": "string",
            "description": "Workflow output: linkedin_url"
          },
          "target_company": {
            "type": "string",
            "description": "Workflow output: target_company"
          },
          "delivery_status": {
            "type": "string",
            "description": "Workflow output: delivery_status"
          },
          "demo_disclaimer": {
            "type": "string",
            "description": "Workflow output: demo_disclaimer"
          },
          "signal_evidence_url": {
            "type": "string",
            "description": "Workflow output: signal_evidence_url"
          }
        },
        "code": "def handler(context):\n    email = str(context.get_input('email') or '')\n    if not email:\n        status = 'held_no_verified_email'\n        reason = 'No verified email was returned; use the LinkedIn profile or an approved fallback enrichment.'\n    elif not bool(context.get_input('send_to_lemlist') or False):\n        status = 'ready_for_paused_campaign'\n        reason = 'Lead and message are ready; Lemlist upload is blocked until send_to_lemlist is explicitly true.'\n    else:\n        status = 'held_campaign_not_configured'\n        reason = 'A paused or draft Lemlist campaign ID is required.'\n    return {'delivery_status': status, 'reason': reason, 'target_company': str(context.get_input('target_company') or ''), 'full_name': str(context.get_input('full_name') or ''), 'title': str(context.get_input('title') or ''), 'email': email, 'linkedin_url': str(context.get_input('linkedin_url') or ''), 'subject': str(context.get_input('subject') or ''), 'email_body': str(context.get_input('email_body') or ''), 'signal_evidence_url': str(context.get_input('signal_evidence_url') or ''), 'demo_disclaimer': str(context.get_input('demo_disclaimer') or '')}",
        "incomingEdges": [
          {
            "sourceNode": "{{is_a_paused_lemlist_campaign_explicitly_approved}}",
            "isDefaultRoute": true
          }
        ]
      }
    },
    {
      "key": "return_lemlist_upload_result",
      "spec": {
        "name": "Return Lemlist upload result",
        "description": "Confirms the email campaign has been successfully uploaded to Lemlist and passes along the campaign details—including target company, recipient email, LinkedIn profile, subject line, message body, and evidence link—for downstream tracking and reporting.",
        "nodeType": "code",
        "inputSchema": {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.email"
            },
            "subject": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.subject"
            },
            "email_body": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.email_body"
            },
            "linkedin_url": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.linkedin_url"
            },
            "target_company": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.target_company"
            },
            "signal_evidence_url": {
              "type": "string",
              "sourceNodeId": "{{write_tender_led_vanta_message}}",
              "sourcePath": "$.signal_evidence_url"
            }
          }
        },
        "outputSchema": {
          "email": {
            "type": "string",
            "description": "Workflow output: email"
          },
          "subject": {
            "type": "string",
            "description": "Workflow output: subject"
          },
          "email_body": {
            "type": "string",
            "description": "Workflow output: email_body"
          },
          "linkedin_url": {
            "type": "string",
            "description": "Workflow output: linkedin_url"
          },
          "target_company": {
            "type": "string",
            "description": "Workflow output: target_company"
          },
          "delivery_status": {
            "type": "string",
            "description": "Workflow output: delivery_status"
          },
          "signal_evidence_url": {
            "type": "string",
            "description": "Workflow output: signal_evidence_url"
          }
        },
        "code": "def handler(context):\n    return {'delivery_status': 'uploaded_to_lemlist', 'target_company': str(context.get_input('target_company') or ''), 'email': str(context.get_input('email') or ''), 'linkedin_url': str(context.get_input('linkedin_url') or ''), 'subject': str(context.get_input('subject') or ''), 'email_body': str(context.get_input('email_body') or ''), 'signal_evidence_url': str(context.get_input('signal_evidence_url') or '')}",
        "incomingEdges": [
          {
            "sourceNode": "{{add_approved_lead_to_lemlist}}"
          }
        ]
      }
    }
  ],
  "tests": []
}
