{
  "$schema": "../workflow-recipe.schema.json",
  "format": "revenanas.workflow-recipe/v1",
  "slug": "clay-qualified-account-gated-lemlist",
  "title": "How to activate qualified accounts in Clay with a gated Lemlist handoff",
  "job": "For each account entering a qualified Clay Audiences segment, find the buyer the win reason implies, verify an email, write a signal-led draft, record it in HubSpot, and add the lead to Lemlist only after explicit approval.",
  "tools": [
    "Clay",
    "HubSpot",
    "Lemlist"
  ],
  "service": {
    "name": "Signal-Based Outbound",
    "url": "https://www.revenanas.com/services/signal-based-outbound"
  },
  "importability": {
    "clay": "official-cli-bundle",
    "template_url": null,
    "notes": "Built and run through Clay's official Terracotta CLI in the Revenanas test workspace, then exported as a transparent Revenanas bundle. Clay does not offer public template links for Workflows. The installer recreates the graph as an unpublished draft with official CLI commands and validates it. Workspace-specific IDs are passed with --set; HubSpot and Lemlist are connected in Clay by you. Recreated through the official CLI, not a native Clay template."
  },
  "direct_answer": "Trigger the workflow from a Clay Audiences segment of qualified accounts. Find up to five security, compliance or technology leaders, rank them by title in a code step, and verify a work email. Write the message from the account's live signal, the inherited why-we-won and the buyer's title, record the company and buyer in HubSpot, then pass a conditional that requires a verified email, a campaign ID and send_to_lemlist = true. Everything else is held with a reason.",
  "inputs": [
    {
      "name": "qualified_segment_id",
      "type": "string",
      "required": true,
      "description": "Clay Audiences company segment of Qualified accounts (installer --set)."
    },
    {
      "name": "signal_summary",
      "type": "string",
      "required": true,
      "description": "Buyer-safe signal sentence from the discovery workflow."
    },
    {
      "name": "signal_evidence_url",
      "type": "url",
      "required": false,
      "description": "Official notice URL, stored for the rep."
    },
    {
      "name": "inherited_why_we_won",
      "type": "string",
      "required": true,
      "description": "Win reason carried from HubSpot."
    }
  ],
  "outputs": [
    {
      "name": "delivery_status",
      "type": "string",
      "required": true,
      "description": "uploaded_to_lemlist, ready_for_paused_campaign, held_no_verified_email or held_campaign_not_configured."
    },
    {
      "name": "subject",
      "type": "string",
      "required": true,
      "description": "Draft subject."
    },
    {
      "name": "email_body",
      "type": "string",
      "required": true,
      "description": "Draft message for human review."
    }
  ],
  "steps": [
    {
      "id": "01-trigger",
      "action": "Account enters the qualified segment",
      "purpose": "Activate only accounts the discovery Claygent qualified.",
      "configuration": {
        "trigger": "audience_segment",
        "entity": "ACCOUNT"
      }
    },
    {
      "id": "02-people",
      "action": "Find up to 5 security, compliance or technology leaders",
      "purpose": "Search for the buyer the win reason implies.",
      "configuration": {
        "action": "cpj-find-lists-of-people-v2",
        "limit": 5
      }
    },
    {
      "id": "03-rank",
      "action": "Rank titles and pick one",
      "purpose": "Deterministic, arguable scoring instead of a model.",
      "configuration": {
        "scores": {
          "CISO": 120,
          "Director of information security": 115,
          "Information security manager": 110,
          "Data protection": 105,
          "Compliance": 90,
          "CTO": 80,
          "CIO": 75,
          "Risk": 65,
          "Junior/assistant": -70
        }
      }
    },
    {
      "id": "04-email",
      "action": "Find a verified work email",
      "purpose": "Hold rather than guess when nothing verified returns.",
      "configuration": {
        "action": "findymail-find-work-email-from-linkedin"
      }
    },
    {
      "id": "05-message",
      "action": "Write subject and message",
      "purpose": "Compose from the live signal, inherited win reason and buyer title.",
      "configuration": {
        "node": "code",
        "send_to_lemlist_default": false
      }
    },
    {
      "id": "06-hubspot",
      "action": "Record the company and link the buyer in HubSpot",
      "purpose": "End the loop in the CRM, not only the sequencer.",
      "configuration": {
        "actions": [
          "hubspot-create-object",
          "hubspot-lookup-object",
          "hubspot-create-association"
        ]
      }
    },
    {
      "id": "07-gate",
      "action": "Gate before Lemlist",
      "purpose": "Require a verified email, a campaign ID and explicit approval.",
      "configuration": {
        "all_of": [
          "email not empty",
          "campaign_id not empty",
          "send_to_lemlist = true"
        ]
      }
    },
    {
      "id": "08-lemlist",
      "action": "Add approved lead to a paused Lemlist campaign",
      "purpose": "Hand off with subject, message, evidence URL and title as custom fields.",
      "configuration": {
        "action": "lemlist-add-lead-to-campaign-v2",
        "allowDuplicates": false
      }
    }
  ],
  "guardrails": [
    "The downloadable bundle ships with send_to_lemlist = False and a blank campaign ID.",
    "Keep the Lemlist campaign paused until a person has reviewed the copy.",
    "No verified email means the row is held, never sent to an unverified address.",
    "The tested build wrote HubSpot companies on reserved example.com domains; point the domain mapping at real records only when you intend to."
  ],
  "test_cases": [
    {
      "name": "Qualified account, public-sector award (NHS England supplier)",
      "input": {
        "segment_entry": "Qualified"
      },
      "expected_status": "buyer selected, verified email, draft written, HubSpot records linked",
      "observed": "passed"
    },
    {
      "name": "Qualified account, public-sector award (SCAPE supplier)",
      "input": {
        "segment_entry": "Qualified"
      },
      "expected_status": "buyer selected, verified email, draft written, HubSpot records linked",
      "observed": "passed"
    }
  ],
  "architecture": {
    "summary": "An Audiences segment trigger feeds a people search, a deterministic ranking step, email verification and a message code step, then HubSpot writeback and a three-condition conditional that either adds the lead to Lemlist or holds it with a reason.",
    "diagram": "Qualified segment -> Find up to 5 leaders -> Rank titles -> Verified email -> Write message -> HubSpot company + buyer link -> Gate (email, campaign ID, approval) -> Lemlist OR Hold with reason"
  },
  "verification": {
    "last_tested": "2026-09-23",
    "builder": "Clay official Terracotta CLI",
    "graph_valid": true,
    "passing_tests": 2,
    "passing_run_ids": [
      "wfr_088c365f665ab4ad0c30f3d535d44ec4",
      "wfr_d4461f21867ded73c054863e66bdc196"
    ],
    "install_check": "2026-09-25: bundle installed as an unpublished draft (wf_0tlx7jsx4twGw8hVemF); graph valid; node and edge structure identical to the live workflow.",
    "observed_failures": [
      "The demo build set the approval flag inside the message step because its campaign was paused; the bundle ships the flag false and the campaign ID blank.",
      "Lemlist connectivity was verified by adding leads to a paused campaign; nothing was sent."
    ],
    "changes_from_tested_build": [
      "Gate ships closed.",
      "An unapproved vendor proof point was removed from the message copy."
    ]
  },
  "limitations": [
    "HubSpot writeback nodes use demo_vanta_* property names; rename to your own.",
    "The message copy is a starting draft for a compliance-software seller; rewrite it for your offer.",
    "HubSpot and Lemlist must be connected in Clay before the draft can run."
  ],
  "faqs": [
    {
      "question": "How do I stop Clay from emailing leads automatically?",
      "answer": "Put a conditional before the Lemlist step that requires a verified email, a campaign ID and an explicit approval flag. Ship the flag as false and keep the campaign paused until a person has read the copy."
    },
    {
      "question": "Why rank buyer titles in code instead of with AI?",
      "answer": "It is cheap, repeatable and easy to argue with. When a rep disagrees with a pick, you change a number, not a prompt."
    }
  ],
  "sources": [
    {
      "name": "Clay Workflows documentation",
      "url": "https://university.clay.com/docs/workflows"
    },
    {
      "name": "Clay Workflow FAQs",
      "url": "https://university.clay.com/docs/workflow-faqs"
    },
    {
      "name": "Clay HubSpot integration overview",
      "url": "https://university.clay.com/docs/hubspot-integration-overview"
    },
    {
      "name": "Clay: enriching an Audience with Workflows",
      "url": "https://university.clay.com/lessons/enriching-an-audience-with-workflows"
    },
    {
      "name": "Lemlist API documentation",
      "url": "https://developer.lemlist.com/"
    }
  ],
  "related_guide": "https://www.revenanas.com/blog/closed-won-signal-led-pipeline-clay",
  "install_command": "python3 install_clay_workflow.py.txt clay-qualified-account-gated-lemlist.clay-workflow.json --set qualified_segment_id=<your Audiences segment id>"
}