CogniSync Integration Dashboard

For React Developers

Bot URL Configuration

React Integration Code

import { useEffect, useState } from 'react';

export default function ChatbotPage() {
  const [botUrl, setBotUrl] = useState('/b/YOUR_BOT_URL');
  
  useEffect(() => {
    const handleMessage = (event: MessageEvent) => {
      if (event.data.type !== 'cognisync-bot-resize') return;
      
      const { action } = event.data;
      console.log('Chatbot action:', action);
      
      // Handle resize actions: maximize, minimize, close, etc.
      switch(action) {
        case 'maximize':
          // Handle maximize
          break;
        case 'minimize':
          // Handle minimize
          break;
        case 'close':
          // Handle close
          break;
      }
    };

    window.addEventListener('message', handleMessage);
    return () => window.removeEventListener('message', handleMessage);
  }, []);

  return (
    <div className="w-full h-screen">
      <iframe
        src={botUrl}
        title="CogniSync Chatbot"
        style={{
          width: '100%',
          height: '100%',
          border: 'none',
          borderRadius: '8px',
        }}
      />
    </div>
  );
}

Setup Steps:

  1. Replace YOUR_BOT_URL with your actual bot URL (e.g., /b/your-token)
  2. The bot URL can be relative or absolute
  3. The chatbot handles its own state management
  4. Listen to cognisync-bot-resize messages for UI coordination

Note: Make sure to update the iframe src attribute with your actual CogniSync domain if self-hosting.

Quick Test Scenarios

Current Configuration:

Scenario:Test Without Token
Iframe URL:/b/

Tip: Switch between scenarios to test different configurations. The iframe will reload when you change scenarios. Watch the State Monitor to see postMessage events.

Live Preview

Test your configuration in real-time

Chat widget will appear below

Use controls on the left to configure