Back to work

Lead-to-Booking Agent · Lead booking automation

From a new lead to a proposed visit

Leads arrive from web forms and phone calls. Each gets a record, proposed visit times and an office task, and risky jobs wait for a manager.

What can’t go wrong

  • 1 dealA repeat never doubles a lead
    How we know
    The same lead arrived twice in a row, a second time while the first was still being handled, and again after a first attempt failed part-way. Each time one deal and one office task existed at the end. A repeat after a finished run was answered without doing any of the work again.
  • 0 callsForged requests do nothing
    How we know
    A wrong signature, a correct signature 400 seconds old, one 61 seconds ahead, no signature at all and a body with no phone or email were each refused with no call of any kind to any other service. The same held for a forged or malformed approval click.
  • 0 sentCustomers only get drafts
    How we know
    In every scenario the workflow only drafted an email and only proposed a text message to the office. The test suite asserts that no email send endpoint is ever called, and no text-message endpoint exists.
  • $800Big jobs wait for a manager
    How we know
    Termite and wildlife jobs, commercial properties and estimates of $800 or more are held until a manager presses Approve or Hold, and the message says which rule held the job. The first decision wins: a second click, a redelivery and a late Hold each changed nothing. The $800 and every price in the scenarios are rows of the rules sheet.

How a lead moves

  1. A lead arrivesForm or phone call
  2. It is checked and readSender, repeats, urgency
  3. A visit is proposedRecord, times, office task
  4. A person decidesRisky jobs wait for a click

How it works, in detail

For technical reviewers: the workflows, architecture and automated checks.

TriggerStepAnswer to senderRedrawn from the build’s layout file

Verified on real n8n

36 of 36 checks passed on n8n 2.42.6.

  • 36/36End-to-end checks passed
    Details
    Run on n8n 2.42.6 on 11 Oct 2026, from a clean state: 21 scenarios, 6 further checks (missing signature, two deliveries in a row, the error workflow, a repeat while a run is in flight, a repeat after a failure, the environment allowlist), 7 approve and hold checks, a HubSpot parity check and an execution-history check. Each asserts the response, every logged request and the resulting CRM and task state.
  • 117Unit checks passed
    Details
    108 unit checks of the workflow logic and 9 for the Slack click relay, run without n8n and without a network. The logic is plain modules injected into the Code nodes.
  • 114Nodes in three workflows
    Details
    Book new lead 80, Handle approval 28, Alert on errors 6. The workflow files are generated from source by workflow/build-workflow.mjs, which checks they are fresh.
  • 0Validator errors
    Details
    n8n-mcp validate_workflow, runtime profile, on all 3 workflows: 0 errors and 0 warnings. An earlier run reported 15 false errors that came from how two modules built a string; they were rewritten and the output is identical.
  • 3 × 5 sRetries on every network call
    Details
    All 38 HTTP calls retry 3 times, 5 seconds apart, and every call that changes state, except the ledger's own, carries an Idempotency-Key built from the event id and the node name. The vendors differ: HubSpot, Slack, ClickUp comments and Gmail drafts ignore the key, so deals are read by a unique property and contacts are searched before they are created.

Inside the automation · 114 nodes

Three workflows, one lead

