I added an AI chatbot to a static website. Please don't put your API key in the frontend like I almost did
A few weeks ago a small business owner asked me for something that sounded easy: "Can you add an AI chatbot to my website? It should answer customer questions." The website was just HTML, CSS and a bit of JavaScript. No backend. No database. I thought, okay, I will call the AI API from the browser,

Posted on Dec 1 • Edited on Dec 1 • Originally published at rsflowhub.com
A few weeks ago a small business owner asked me for something that sounded easy:
"Can you add an AI chatbot to my website? It should answer customer questions."
It worked on the first try. And then I opened DevTools and saw my API key sitting in the Network tab for everyone to copy.
If you work only on the frontend, this is the fast way:
// Please do NOT do this in production fetch ( "https://some-ai-provider.com/v1/chat", { method: "POST", headers: { Authorization: "Bearer sk-my-real-secret-key" }, body: JSON. stringify ( { message: "Hello" } ), } ); Enter fullscreen mode Exit fullscreen mode It works, but here is what can go wrong:
The "right" fix is to build a small backend that hides the key. But for a simple business website, that means a server, rate limits, a database, spam protection, and someone to maintain it. That is a lot of work for one chat bubble.
You keep the key on a server and your frontend talks to your server.
// server.js (Node + Express, very simple version) import express from "express"; const app = express ( ); app. use ( express. json ( ) ); app. post ( "/chat", async ( req, res ) => { const r = await fetch ( "https://your-ai-provider.com/v1/chat", { method: "POST", headers: { Authorization: `Bearer ${process.env.AI_KEY}`, // key stays on the server "Content-Type": "application/json", }, body: JSON. stringify ( { message: req. body. message } ), } ); res. json ( await r. json ( ) ); } ); app. listen ( 3000 ); Enter fullscreen mode Exit fullscreen mode This is better. The key is safe now. But the work is not finished. You still need:
Each one is a small task. Together they are a few weeks.
I tried RSFlowHub for this. Full honesty: I built it, so I am a bit biased. But the reason I made it is exactly this problem.
The idea is simple. You paste one script tag, and the settings live in a dashboard, not in your code.
<script src = "https://rsflowhub.com/widget/v1/rsflowhub-widget.js" data-widget-token = "wt_sec_your_token_here" async ></script> Enter fullscreen mode Exit fullscreen mode That's all. No backend and no AI key in your page. The token only works for the domains you allow, so if someone copies it to another site, it won't work.
A small thing I care about as a developer: the widget loads a tiny file first (about 4 KB), and the full chat only loads when the visitor clicks the bubble. It uses Shadow DOM, so it does not mess with your CSS and your CSS does not mess with it.
Sometimes the widget is not enough. Maybe you use React and want your own design, or you only need one AI feature, like checking if a contact form message is spam.
For that you can use the RSFlowHub APIs from your own backend (or a serverless function). The key stays in an environment variable:
// Example: sentiment analysis from a serverless function const res = await fetch ( "https://apis.rsflowhub.com/api/v1/ai/sentiment-analysis", { method: "POST", headers: { Authorization: `Bearer ${process.env.RSFLOWHUB_API_KEY}`, "Content-Type": "application/json", }, body: JSON. stringify ( { text: "I waited 2 hours and nobody replied." } ), } ); console. log ( await res. json ( ) ); Enter fullscreen mode Exit fullscreen mode There are also endpoints for grammar fix, spam detection, email reply, review reply, PII redaction, text summary, image generation and more. They are small and focused, so you don't need to write long prompts yourself. There are SDKs too (PHP, Node, Python) if you don't want to write raw fetch.
You can also create API keys with limited scopes. For example, a key that can only call AI endpoints and nothing else. That way even a leaked key can't do much.
If you are a frontend developer, you don't need to become a backend engineer just to add one chatbot. Hide the key, add limits, give the bot real content. You can do that with your own proxy, or save the time and use a widget.
If you want to try it, you can start free at rsflowhub.com. The API docs are there too. I'd love to hear how you handle this on your own projects. Do you build the proxy yourself, or do you use a ready tool? Tell me in the comments.
Expand Abdullah Naseer Abdullah Naseer Abdullah Naseer Follow Need to know about me? I Can Be Your Manager Or a Worker Here's My Insta ID 👉: wogfl Come if you need Anything 🤞 Joined Oct 26, 2026 • Dec 1 Dropdown menu Copy link Hide That DevTools moment is the exact story every frontend dev needs to hear once, Rutvik — "it worked on the first try" is precisely when the key leaks, because nothing fails loudly.
The checklist is solid, and the one item I would add to the top of it is key rotation: if a key ever did make it into a shipped page, even for an hour, revoke and rotate it — domain allowlists and daily limits protect the next attempt, but the leaked key itself stays live until you kill it. Your "daily message limit" point is the one that saves real money; a bot sending 10,000 messages overnight is not a hypothetical, it is a bill.
One question on the widget side: you mention the loader is about 4 KB and the rest loads after — how do you keep the streaming and markdown rendering light once the full widget does load? That is usually where the weight creeps back in.
Honest disclosure about building RSFlowHub yourself, by the way — that earns trust, not suspicion.