How to Build an AI Agent That Generates Leads While You Sleep

Discover how to build an AI agent that qualifies and routes leads automatically using three persistent skill files.

By Central
This guide explains the architecture of an AI lead generation agent using soul.md, skill.md, and verification scripts.
Highlights
  • An agent without a skill file is just a chat window with extra steps.
  • The verification script checks that every required field is populated after the skill completes.
  • Start with inbound qualification and get the pipeline clean before building the outreach skill.

Why Most Lead Generation Agents Fail at Scale

The standard approach — throw a chatbot on a landing page and hope — produces noise, not pipeline. You get generic responses, no qualification, and zero handoff to your CRM. The problem isn’t the model. It’s the lack of a structured skill that tells the agent exactly how to qualify, route, and log each lead.

An agent without a skill file is just a chat window with extra steps. Every run starts from scratch. The first lead gets one treatment, the tenth gets another, and your follow-up sequence collapses because nothing is consistent.

Here is the architecture that fixes that.

The Three Files Every Lead Agent Needs

Your agent runs on three documents, not prompts. Prompts die when the session ends. These files persist.

soul.md — the identity file. It sits at /opt/data/soul.mdcode on a Hermes install. This is the system prompt on every run. It sets tone, autonomy level, and what the agent declines. Two agents running the same skill return different results if their soul files disagree.

skill.md — the procedure file. It lives in a folder under hermes/skills/code. The front matter (YAML) defines the trigger — what job this skill applies to. The body holds the steps: how to qualify, what questions to ask, where to log the result.

verification script — an optional but recommended file that runs after the skill completes. It checks that every required field is populated and that the lead meets your minimum qualification threshold. Without it, the agent confirms a lead and moves on even when half the data is missing.

Lead Qualification Skill — Reference Structure

Component Purpose Example Value
YAML trigger When the skill activates description: "Qualify inbound lead from website form"code
Input fields Data the agent expects name, email, company_size, pain_pointcode
Qualification rules Hard pass/fail criteria company_size >= 10 AND pain_point != ""code
Routing logic Where the lead goes if score > 80: push to CRM; else: tag for nurturecode
Logging format How the output is structured JSON with timestamp, score, assigned repcode
Verification block Post-run checks confirm all fields populated, score recalculatedcode

Step 1: Build the Identity Before the Skill

Your agent needs a voice before it can qualify a lead. Use Ordain to generate the soul.md file. Select Hermes as the platform. Set independence to “middle” — the agent handles routing and logging autonomously but checks with you on anything that deviates from the skill.

In the text box, be specific. Not “helpful and thorough” — that tells the agent nothing it didn’t already assume. Write:

“`

Works in US business hours. Answers in plain English with no preamble.

Never invents a company name or contact. If a field is missing, it asks

for it specifically — it does not guess. It logs every interaction to

the CRM before moving on.

“`

Generate the file, download it as .txt, and upload it to your agent’s Telegram chat. Then paste the copy prompt from Ordain. The agent writes its own soul.md into the right folder. Reset the session with /resetcode so the new identity loads.

Step 2: Write the Lead Skill with a Verification Loop

Back in Ordain, open the skill builder. Select Hermes again. Name the skill something specific — lead_qualify_standardcode — because the trigger description is what the agent reads when deciding whether to open the file.

In the “what should it do” box, paste the full procedure. Do not write “qualify leads and give me a summary.” That produces a skill that says roughly that — the agent still makes every decision itself. Write the exact sequence:

“`

  1. Read the inbound form submission from the webhook payload.
  2. Extract: company name, contact email, employee count, stated need.
  3. Score the lead:
    • employee count >= 10: +20 points
    • stated need matches one of [inventory, scheduling, compliance]: +30 points
    • company has a website with valid domain: +10 points
    • contact email is not a free provider (gmail, yahoo): +15 points
  1. If score >= 65: push to CRM endpoint with all fields plus score.
  2. If score < 65: write to nurture queue with reason for rejection.
  3. Log the outcome to the activity file with timestamp.

“`

Under requirements, add:

“`

Every lead record must contain: name, email, score, routing_decision, timestamp.

No record is written unless all five fields are populated.

“`

Generate the skill. What comes back is a proper skill.md file with front matter, a description, the procedure, pitfalls, and a verification section. The pitfalls section is where you put the mistakes you’ve already watched it make — it stops making them once they’re written down.

Upload the .txt to Telegram, paste the copy prompt, and the agent writes the folder into hermes/skills/code. It picks up the skill on the next session.

Step 3: Test Against a Known Answer

Before you point real traffic at it, run a test case you already know the answer to. Submit a form payload with a clear pass and a clear fail. Watch the agent follow the procedure.

If it completes the task but formats the output however it wants — ignoring the structure from the file — the steps are too loose. Add a line: “Output goes back in the exact JSON format printed in the procedure.” Run it again. The second attempt should match.

This is where the pitfalls section grows. Every test reveals a gap. Write the gap into the file.

Step 4: Set the Schedule and Forget

The agent is useless if you have to trigger it manually. Ask it to run every 15 minutes and check the webhook endpoint for new submissions. It sets that up itself. No cron job needed.

The research skill example from the source material runs at 6:00 AM and messages a brief to Telegram. Your lead skill works the same way — it checks, qualifies, logs, and messages you only when something breaks the pattern. That is the point: the agent handles the standard case, and you handle the exception.

Step 5: Model Downgrade

You developed the skill on Astra or Sonnet. That is expensive for a recurring task. Test the same skill on Luna or Haiku. If the output holds — same structure, same completion rate — switch. The lead skill is deterministic enough that a cheaper model often works.

Run the same test payload on Luna. Compare the output field by field. If the JSON matches, you save roughly 4x per run. That matters when the agent polls every 15 minutes.

What Breaks and How to Fix It

The agent qualifies a lead but skips the CRM push. The verification block is missing. Add a post-run check that confirms the API response before marking the task complete.

The agent hallucinates a company name. Your soul.md did not include the “never invents” instruction. Add it, reset the session, and retest.

The skill runs but produces inconsistent scores. The scoring logic is too loose. Make the rules binary — “if X, then +20” — rather than “consider X.” Remove judgment from the qualification step.

Multiple leads arrive simultaneously and the agent stalls. The skill file has no concurrency handling. Add a line: “Process one payload at a time. Queue the rest. Log queue depth.”

The One Thing You Cannot Delegate

The skill handles qualification, routing, and logging. It does not handle the follow-up conversation. That is a separate skill — and one you should build only after the qualification skill runs cleanly for two weeks.

Start with inbound qualification. Get the pipeline clean. Then build the outreach skill that drafts the first email. That is where the compound return lives — not in the chatbot, but in the sequence that runs after the lead is scored.

Questions answered
  • Why do most lead generation agents fail at scale?The standard approach produces noise, not pipeline, due to lack of a structured skill.
  • What three files does every lead agent need?soul.md (identity), skill.md (procedure), and a verification script.
  • What is the one thing you cannot delegate?The follow-up conversation is a separate skill that should be built after the qualification skill runs cleanly for two weeks.
Share This Article