We're still building things here! You might notice a few rough edges while we work on improvements. Help us improve by reporting bugs here.

Quickstart

Create an assistant, set up OAuth authentication, and embed the widget on your website.

Widget Overview

The widget app is hosted at widget.companin.tech and provides an easy way to embed an AI assistant into your website. To get started, you'll need to create an assistant and an OAuth application.

1. Create an Assistant

First, create an AI assistant in your dashboard:

  1. Go to your dashboard and navigate to the "Data Sources" page
  2. Click the "Add" button in the Assistants section
  3. Fill in the assistant details (name, description, tone, etc.)
  4. Save the assistant and note its ID

2. Create an OAuth Application

Create an OAuth application to authenticate your widget:

  1. Go to the "OAuth" page in your dashboard
  2. Click "Create Application"
  3. Fill in the application name and description
  4. Copy the client_id from the created application

3. Embed the Widget via Iframe

The simplest way to integrate the widget is by embedding it directly using an iframe. This method requires no JavaScript initialization and works out of the box.

HTML5embed.html
<iframe  src="https://widget.companin.tech/embed/session?clientId=YOUR_CLIENT_ID&assistantId=YOUR_ASSISTANT_ID&startOpen=true&locale=en"  style="border: none; position: fixed; bottom: 32px; right: 32px; z-index: 1000; background-color: transparent; width: 400px; height: 600px; border-radius: 8px;"  title="AI Assistant Widget"></iframe>

Replace YOUR_CLIENT_ID and YOUR_ASSISTANT_ID with your actual values. The locale parameter can be set to match your site's language.

Advanced: JavaScript Initialization

For more control, you can initialize the widget programmatically. First, obtain a widget token from your server.

Obtain a Widget Token

Call the widget token endpoint with the client_id to receive a short-lived JWT.

GNU Bashrequest.sh
curl -X POST https://your-api.example.com/api/auth/widget-token \  -H "Content-Type: application/json" \  -d '{"client_id":"YOUR_CLIENT_ID"}'

Initialize the Widget

Fetch the token from your server and initialize the widget.

JavaScriptinit.js
// Get token from your serverconst res = await fetch('/my-server/get-widget-token');const { token } = await res.json();// Initialize widgetwindow.MyAssistantWidget.init({  container: '#assistant',  assistantId: 'ASSISTANT_UUID',  auth: { type: 'bearer', token },});

Notes

  • Do not expose client secrets in the browser; keep them on the server.
  • Tokens are short-lived (1 hour); refresh as necessary server-side.