Eyal Mordechai

Lead Bot · AI agent · 2026

Taught a WhatsApp bot to warm up leads before a sales rep steps in

A training academy with an online store was sending ad leads to a WhatsApp bot. I turned an early, fragile bot into one that asks the right questions, answers only from what it can check, and hands the sales team leads that are ready to talk.

Role
Engineering & conversation design
When
Jul–Aug 2026
Built with
LangGraph, RAG, CRM & store APIs
Status
Ran in production
18:10
AA

Academy Advisor

online

TODAY
Message
0 / 16

Agent · tool calls

Waiting for the first message…

A scripted replay: the lead, the messages, the products and the numbers are made up. The tool names and rules are the bot's real ones.

72

of the 134 commits are mine, Jul–Aug 2026

8

tools the agent can call

5

paths a lead can take: course, store, service, hobby, job

3

lead levels the sales team sees in the CRM

How it's built

One agent, a few tools, and code around it

The model decides what to say and what it learned. The code around it decides what's allowed: which values get saved, when a call can be booked, and what happens when the model gets it wrong.

One message, start to finish

Lead on WhatsApp

Usually straight from an ad

Message handler

Detects the ad campaign, 90s timeout, error shown in the admin

Agent

LangGraph ReAct agent on an OpenAI model. System prompt, rules, the lead's saved state and the last 30 messages.

Safety nets in code

Hebrew check, booking-promise check, filler and markdown cleanup

Reply on WhatsApp

With a human-feeling typing delay

Tool calls · the functions the agent can call

search_knowledge()

search_shop_products()

classify_lead()

schedule_call()

cancel_call()

send_video()

recommend_video()

mark_not_relevant()

Where it reads and writes

Postgres

Chroma

CRM · new API version

Their online store

Running alongside

Follow-ups

CRM retry queue

New-lead opener

Docker on a cloud server

Built by meExtended by meAlready thereI worked on it with another developer, who built the first version.
Tone: an advisor, not a salesperson! You explain, guide and advise. You don't sell.
One of the bot's rules, translated from the Hebrew system prompt

The CRM

Plugging into the CRM the team already used

The sales team lived in their CRM, so the bot had to write there: who's ready, who replied, and when to call. The hard part wasn't the code.

01 · Before

A workaround that broke every day

The CRM's public API could only add leads. Asked to update one it couldn't find, it created a new one, and duplicates piled up in a junk campaign.

So the bot used the CRM's internal admin pages, with cookies copied from a logged-in browser. One of them expired every 24 hours, and then updates failed without anyone noticing.

02 · The ask

I asked the vendor instead

Rather than build another workaround, I messaged the CRM company on WhatsApp with one specific request: let us change a lead's status and add a tag, by phone number.

I kept following up. A few days later they shipped a new API version that did exactly that.

03 · After

Every update, checked

I rebuilt the integration on the new API. When the bot books a call:

  1. 1. → getLeadStatus(phone)← leadId
  2. 2. → updateLeadStatus(leadId, level 1)
  3. 3. → addLeadTag(leadId, "call window · 15-18")
  4. 4. → getLeadStatus(leadId)← status matches ✓

Leads from ads often reach the bot before the CRM has them. Then the update waits in a queue and retries until the lead shows up.

The sales team's lead list

Rebuilt from the real screen, with made-up leads

  • Noa L.New · Level 2
    Facebook · Today, 18:04
    WhatsAppsource: ad campaigncall window · 15-18
  • Amir K.New · Level 2
    Facebook · Today, 17:41
    WhatsAppsource: ad campaign
  • Dana R.New · Level 1
    Website · Today, 16:05
    Website form
  • Yossi M.New · Level 3
    Facebook · Yesterday, 21:12
    WhatsApp

schedule_call() → Noa's row: Level 2 → Level 1, plus the call-window tag

What the rep sees in the CRM

  • Never replied to the botLevel 3
  • Replied, still talkingLevel 2
  • Booked a call with the botLevel 1 + call-window tag
  • Came from a form, the website or a phone callLevel 1 right away

Where it broke

Every bug became a rule

I read real conversations and the client's complaints, and fixed what broke, in the prompt, in the code, or both. These are from my commits.

  1. 23 Jul

    Leads from ads reached the bot before the CRM had them, so their updates were lost.

    Retry the lookup, then a background queue on the new CRM API, and check that each status actually landed.

    code
  2. 24 Jul

    The bot booked calls for Friday and Saturday, when nobody calls back.

    Inject today's day into the prompt. On weekends it asks for a Sunday–Thursday window first.

    promptcode
    ↳ 2 Aug

    Then it got the day wrong: Python counts Monday as 0, and my map started at Sunday.

    Fixed the mapping.

  3. 28 Jul

    It offered a call before it knew anything about the person.

    A gate: at least 2 of familiarity, field and experience before offering a call, unless the lead asks for one.

    prompt
  4. 29 Jul

    It answered “I'll check and get back to you” instead of looking it up.

    Search the knowledge base before every answer about courses, licences or prices. Only if that's empty, hand it to an advisor.

    prompt
  5. 3 Aug

    Leads who said “not relevant” kept getting nudges.

    Flag them and skip them in the follow-ups. If they come back on their own, clear the flag.

    code
  6. 5 Aug

    When the bot promised a call without booking it, the safety net pushed the lead with “any time”.

    No push without a real call window. And no call offer in the same message as a video.

    codeprompt
  7. 13 Aug

    Conversations died: offers to call in every message, endings like “if you want to hear more, I'm here”.

    Every message ends with a real question. A call offer at most once every 3–4 messages. The new filler phrase is caught in code.

    promptcode
  8. 25 Aug

    One stuck message could leave a lead without an answer, and nobody knew.

    A 90-second timeout per message, and the last error shown on the lead in the admin.

    code
The journaling app’s writing screen, shown on a laptop

Next project

Final Project

An AI journal for self-reflection

Bezalel2025
Read the case study →