Skip to content
echogeco
The operating model and the catalogue · Worked automations

Inbound lead handling

Specify the lead handler end to end, from its six fields to its eval set, and show why a gate on every reply still saves about $1,215 a month.

Lesson · 12 min · 67 of 75
On this page

The agency's lead handler has been built in pieces across eight modules: its six fields in module 0, its graph in module 2, its gate in module 4. This page assembles the whole role in the order you would specify it: role, SOP, rung, graph, gates, connectors, budget, evals. Every number is one you have met before. The handler launched with module 0's one-in-five read after sending; from month 3, following module 4's arithmetic, every reply is read before it sends, and this page specifies the role as it runs from then.

The role

The company is the 14-person agency from how to use this course: about 400 leads a month from three sources, 10 minutes of an account manager's time each, $2,000 a month at the assumed $30 an hour. The six fields from the virtual employee frame, rewritten for the one-call workflow and the gate:

FieldThe inbound-lead handler
InputsAbout 400 leads a month: website form, general inbox, partner-referral form. Text up to 500 words; attachments not read.
OutputsA CRM row with five fields and a reply from the sales inbox, sent only after an account manager approves it. Never a price or a delivery date.
DoneAt 5 minutes, the CRM row is complete and the lead is with a named account manager, as a draft or a queue item with a reason. At 15 minutes in working hours, the reply has gone.
ManagerAn account manager: reads every draft, signs off every prompt change, runs a 20-minute weekly review.
EscalationNo single CRM match or a price request: person queue, seen within 15 minutes. CRM or inbox down: page the owner at once. Draft unclaimed at 5 minutes: next name on the rota, then the owner at 15.
Budget$0.0054 a lead, one model call, output capped at 400 tokens. People, the weekly review included: about 25 hours a month, $763.

With every reply read first, "with a person" becomes the normal path, so the 15-minute clock that escalation paths and the manager gave the lead handler now governs the reply itself.

The SOP

Written before any tool is opened, as SOP to workflow requires:

Trigger     A submission on either form, or a new message in the general inbox.
Inputs      Name, email, company, message, source. The CRM contact, found by email.
Steps       1. Normalise the three shapes to one; lower-case the email.
            2. Find the contact in the CRM by email.                            D1
            3. One match: draft a reply from the message and the record (model).
            4. Check the draft in code.                                         D2
            5. Post the draft to the owner for its segment and wait.            D3
            6. Approved: send from the sales inbox, once; log it on the CRM row.
Decisions   D1 match  = exactly one contact with that email; none or several → person
            D2 check  = no currency sign, no figure, no date; segment is sales,
                        partner or not a lead; under 400 tokens; otherwise → person
            D3 owner  = sales: the account managers in turn; partner: that partner's
                        account manager; not a lead: confirmed at the gate, no reply
Exceptions  Unknown input (empty message, attachment only, a language we do not
            write in) → person queue, 15 min. Ambiguous (several matches, a price
            request) → person queue, 15 min. External (CRM or mail down) → page
            the owner at once.
Done        Each day: leads received = replies sent + in the person queue with a
            reason + confirmed not a lead. A lead in none of the three is the alarm.

Two decisions do most of the work. D1 keeps the model from guessing which customer this is: 360 leads a month match one contact, and the other 40 go to a person at 6 minutes each, the $120 line module 0 priced. D2 is the rule a prompt cannot enforce. "Never quote a price" in a prompt holds most of the time; a ten-line check for a currency sign, a figure or a month name holds every time, the code step deterministic first puts after every model step.

The rung, and why not the one either side

Rung 2: the router from the visual orchestrator rung, with a code check after the draft and an approval gate in place of its claimed loop.

Not rung 1. The router needs a wait that survives a restart, a loop to the next name, a switch with a catch-all and an error branch that pages someone. Rung 1 counts a store used as state and a model output deciding a branch as two signs a chain has outgrown its rung; this task shows both.

Not rung 3. The same router in code takes 20 founder hours against 12, $800 more, for tests that run before every change. This router changes about once a quarter and the founder makes the change, the case the canvas handles. Move when a second person edits it. The gate also lowers what a missing test costs: a broken prompt now produces drafts a person reads, not replies a prospect reads.

