HomeDocumentation

Widget Embedding

Add your AI chatbot to any website in seconds with our simple embed code.

Quick Start

Add this code before the closing </body> tag:

<script 
  src="https://www.chatreact.ai/embed/widget.js" 
  data-chatbot-id="YOUR_CHATBOT_ID" 
  async
></script>

That's it! Your chatbot is now live on your website.

Finding Your Chatbot ID

  1. Go to your chatbot's settings
  2. Navigate to the Embed tab
  3. Copy the embed code (includes your ID)

Or find the ID in your dashboard URL: /dashboard/company/chatbots/[CHATBOT_ID]

Widget Options

Customize the widget with data attributes:

Basic Options

<script 
  src="https://www.chatreact.ai/embed/widget.js" 
  data-chatbot-id="YOUR_CHATBOT_ID"
  data-position="bottom-right"
  data-language="en"
  async
></script>
AttributeValuesDefault
data-positionbottom-right, bottom-leftbottom-right
data-languageAny language codeAuto-detect
data-opentrue, falsefalse

Color Overrides

Override dashboard settings with inline colors:

<script 
  src="https://www.chatreact.ai/embed/widget.js" 
  data-chatbot-id="YOUR_CHATBOT_ID"
  data-primary-color="#8B5CF6"
  data-background-color="#0F172A"
  data-text-color="#F1F5F9"
  data-border-radius="24"
  async
></script>

FAQ Widget

Display FAQs as an accordion on any page:

<div id="chatreact-faq"></div>
<script 
  src="https://www.chatreact.ai/embed/faq-widget.js" 
  data-chatbot-id="YOUR_CHATBOT_ID"
  data-primary-color="#8B5CF6"
  data-background-color="#0F172A"
  data-text-color="#F1F5F9"
  data-border-radius="24"
  async
></script>

The FAQ widget shows published FAQs from your chatbot.

Platform-Specific Guides

WordPress

  1. Install any "Header/Footer Scripts" plugin
  2. Add the embed code to the footer section
  3. Save and publish

Shopify

Recommended: ChatReact Shopify App

Install the ChatReact app from the Shopify App Store for the easiest integration:

  1. Install the ChatReact app in your Shopify admin
  2. Enter your Chatbot ID in the app settings
  3. The chat widget automatically appears on your storefront
  4. Manage widget assignments per page, or enable it everywhere

The app also supports Form and FAQ widgets as App Blocks in the Theme Editor.

Alternative: Manual Embed

  1. Go to Online Store → Themes → Edit Code
  2. Open theme.liquid
  3. Add code before </body>
  4. Save

Webflow

  1. Go to Project Settings → Custom Code
  2. Add to Footer Code
  3. Publish site

Next.js / React

Use the Script component:

import Script from 'next/script';

export default function Layout({ children }) {
  return (
    <>
      {children}
      <Script 
        src="https://www.chatreact.ai/embed/widget.js"
        data-chatbot-id="YOUR_CHATBOT_ID"
        strategy="lazyOnload"
      />
    </>
  );
}

Vue.js

Add to your main App.vue or layout:

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

onMounted(() => {
  const script = document.createElement('script');
  script.src = 'https://www.chatreact.ai/embed/widget.js';
  script.dataset.chatbotId = 'YOUR_CHATBOT_ID';
  script.async = true;
  document.body.appendChild(script);
});
</script>

JavaScript API

Interact with the widget programmatically:

// Open the chat
ChatReact.open();

// Close the chat
ChatReact.close();

// Toggle open/closed
ChatReact.toggle();

// Send a message
ChatReact.sendMessage('Hello!');

// Set user data
ChatReact.setUser({
  name: 'John Doe',
  email: '[email protected]'
});

Testing

Preview Mode

Before embedding live:

  1. Use the Preview feature in your dashboard
  2. Test different scenarios
  3. Verify responses are accurate

Local Development

For local testing, use localhost URLs:

<script 
  src="http://localhost:3000/embed/widget.js" 
  data-chatbot-id="YOUR_CHATBOT_ID" 
  async
></script>

Troubleshooting

Widget Not Appearing

  1. Check browser console for errors
  2. Verify chatbot ID is correct
  3. Ensure chatbot is active (not disabled)
  4. Check if ad blockers are interfering

Styling Conflicts

If your site's CSS conflicts:

  • Widget uses shadow DOM for isolation
  • Check z-index values
  • Ensure no !important overrides

Performance

The widget is designed for minimal impact:

  • Lazy loaded
  • < 50KB total size
  • Non-blocking
  • Cached aggressively

Next Steps