Chatbot for Custom Website Builds: Where the Script Goes in Your Templates, Which Environment Gets Which Key, and What Your Security Rules Must Allow
Chatbot for custom website projects is not a plugin job. You have a codebase, templates, a build, maybe a content security policy, and a staging site you do not want counted as a real one. This guide covers where the script belongs, how to keep keys per environment, and which parts need a developer.
⚡ In short
- There is no framework package to install. The install is one script tag in the layout every page shares.
- Use a separate website, and so a separate key, for staging if you test with real traffic. Do not reuse the live key.
- If you run a content security policy or a consent banner, tell them about the chat script.
- Everything past the plain install uses the JavaScript API, webhooks or the REST API, not a native framework integration.

Starting point
Start from your base layout, not from a page
In a custom build there is nearly always one file that wraps every page: a base template, a layout, a master view. The chat script belongs there, once, near the end of the body.
Why the layout
Pages added next year inherit it. A template that renders the layout also renders the chat, so you never maintain a list of pages. Compare that with a plain folder of files in our HTML website rollout guide.
What you paste
The dashboard gives you one line that loads the widget and carries your website key. Paste it exactly as given. Do not wrap it in your own loader unless you have a reason, because the simplest path is the one with the fewest places to fail.
Server-side frameworks, in general
Whether your layout is a PHP view, a Django or Rails template or a Node render function, the rule is the same. Output the script tag in the layout, not inside a page body.
Environments
Keep one key per environment for a chatbot for custom website work
Each website in LiveChatBot has its own key, and visitors count against that website.
Why not reuse the live key
If staging and live share a key, your own testers and automated checks use up free visitors and mix test chats into your real inbox. The free plan gives you two websites, so one can be live and one can be a staging site.
How to wire it
Read the key from configuration, an environment variable or a settings file, and output the script only where a key exists. Leave it empty on local development, where you rarely need a chat. Then the layout needs no condition on the host name.
An extra website beyond two costs ₹199 for six months. See pricing for the full list.
Try it
What does your custom site need from a developer?
Follow the branch that matches what you want. The tree shows whether it is a template change, a settings change or custom code.
Security
Security rules: CSP, consent and caching
Content security policy
If your site sends a content security policy header, it will block a script from a domain it does not list. Add the LiveChatBot script address to your script rules, then open the browser console on a test page. Any blocked request is listed there, so you can see which other directives need the same domain. Change one thing at a time and reload.
Cookie consent
If you load marketing scripts only after consent, decide whether chat counts as one. That is a legal and policy choice for you, not something the chat tool can decide. Many sites let the widget load but explain it in their privacy notice. Ask your adviser, and see our notes on visitor tracking.
Caching and CDNs
Cached pages carry the script tag with them, which is what you want. Clear the cache after the change so old HTML does not linger.
Going further
What a chatbot for custom website code can do beyond the install
The widget exposes window.LiveChatBot with open, close, show, hide, setVisitor, sendMessage, pageView and on. That is the full list; do not expect other methods.
Pass a known customer
After login, call setVisitor with the user’s name and an email or phone number. Your team then sees who they are talking to. Do this only after a real login and mention website chat in your privacy notice.
Single-page navigation
If your pages change without a reload, call pageView after each route change so tracking and page rules stay accurate. The API snippets guide has examples.
Move data out
Ticket webhooks fire when a ticket is created or solved, and the REST API reads and updates tickets from your server. For a no-code route, use Zapier. Ask our team for developer documentation for the endpoints.
Testing
A release check for your chatbot for custom website deploys
Add chat to your release routine in four quick checks.
Before deploy
Confirm the key in configuration belongs to the right website, and that local and test builds leave it empty or use the staging key.
After deploy
Open the live site in a private window and look for the bubble. Send a message and make sure it lands in the inbox and the Android app. Open the browser console and check for blocked requests.
On an error page
Visit your 404 and 500 pages. If they use a different layout, the chat may be missing there, which is often fine. Decide on purpose rather than by accident.
Knowledge
Teach the bot what only your custom site knows
A custom site often has logic the chat cannot see: pricing rules, stock levels, member data. The AI Agent answers only from the knowledge you give it, so write down the rules in plain words and keep them current. Read how to train your AI chatbot for the method.
For anything that depends on live data, such as an order’s status, do not let the bot guess. Send the customer to a person, a ticket or a self-service page of your own.
Honest gaps
What it will not do for your custom build
- No native packages for any framework, and no server-side SDK.
- No direct connection to your database or admin panel. Data moves through webhooks, the REST API or Zapier.
- No pre-chat form, no badge removal (“Powered by LiveChatBot” stays), no WhatsApp inbox and no iOS team app.
- No single sign-on, audit logs or staff roles.
If your project needs those, a different tool, or building your own, may fit better.
Frequently asked questions
Can I add a chatbot to a site I built myself?
Yes. Paste the script tag into your base layout. No plugin, framework package or server setup is needed.
Do I need a separate key for staging?
It is wise. Each website has its own key, and you can use the second free website for staging so tests do not use live visitors.
Will my content security policy block it?
It can, if the policy does not list the script’s domain. Add it, then watch the browser console for other blocked requests.
Is there a React or other framework package?
No. For React-style apps you load the same script once and use the JavaScript API for route changes.
Is a chatbot for custom website projects free?
The free plan covers two websites and 100 free new visitors per website each month, with one-time packs after that.
Keep reading
Related guides
Chatbot for HTML Website Rollout: Get One Snippet onto Every Page and Prove It Works on All of Them
Chatbot for React Website Projects: Load the Script Once, Survive Route Changes and Avoid Double Installs (Copy-Ready Snippets)
Free Chatbot for Webflow: What Stays Free, What Costs Money and What Webflow Itself Charges For
Add chat to your own build
One script, a free plan for two websites and no per-seat charges. Start on livechatbot.in.