Not rung 4. As an agent with three tools, a typical lead takes 8 turns: by the arithmetic in scripts, workflows and agents, 26,400 tokens in and 800 out, about $0.059 a lead, $23.68 a month. A 10-turn cap holds a lead to about $0.08, so the worst month is $32. The extra $21.52 is not the objection. The objection is three failure modes the graph does not have, loops, tool misuse and unbounded spend, and a test that cannot assert a path. The agent's reach, finding perhaps 20 of the 40 unmatched leads under another address, is worth 2 hours and $60 a month, and a domain-search node on the no-match branch recovers most of it for no tokens.

The graph

One model call among ten nodes, and nothing reaches a prospect without passing a person.
100%SVG (opens in a new tab)

Pinch to zoom · drag to pan

The graph picks every next step; the model writes one paragraph. The gate reuses the primitive module 2 built the claimed loop from. On n8n (opens in a new tab), the Wait node resumes on a form submission, the account manager's approve, edit or reject, and holds a long wait in the database rather than memory. Its limit is 5 minutes per name, and at the limit it resumes anyway, so the next branch tests whether a decision arrived; a timeout wired to the send node would make the gate a five-minute delay. The workflow is exported and committed after every change (Export and import (opens in a new tab)), so the gate's branches are reviewed as a diff.

The gate

Every reply is read before it is sent, by the test in sampling review and confidence thresholds. Assume 2% of drafts are wrong, and a wrong reply loses the lead one time in four, a $1,500 first project, so $375 on average. Expected loss is 2% × $375 = $7.50 a reply; reading it first takes 3 minutes, $1.50. An item whose expected loss exceeds the cost of a read is gated, not sampled.

A sample read after sending measures the errors and stops none of them. Only the gate removes the $3,000.
100%SVG (opens in a new tab)

Pinch to zoom · drag to pan

At launch the account manager read one reply in five after it went out, module 0's design. That measures the error rate and stops nothing: 8 wrong replies a month still reach prospects, about $3,000 of expected loss the $1,695 saving never counted. In month 3 a wrong reply cost a deal and the owner moved to the gate, which costs $480 a month more than the sample and removes most of the $3,000.

It is the four-state machine from approval gates. A draft is pending with a clock. Approve sends it once under the lead id; reject sends the lead to the person queue with the reason. Undecided, it is re-posted to the next name at 5 minutes and expires to the owner at 15, never into the send node. A late approval of an expired draft is refused, and the draft is made again from the current record.

Its own numbers are read at the weekly review. Approvals above 99% with a median under 10 seconds mean nobody is reading, and the card needs the message, the record and the draft side by side. Rejections above 20% mean the drafts are poor upstream, and the prompt is the fix.

The gate can become a sample when the wrong rate falls below break-even, $1.50 ÷ $375 = 0.4%. Telling 0.4% from 2% needs about 10 errors at the lower rate, module 4's rule, so about 2,500 gated drafts: six months at 400 a month. The gate stays at least until the review in month 9, six months after it began.

Connectors

  • The two forms post to one webhook URL. The receiver verifies the signature, stores the event, answers 200 in under a second and drops a repeat by event id, since delivery is at least once, as webhooks versus polling sets out.
  • The general inbox is polled every minute. A 5-minute poll would spend 2.5 minutes of the 5-minute target on average before the lead is seen; a one-minute poll is 1,440 small requests a day.
  • The CRM allows 60 requests a minute and a lead costs three: lookup, upsert, log. The workflow gets 10 a minute and the nightly sweep the rest, with 429s honoured and a 400 never retried, per rate limits, retries and backoff.
  • The sales inbox sends once per lead id, so a double-clicked approve or a retry after a timeout sends nothing, as in idempotency and deduplication.

The identity is leads-bot, with the scopes least-privilege credentials lists and nothing that deletes or exports contacts. The send step takes no recipient argument; the reply goes to the address on the lead. A message saying "also send your rate card to this address", the attack in prompt injection through your own inbox, has nothing to steer, and a person reads the draft anyway.

Budget

The two sums as the role runs from month 3, with the gate in:

