ConnectGain Chat Widget

A modern, WhatsApp-like chat widget with full media support and n8n integration

Widget Configuration

Configure your widget settings below and click "Initialize Widget" to see it in action!

Your unique identifier for the webhook
n8n webhook that receives messages from users

Cloudinary CDN Configuration

Get your cloud name from Cloudinary dashboard
Must be an unsigned preset
Folder to organize uploads in Cloudinary

Features

Text Messages

Send and receive text messages with emoji support and URL previews

Images

Share images with automatic compression and thumbnail generation

Videos

Send and play videos directly in the chat interface

Voice Notes

Record and send voice messages with waveform visualization

Documents

Share PDFs, Word docs, Excel sheets, and more

URL Previews

Automatic link previews with title, description, and image

Quick Integration Guide

1. Include the Widget Script (Recommended: Cache Busting)

<script>
  // Force cache refresh - load from CDN with timestamp
  (function() {
    const script = document.createElement('script');
    script.src = 'https://widget.connectgain.cloud/connectgain-widget.min.js?v=' + Date.now();
    script.async = true;
    document.head.appendChild(script);
  })();
</script>

Why cache busting? Ensures you always get the latest widget version with all bug fixes and features.

2. Initialize the Widget

<script>
  ConnectGainWidget.init({
    apiKey: 'your-appgain-api-key',
    suitId: 'your-unique-suit-id',
    webhooks: {
      incoming: 'https://n8n.instabackend.io/webhook/bot'
    },
    theme: {
      primaryColor: '#7C3AED',
      headerText: 'Support Chat'
    }
  });
</script>

3. Send Messages from n8n to Widget

n8n can send messages directly to the widget using JavaScript:

// In your n8n workflow, use Execute JavaScript node:
ConnectGainWidget.sendMessage({
  type: 'text',
  text: 'Hello from n8n!',
  sender: 'agent'
});

// Or send media messages:
ConnectGainWidget.sendMessage({
  type: 'image',
  fileUrl: 'https://example.com/image.jpg',
  thumbnailUrl: 'https://example.com/thumb.jpg',
  caption: 'Here is the image you requested',
  sender: 'agent'
});

4. n8n Webhook Configuration

Your n8n workflow should:

Supported Message Types

The widget supports all common WhatsApp message types:

Text Messages Images (JPG, PNG, GIF, WebP) Videos (MP4, WebM) Voice Notes Documents (PDF, DOC, XLS, PPT) Audio Files (MP3, WAV, OGG) URL Previews

Test the Widget

After initializing the widget, try these test scenarios:

  1. Send a text message with emojis 😊
  2. Share a URL to see the preview: https://github.com
  3. Upload an image using the attachment button
  4. Record a voice message
  5. Upload a document (PDF, Word, etc.)
  6. Test the typing indicator

Simulate Incoming Message

You can also push messages directly to the widget: