Back to blog
August 20, 2025

Scaling an Open-Source Chatbot to 700+ Stars

Lessons learned contributing to Hexabot, an open-source chatbot builder adopted by major telecom providers.

open-sourcechatbotdistributed-systems

Scaling an Open-Source Chatbot to 700+ Stars

Contributing to Hexabot taught me that building for the open-source community is fundamentally different from building internal tools. Here is what I learned.

What is Hexabot?

Hexabot is an open-source chatbot builder that lets non-technical users create conversational flows visually. Think of it as a self-hosted alternative to Dialogflow or Botpress, built with NestJS and Next.js.

It was adopted by major Tunisian telecom providers, serving 500+ daily active users.

The Horizontal Scaling Problem

As Hexabot grew, we needed to run multiple instances behind a load balancer. But we had a problem: cron jobs.

Several background tasks (message cleanup, analytics aggregation, session expiry) ran as cron jobs. With multiple instances, each job would execute N times — once per instance.

The Solution: Zookeeper Leader Election

We implemented a leader election mechanism using Apache Zookeeper:

// Only the leader instance runs cron jobs
const isLeader = await zookeeperClient.isLeader();
if (!isLeader) return;
 
await runScheduledJob();

Each instance registers as a candidate in Zookeeper. Only the elected leader runs scheduled tasks. If the leader goes down, another instance is automatically elected.

CI/CD Optimization

The Docker build was taking 8+ minutes in CI. We cut it to under 4 minutes (53% reduction) with:

  1. Multi-stage builds — Separate build and runtime stages
  2. Layer caching — Install dependencies before copying source code
  3. .dockerignore — Exclude tests, docs, and local configs

What I Learned

  • Open source is about community, not just code. Reviewing PRs and helping contributors is as important as writing features.
  • Backwards compatibility matters. When telecom companies depend on your API, you cannot make breaking changes lightly.
  • Documentation is a feature. Every hour spent on docs saves ten hours of GitHub issues.