Kumar Harsh Available for freelance work

How to build a WhatsApp AI assistant on Cloudflare Workers

By Kumar Harsh, , 3 min read

Honey is a personal AI assistant that lives in WhatsApp. It remembers facts, sets reminders, logs expenses from receipt photos and understands voice notes in English, Hindi and Hinglish. It runs on free-tier infrastructure for ₹0 a month. This article walks through the architecture in the order a message travels through it, and what to copy if you are building something similar.

The full case study, with a live outage demo, is on the Honey page.

The constraint: ₹0 a month

Honey runs serverless on Cloudflare Workers, a Cloudflare D1 database and a multi-provider AI cascade. The budget shaped every decision: no always-on server to pay for, no separate vector database to host, and no dependency on a single AI provider.

1. A message arrives

WhatsApp passes each message to the Meta Cloud API, which calls a webhook. In Honey the webhook is a Cloudflare Worker running at the edge. Two rules apply to any bot built on the WhatsApp Cloud API:

  • The webhook must pass Meta’s verification handshake before messages are delivered to it.
  • It should return a success response quickly and finish the slow work, such as calling a model and writing to the database, after responding. In a Worker, ctx.waitUntil() keeps that work running once the response has gone out.

2. The cascade answers

Workers AI (Llama 3) answers first. If it is rate-limited or slow, the request moves to Groq, and then to Gemini 2.5 Flash. Free tiers have limits, so a cascade is what lets a zero-cost assistant stay available: a limit on one provider moves the request to the next instead of ending the conversation.

The design details, including timeouts, retries and circuit breakers, are covered in LLM provider failover. On the Honey page you can pick an outage and watch the reply move down the cascade.

3. Memory

Context lives in a D1 vector database. Facts, notes and journal entries are stored with multilingual embeddings, so recall works by meaning instead of exact keywords. That matters for a user who mixes English, Hindi and Hinglish in one chat.

At personal scale there is no need for a separate vector service. A single table that keeps each piece of text next to its embedding is enough to start.

4. Scheduled routines

A minutely cron engine runs the routines: an 8:00 AM morning briefing, a 1:00 PM daily quiz, an 8:30 PM habits check-in and market alerts every 15 minutes. One trigger that fires every minute and checks what is due keeps the scheduling logic in one place.

What to copy if you build your own

  • Respond to the webhook fast and do the work afterwards.
  • Put the cheapest, fastest model first in the cascade and the most capable fallback last.
  • Keep the cascade behind one function, so a provider can be swapped without touching the rest of the code.
  • Store embeddings next to the text you will show the user.
  • Start with one routine, then add more once the first runs reliably.

Want a WhatsApp agent of your own?

This is the kind of system I build as a freelance AI engineer. See AI agent development, use the scope estimator or send a brief. You get a direct reply within 12 hours.

Keep reading

LLM provider failoverRead the articleHow long to build an AI agentRead the article