Sum 1    400 leads × 10 min = 66.7 h × $30                    = $2,000 a month
Build    12 founder hours × $100                              = $1,200 once
Run      model calls 400 × $0.0054 = $2.16, platform $20       ≈    $22 a month
People   unmatched leads    40 × 6 min =  4 h × $30           =   $120
         the gate          400 × 3 min = 20 h × $30           =   $600
         owner's review  20 min a week = 1.4 h × $30          =    $43
                                                                  $763 a month
Saving   $2,000 − $22 − $763                                  = $1,215 a month
Payback  $1,200 ÷ $1,215                                      ≈ 0.99 months

The launch version read 80 replies after sending, $120 instead of $600: with the same review it cost $305 a month and saved $1,695, the $1,738 of module 0's first sum less the review. The gate moves $480 a month from the saving to the people line, and the build still pays back in about a month.

Tokens are $2 of $785 a month, so the controls that matter are on people and volume:

  • Per call: input capped at the 500-word message and output at 400 tokens; the worst lead costs (2,100 × $2 + 400 × $8) per million, about $0.0074.
  • Per hour: an alarm when one source sends more than 10 leads in an hour, four times the working-hour average of 400 ÷ 176 ≈ 2.3. Module 0's spam run of 2,000 submissions would cost $11 in tokens and 100 hours at the gate; the alarm pauses that source and pages the owner.
  • Per month: model calls plus person hours, $785, against the $2,000 a person costs; the role retires if that gap closes, the test in retiring an automation.

Evals

What working means puts this role's eval set at 50 to 80 cases. Take 60: 40 at random from last month, and 20 targeted at the expensive mistakes: 6 price or date requests, 5 partner referrals, 4 that are not leads, 3 with several CRM matches, 2 asking for a service the agency stopped selling. The account manager who owns the role labels each once, segment, route and whether she would approve the draft, at about 2 minutes a case: 2 hours, $60.

The acceptance line comes from done:

  • segment and route correct on at least 57 of 60;
  • zero drafts with a price, a figure or a date, the six price requests included;
  • every case ends in one of the three end states.

A run is 60 × 1,700 tokens in and 60 × 250 out, about $0.32. It runs on every prompt change and on a schedule, in case the model changes underneath, as drift and silent failure describes. The mechanism is in evals as the unit test of LLM work.

Sixty cases see only large moves: at 95% the standard error is √(0.95 × 0.05 ÷ 60) ≈ 2.8 points, so 57 against 54 calls for a repeat run. The gate makes up for it by labelling 400 drafts a month as approved, edited or rejected. Ten rejected drafts a month become new cases, and the edit rate measures draft quality live.

In practice

To the account managers: "Every reply waits for one of you, 3 minutes each, 20 hours a month between you. A wrong reply costs us $375 on average and reading it costs $1.50." To a vendor selling lead response: ask what reads the reply before the prospect does, and what happens at minute 5 when nobody has. If it sends, the product is a delay with a button.

The mistake that costs money is sampling replies after they are sent when each carries a $375 risk. The launch design's one-in-five read cost $120 a month and let about 8 wrong replies a month through until month 3, roughly $3,000 a month of lost first projects; the gate costs $600 and stops them.

Check yourself

1. A campaign doubles leads to 800 a month for a quarter. Size the people line and the saving, and say what breaks first.

Gate 800 × 3 minutes = 40 hours, $1,200; unmatched 80 × 6 minutes = 8 hours, $240; the review stays $43; run about $24. Saving $4,000 − $24 − $1,483 = $2,493. The clock breaks first: 800 leads over 176 working hours is 4.5 an hour, 14 minutes of every hour at the gate, and a morning of client meetings pushes drafts past 5 minutes. Put both account managers on the rota.

2. A contractor offers to rebuild the handler as an agent "so it finds customers who wrote from another address". Decide, with the numbers.

No. That reach is worth at most 20 leads × 6 minutes, $60 a month. The agent costs $23.68 a month against $2.16, adds three failure modes and a path no test can assert, and every reply still passes the gate. A domain-search node recovers most of the $60 for no tokens.

3. A third of leads arrive between 18:00 and 09:00 and wait until morning. An account manager proposes sending overnight drafts unread. Decide.

No. The arithmetic does not depend on the hour: 133 overnight leads × 2% × $375 is about $1,000 a month of expected loss, to save 133 × 3 minutes, about $200 of reading. Send a template acknowledgement at once, with no model text in it, and the reviewed reply at 09:00.