Rebuilding an AI Support Agent from n8n onto a Custom Platform

PYTHONDJANGOAI SUPPORT AGENTLANGGRAPHAUTOMATION

I have written before about the multi-agent support system I built for an Algerian e-commerce brand on n8n. It worked, and it answered thousands of messages a day. This post is about the next step: rebuilding it as a custom platform, and why a system that works is still worth rebuilding when you cannot see inside it.

Why rebuild something that worked

n8n got the agent live fast, which was the right first move. But as it grew, the things I needed most were the things a visual workflow makes hardest: versioning a prompt and rolling it back, replaying a real conversation against a new version before shipping it, letting non-technical staff edit promotions and prices without touching the logic, and seeing exactly why a given message got the answer it did. So the agent moved to a custom build, Django and a proper agent framework, where every run is recorded and inspectable. I did it for control and visibility, not for new customer features.

The bugs the rebuild exposed

Once every run was visible, three quiet failures surfaced that had been there all along. Each one ends the same way: a customer writes and hears nothing back. The first was a handoff loop. One agent handles general questions, another handles the order flow, and they pass control between them. Because each one reads the same conversation history, a message could get handed over, read as still needing the other agent, and handed straight back. When the loop hit its safety cap, the surviving message was an internal handoff token, so the customer got an empty reply, sometimes right after their order had been created. The fix was to tell the last agent in a chain, explicitly, that it is the one who must answer. The second was stranded messages. A worker would restart mid-task, or a lock would not free, and an incoming message would sit there with no reply, no error, and no alert, because nothing was watching the message's state. Now a sweep runs on a schedule: anything sitting unhandled too long gets run again, and anything stuck far too long gets flagged to a human, because by then it is a person's to answer. The third was a voice note handed to a human before anyone had heard it. The step that escalates an unreadable voice note was racing the step that transcribes it, so a few clear voice notes got escalated a second or two before their transcription landed, pulling in a person who was not needed. Ordering those two steps fixed it.

What the rebuild bought

A workflow tool is a good way to get an agent live. Once it is handling real money and real customers, you need to see every decision it makes, because these failures do not throw errors. They leave someone with no reply, and you find them only when you can watch the system instead of hoping it worked.

Results

  • The agent moved from an n8n workflow to a custom platform with full run history
  • Prompts are versioned, replayable against real conversations, and rolled back safely
  • Non-technical staff edit promotions and prices without touching the agent logic
  • Three silent failures, where a customer heard nothing, were found and closed once every run was visible
Built by Ilyes Haddad, production AI support agents. If this is a problem you have, reach me at contact@ilyeshaddad.com