Log/AI agents/

Handing off from an AI agent to a human: use events, not labels

The agent for an art school in Barcelona went live, then started talking over the owner the same night. Why I now detect human replies by Kommo events.

The AI agent for an art school in Barcelona went live on September 7 at 15:00. The first prospect bought a trial 19 minutes later with no human in the loop. By 01:00 the next morning the agent was talking over the school.

Three failures that night, one cause.

A parent asked about a Thursday class in English. The agent said there was none. The teacher replied from his phone 45 minutes later: there is one. Both replies landed in the same WhatsApp thread, one after the other, with nothing in Kommo tying them together.

Another parent had just been answered by the school at 00:58 from a phone. At 01:10 the agent wrote to her anyway, saying the school had not replied yet.

A third parent said she would pay at the studio. The agent sent two more identical payment pushes after that.

Why label-based handoff did not work

I had built the handoff on CRM labels. The owner was supposed to put a “school replied” label on the deal and the agent would stay quiet. In practice the owner is not technical and does not want to tap labels on a phone. Every signal I built on top of her labels was empty most of the time.

The deeper reason is how WhatsApp coexistence works in Kommo. The teacher and the owner reply from the WhatsApp mobile app, not inside Kommo. In Kommo those outgoing messages come in tagged “Robot”: is_read does not change, in_work does not change, opening the deal card does not mark the conversation as read. Every signal I was reading sat at zero while a human was already in the chat.

Switch to events

Kommo has /api/v4/events. The events incoming_chat_message and outgoing_chat_message give time, deal id and conversation id. No text, but the fact of the message is there.

created_by on every event is 0, so I cannot tell our sends from the owner’s by that field. I tell them apart differently: in all 5 places where my service posts to Kommo, it writes a note_ours marker. Everything else is a human. One edge case: if an outgoing has no incoming before it in the last 24 hours, Kommo’s own trigger sent a template, so I treat that as not a human.

In the deal, I store two unix timestamps in a custom field: last human reply from the school, and the time the agent explicitly called a person. They survive deploys.

The rules now

  • A human writes to the client → the agent is silent on that deal for 2 hours. Every new human message extends the window.
  • The agent called a person → silent until the person responds, up to 24 hours.
  • The window expires → the open conversation is closed by the code so the Kommo trigger fires again, and the agent takes it back.
  • The watchdog calls a person on the same events: an incoming message without an outgoing after it gets the agent 3 minutes, then the school 30.
  • The old labels are still set and cleared, now by the code, so a person looking at the CRM can see what state the agent is in. Nobody is asked to manage them.

What I would do differently

Build handoff on the platform’s own events from day one, not on labels a human is supposed to maintain. Labels work if the person touching them is technical and wants a lever. In this case the owner wants to answer messages, not configure state. Events do not need text to be useful: an outgoing happened, we did not send it, therefore a human did.

The next step for this project is Kommo Pro at $45 against the current Advanced at $25. Pro ships with the External chat history right. It gives the text of incoming messages, voice transcripts included, the text of what the school replies, and the chat history from before the agent went live. $20 a month to replace the 2-hour silent window with an agent that keeps up with what the school is actually saying.

All entries · Book a call · Discuss on X