SEO audit and AI marketing agent for an online store
I built a backend that audits a store's SEO, tracks rankings and runs a daily AI agent that writes blog drafts, plus a WhatsApp assistant for customer chats.
The problem
I needed to grow a new store's search traffic without hiring an SEO agency, and to answer customer WhatsApp messages at any hour.
How I built it
An Express and TypeScript service with a crawler that reads the sitemap first (which suits a single-page app), a page scorer, keyword research from autocomplete and trends, rank tracking, and a daily agent. The agent gathers the data, asks a language model what to do, works through the tasks (meta tags, blog drafts, internal links, competitor pages), then emails a digest, with a weekly strategy report on Mondays. A WhatsApp assistant (GPT-4o, voice notes transcribed with Deepgram, orders forwarded to suppliers) ran from the same service. I cloned the engine for a second site in April.
What got hard
- The AI features kept dying as API keys and providers failed one after another: a key went dead, one provider could not be reached from the host's region, another key was invalid.
I built a provider chain with fallbacks, so the next available model takes over, and later made rate-limit responses retry instead of marking a working provider as dead.
- Every language-model call failed with 'Premature close' on the host.
The host was reusing connections that the provider's edge had already closed. Forcing fresh, non-pooled connections for each model request fixed it for every provider.
- The WhatsApp client crashed at start-up on the cloud host and logged the shop out on every deploy.
I cleared stale browser lock files at start, ran the browser in single-process mode, and set the client to take over a session on conflict.
- Scheduled jobs failed without anyone noticing.
Every failed cron job now alerts the owner by email and WhatsApp, a morning brief goes out daily, and a blog task is injected whenever three days pass without a post.
The result
The daily digest and weekly report emails were verified working in production. The hosted instance is not running now, so I list it as built and archived, with the code ready to redeploy.
The ← and → keys turn the page too.