Scroll the steps. Tap any node for its job, retries and what it sends.

  1. Book new lead1 / 9

    401 · 409

    Signature, shape, one claim

    How it works
    The signature covers the timestamp and the exact bytes received, within a 300 s window. A wrong signature, a timestamp 400 s old and one 61 s ahead each got 401 and no call of any kind; the same bytes signed over a compact re-serialization were refused. A body with no phone or email got 400 and no call. Each valid event id is then claimed once in the event ledger: a second delivery while the first is running gets 409 with Retry-After 30, and one after it finished gets 200 duplicate.
  2. Book new lead2 / 9

    0.6

    Model output is never trusted

    How it works
    Claude answers to a JSON schema and code checks every field against an allowed list again. A refusal, a failed call, an invalid value or a confidence under the rules sheet's threshold (0.6) sends the lead to review instead of a deal. Phone numbers and emails the model echoes are replaced before they reach Slack, ClickUp, Sheets or the response; the check with a hand-written reply that echoes both passed. Only the inquiry text, the source and the ZIP are sent to the model.
  3. Book new lead3 / 9

    37 ZIPs

    Service area read from a sheet

    How it works
    The service-area table, pricing and every threshold are read from an ops rules sheet, not kept in n8n. A ZIP maps to a branch (15 ZIPs in Jacksonville, 11 in Savannah, 11 in Mobile). A lead that needs review or lies outside the area skips the customer check and the deal. A malformed sheet fails the run into the error workflow instead of routing on bad rules.
  4. Book new lead4 / 9

    0 deals

    A customer gets a task

    How it works
    The customer is looked up by phone (by email when there is no phone). An active customer is handled as a service request: one ClickUp task tagged service-request and one Slack note, no call to HubSpot and no new deal.
  5. Book new lead5 / 9

    409

    A lagging search is handled

    How it works
    One search matches email or phone, then the contact is updated or created. When the search had not caught up and the create got 409 (n8n retried it 4 times), the contact is read by email and updated without overwriting its name: one contact, no duplicate. The customer's original message is stored on the contact, so Slack, ClickUp and Sheets only get ids, links, the first name and the ZIP.
  6. Book new lead6 / 9

    0.3

    Unclear leads go to a person

    How it works
    A vague message (“something is going on at our house, not sure what exactly”) came back at confidence 0.3 against the 0.6 threshold: a ClickUp review task and a Slack note, no deal and no slot. A lead from outside the area gets a tagged contact and a short Slack note.
  7. Book new lead7 / 9

    1 deal

    A deal is read before it is made

    How it works
    HubSpot ignores idempotency keys, so each deal carries a unique ridgeway_event_id property and is read by it (404 means none yet) before any create. When a create committed but answered after the 10 s timeout, the retries got 409 three times, the deal was read and reused, and one deal existed (25.9 s). Each arrival window is offered once. When the scheduling service was down for all 4 tries (15.8 s), the office got a call-back task and a Slack warning and the run went on. A reused deal that has moved past New lead keeps its stage, so a re-run cannot undo a decision.
  8. Book new lead8 / 9

    0 sent

    Drafts and proposals only

    How it works
    Email is a Gmail draft and never sent. A text message is proposed in the office task only when consent is true. When Gmail answered 503 on all 4 tries, the booking still completed, the response carried gmail_draft_failed and the task said “Email draft: FAILED, no draft was created”. An earlier version reported that failed draft as created, because the next step read the wrong output of the node; a scenario with Gmail down now covers it. The Slack summary carries Approve and Hold buttons when approval is required.
  9. Book new lead9 / 9

    200

    Every path ends here

    How it works
    A log row with received and finished times and the status, then the ledger is told the event is done together with the deal, task and message ids that an approval click will need, and the webhook answers with the outcome. Successful runs are not saved in n8n's execution history, but n8n still writes the first row and removes it later, so a lead's data stays in its database until a pruner pass; a check reads the database to confirm the pruner removed rows.
  10. Handle approval1 / 4

    401 · 400

    A signed click, ids only

    How it works
    The Slack click reaches n8n through a small relay that signs it. A wrong secret and a correct signature 400 s old got 401; an unknown action, a payload carrying message blocks and a payload with no event id got 400. All five made no call of any kind. The button carries the event id and nothing else, so nothing is trusted from Slack beyond that id.
  11. Handle approval2 / 4

    403

    Only listed approvers

    How it works
    A user who is not on the approver list got a private notice and 403. The only call was that notice: the deal stayed in Needs approval, no decision was stored and the buttons stayed. An empty list means nobody may approve.
  12. Handle approval3 / 4

    1 decision

    The first click wins

    How it works
    The ledger holds one decision per lead. After an Approve, a second click, a Slack redelivery and a late Hold each added exactly one ledger call and answered already decided: one comment, and the deal stayed Approved. A lead that never needed approval answers 409.
  13. Handle approval4 / 4

    6 calls

    Deal, comment, message, in order

    How it works
    An Approve made six calls in order: claim, read the settings, move the deal to Approved, comment on the office task, replace the buttons with who decided and when, and mark the decision done. When HubSpot answered 503 on all 4 tries, the error workflow handed the decision back and alerted; the next click was claimed as attempt 2, the deal update committed once, and there was one comment and one message update.
  14. Alert on errors1 / 1

    3 calls

    Release, alert, log

    How it works
    When a required step fails after its retries, the error workflow gives the event's claim back to the ledger, posts an alert that names the event id and carries no customer data, and writes a row to the Errors tab. With HubSpot failing on all 4 tries, nothing else was created, the ledger entry ended as failed, and the alert and the row were written. All three calls are non-critical.

Watch a recorded run travel

Eight runs from the end-to-end checks. Every path is built from the logged calls.

Three visit times and a drafted reply

