TutorialsDecember 5, 20257 min read

Embed a Chatbot on Your Website (Step-by-Step)

Learn how to add a chatbot to any website in minutes. Copy-paste code included.

N
Nikhil
Product Engineer

How to Embed Chatnest on Your Website

Add an AI chatbot to your website in under 5 minutes. Works on any platform—no coding required.

Quick Start

Get your embed code from your Chatnest dashboard → Deploy → Public Access, then paste it before your closing </body> tag:

<script src="https://chatnest.co/widget.js"
  data-bot-id="YOUR_BOT_ID"
  data-public-key="YOUR_PUBLIC_KEY">
</script>

That's it! Your chatbot bubble will appear on every page.

Platform Guides

WordPress

Option 1: Plugin (Easiest)

  1. Install "Insert Headers and Footers" (free)
  2. Settings → Insert Headers and Footers → "Scripts in Footer"
  3. Paste embed code → Save

Option 2: Theme Editor

  1. Appearance → Theme Editor → footer.php
  2. Paste code before </body> → Update File

Shopify

  1. Online Store → Themes → Actions → Edit Code
  2. Open theme.liquid (Layout folder)
  3. Paste code before </body> → Save

Wix

  1. Settings → Custom Code → "+ Add Custom Code"
  2. Name: "Chatnest Widget"
  3. Paste code → Choose "Body - end" → "All pages" → Publish

Squarespace

  1. Settings → Advanced → Code Injection
  2. Paste in "Footer" section → Save → Publish

Note: Requires Business plan or higher

Webflow

  1. Project Settings → Custom Code tab
  2. Paste in "Footer Code" → Publish

JavaScript Frameworks

React / Next.js

'use client'; // Next.js 13+ only
import { useEffect } from 'react';

export default function ChatNestWidget({ botId, publicKey }) {
  useEffect(() => {
    const script = document.createElement('script');
    script.src = 'https://chatnest.co/widget.js';
    script.setAttribute('data-bot-id', botId);
    script.setAttribute('data-public-key', publicKey);
    document.body.appendChild(script);

    return () => {
      if (document.body.contains(script)) {
        document.body.removeChild(script);
      }
    };
  }, [botId, publicKey]);

  return null;
}

Add to layout:

import ChatNestWidget from '@/components/ChatNestWidget';

export default function Layout({ children }) {
  return (
    <html>
      <body>
        {children}
        <ChatNestWidget
          botId="your-bot-id"
          publicKey="your-public-key"
        />
      </body>
    </html>
  );
}

Vue.js 3

<script setup>
import { onMounted, onUnmounted } from 'vue';

const props = defineProps(['botId', 'publicKey']);
let script = null;

onMounted(() => {
  script = document.createElement('script');
  script.src = 'https://chatnest.co/widget.js';
  script.setAttribute('data-bot-id', props.botId);
  script.setAttribute('data-public-key', props.publicKey);
  document.body.appendChild(script);
});

onUnmounted(() => {
  if (script && document.body.contains(script)) {
    document.body.removeChild(script);
  }
});
</script>

Troubleshooting

Widget Not Showing?

  1. Check Bot ID and Public Key match your dashboard
  2. Open browser console (F12) for errors
  3. Disable ad blockers temporarily
  4. Verify code is before </body>

Want to Control Pages?

Load conditionally with JavaScript:

// Skip checkout page
if (!window.location.pathname.includes('/checkout')) {
  const script = document.createElement('script');
  script.src = 'https://chatnest.co/widget.js';
  script.setAttribute('data-bot-id', 'YOUR_BOT_ID');
  script.setAttribute('data-public-key', 'YOUR_PUBLIC_KEY');
  document.body.appendChild(script);
}

CSP Errors?

Add to Content-Security-Policy:

script-src https://chatnest.co;
connect-src https://api.chatnest.co;

Testing Checklist

After installing:

  • Widget bubble appears in bottom-right (default)
  • Clicking opens chat window
  • Bot responds to test messages
  • Works on mobile
  • Tested in Chrome, Safari, Firefox

Get Started

Create your free account → Build a bot → Deploy → Copy embed code → Paste on your site

Setup time: 5 minutes


Updated December 2025

Website IntegrationEmbed CodeWordPressShopifyHTMLTutorial
Share this article

Ready to build your AI chatbot?

Join thousands of businesses using Chatnest to automate support, generate leads, and engage customers 24/7.

No credit card required • Free plan available • Cancel anytime