- Serverless
- Edge
- WhatsApp Business API
WhatsApp AI Assistant
A serverless AI swiss-army knife living inside WhatsApp.
Built with
- Hono
- Upstash Workflow
- QStash
- Groq (Llama-3)
- Hugging Face
- Supabase
- Upstash Redis
- Axiom
- MTProto
The idea
I wanted a personal AI assistant inside the app I already have open all day, not another web app to visit. WhatsApp's Business API made it the perfect host. No frontend to build, no app to install, just a chat.
The hard part was never the AI. It was the plumbing. Serverless platforms kill long-running requests, WhatsApp retries webhooks aggressively, and free tiers come with tight ceilings on everything.
The pipeline
A Meta webhook lands on a Hono router, which validates it, offloads the payload to an Upstash Workflow queue, and acknowledges within about 50ms. QStash then drives the background execution loop: duplicate filtering, allowlist checks, rate limits. Only after all that does the request reach an AI engine.
From there, Groq decides whether the message needs a tool call, like checking train availability by scraping a live source, or a plain response. Uncensored mode swaps in Hugging Face with conversational memory attached. The reply goes back out through the Graph API, and structured logs flush to Axiom and Supabase.
Highlights
50ms queue-and-ack
Incoming webhooks get offloaded to Upstash's background queue instantly, so Meta receives a 200 OK before the AI even starts thinking. No more 10-second serverless execution limits.
Hybrid AI engines
Groq's Llama-3 handles everyday requests with function calling, like live-scraping Sri Lankan train schedules. An unrestricted Hugging Face model takes over in uncensored mode, with a Redis-backed 10-message memory.
AI image generation and editing
/imagine generates images from a prompt. Send a photo with a caption and the bot runs the full image-to-image pipeline through the Meta Graph API.
Telegram media bridge
Send any t.me link and the bot downloads the media over MTProto, including photos, videos, documents, and grouped albums from protected channels, then re-delivers it on WhatsApp.
Abuse-proof by design
A Supabase allowlist and an Upstash sliding-window rate limiter silently drop strangers, while an atomic SETNX lock dedupes WhatsApp's aggressive retry payloads.
Tuned to free tiers
Every dependency, from Vercel to Supabase, Groq, Hugging Face, and Upstash, runs on free plans, with payloads deliberately engineered to stay inside their limits.