What was checked
A call transcript about ants and a quarterly plan, with the ZIP read from what the caller said. The model read ants, normal urgency, confidence 0.9. Three arrival windows on three different days inside the 7-day window were proposed, a text message was proposed because consent was given, and the deal stayed in New lead. 17 logged calls.
Leadanswered200
55/55+802 ms
  1. Receive lead
  2. Verify signature
  3. Check signature result
  4. Normalize and validate lead
  5. Check lead is valid
  6. Prepare event claim
  7. Claim eventclaimed200+0 ms
  8. Check event claim
  9. Route claim result
  10. Fetch ops settings200+15 ms
  11. Prepare Claude request
  12. Qualify lead with Claude200+36 ms
  13. Apply AI guardrails
  14. Fetch service area rules200+51 ms
  15. Check service area
  16. Route lead by path
  17. Prepare FieldRoutes customer search
  18. Find FieldRoutes customer200+80 ms
  19. Check for existing customer
  20. Branch on existing customer
  21. Prepare HubSpot contact search
  22. Search HubSpot contact200+129 ms
  23. Prepare HubSpot contact upsert
  24. Branch on contact match
  25. Create HubSpot contact201+151 ms
  26. Check HubSpot contact create
  27. Branch on contact create
  28. Route lead after contact
  29. Fetch pricing rules200+243 ms
  30. Prepare HubSpot deal
  31. Find HubSpot deal404+508 ms
  32. Pick HubSpot deal
  33. Branch on deal match
  34. Create HubSpot deal201+533 ms
  35. Record HubSpot deal
  36. Branch on deal create
  37. Associate deal with contact200+559 ms
  38. Prepare FieldRoutes availability search
  39. Search FieldRoutes availability200+583 ms
  40. Pick slots
  41. Branch on availability
  42. Prepare deal stage update
  43. Branch on approval
  44. Prepare Gmail draft
  45. Branch on email
  46. Create Gmail draft200+678 ms
  47. Prepare ClickUp CSR task
  48. Create ClickUp CSR task200+718 ms
  49. Prepare Slack leads summary
  50. Post Slack leads summary200+745 ms
  51. Compose result
  52. Append speed-to-lead row200+773 ms
  53. Prepare event done
  54. Mark event done200+802 ms
  55. Respond with resultanswer200

Build notes

What came up during the build, and what changed because of it.

A repeat n8n could not see

What happened
The first duplicate check kept its claim in workflow static data. n8n saves static data only when a run ends, so a second delivery that arrived mid-run started its own booking: an isolated workflow check answered dup false to both, and only a third request after the end answered dup true. The claim moved to an event ledger that the workflow calls. A repeat mid-run now gets 409 with Retry-After, a repeat after the run gets duplicate, and the error workflow gives a failed run's claim back. Moving it also showed that duplicate_delivery had passed only because n8n remembered an earlier scenario; the ledger now starts marked done in that scenario.

HubSpot ignores the idempotency key

What happened
Every write carries a key built from the event id and the node name, and the test suite verifies it, but HubSpot does not. Each deal now carries a unique ridgeway_event_id property and is read by it before any create; a create that conflicts reads the deal again and reuses it. Two follow-on fixes came out of that. n8n would have retried the 404 of every new lead three times, 15 s in all, so the three reads by unique value return the response as data. A re-run of the day would have moved an Approved deal back to Needs approval, so a reused deal now keeps its stage unless it is still in New lead.

A failed draft reported as created

What happened
The office task read the Gmail node with first(), which is its success output only, so when Gmail failed the task still said the draft was created in Gmail. No scenario failed Gmail, so nothing noticed until the Code node was run on its own with the failure item as input. The step now reads its own input, which is Gmail's answer on one output and its error item on the other. The new gmail_down scenario (503 on every try) passes, and a copy with the old glue fails it with the warning missing.

A termite letter priced as a treatment

Why
A realtor asking for a termite letter for a closing is asking for an inspection, but the model's labels cannot say so and changing the allowed pest types would invalidate every recording. One such request came back as termites and went to the approval queue at $1,200; the other came back as other. A request that mentions a word from the rules sheet's list (WDO, wood destroying, termite letter, termite clearance) is now priced as a letter whatever pest the model named. The prices come from the rules sheet.

A key-reuse check that could not fail

What happened
The check said a key that appears twice must be marked as a replay, but the test runner sets that mark exactly when a key appears twice, so it was true by construction. It now uses the request bytes, the run id and the injected fault from the log. A unit check feeds it logs with a changed body, an unexplained reuse and a surprise redelivery, and the old check passes all of them while the new one throws.

A history that kept the lead

What happened
With saveDataSuccessExecution set to none, n8n 2.42.6 still writes the first row of every run, which holds the webhook payload, and removes it later. The first check looked for successful rows in the database and passed on its first try, which made it suspect: the rows never reach success. The check now requires that every visible row is a failed run and that the pruner removed rows during the run. The pruner buffer is set to 0 hours, so a successful run's lead data is gone within about 15 minutes.

Code, build log and full results

Next

Invoice to Payment

Invoice to Payment