Developer Guide
Embeddable Widget

Embeddable Widget

Add IntelliRepo's AI-powered chat directly to your website, intranet, or application. Users can ask questions without leaving your platform.


Quick Start

Add these lines to your HTML:

<script src="https://api.intellirepo.ai/widget/intellirepo-chat.js"></script>
<script>
  IntelliRepoChat.init({
    apiKey: 'rh_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  });
</script>

A chat button appears in the bottom-right corner. Click it to open the chat interface.


Configuration

Customize the widget with these options:

IntelliRepoChat.init({
  // Required
  apiKey: 'rh_live_xxx',
 
  // Optional: Limit to specific collection
  collectionId: 'uuid-of-collection',
 
  // Optional: Customize appearance
  primaryColor: '#4F46E5',
  position: 'right',  // 'left' or 'right'
 
  // Optional: Customize text
  title: 'Ask a Question',
  placeholder: 'Type your question...',
  welcomeMessage: 'Hi! How can I help you today?'
});

All Options

OptionTypeDefaultDescription
apiKeystringrequiredAPI key with chat scope
collectionIdstringnullLimit to one collection
primaryColorstring#4F46E5Theme color (hex)
positionstringrightButton position
titlestringAsk a QuestionChat window title
placeholderstringType your question...Input placeholder
welcomeMessagestringnullInitial assistant message

Customization

Colors

IntelliRepoChat.init({
  apiKey: 'rh_live_xxx',
  primaryColor: '#10B981'  // Emerald green
});

The primary color affects the chat button, header, and send button.

Position

IntelliRepoChat.init({
  apiKey: 'rh_live_xxx',
  position: 'left'  // Button on bottom-left
});

Programmatic Control

Open/Close

// Open the chat
IntelliRepoChat.open();
 
// Close the chat
IntelliRepoChat.close();
 
// Toggle open/closed
IntelliRepoChat.toggle();

Send a Message

// Pre-fill and send a question
IntelliRepoChat.ask('What is the return policy?');

Remove Widget

// Remove widget from page
IntelliRepoChat.destroy();

Collection Scoping

Single Collection

Limit the widget to search only one collection:

IntelliRepoChat.init({
  apiKey: 'rh_live_xxx',
  collectionId: 'your-collection-uuid'
});

All Collections

Omit collectionId to search all collections the API key can access.


Use Case Examples

Customer Support Portal

<script src="https://api.intellirepo.ai/widget/intellirepo-chat.js"></script>
<script>
  IntelliRepoChat.init({
    apiKey: 'rh_live_support_key',
    collectionId: 'faq-collection-id',
    title: 'Need Help?',
    welcomeMessage: 'Hi! Ask me anything about our products.',
    primaryColor: '#2563EB'
  });
</script>

Internal Knowledge Base

<script src="https://intranet.company.com/widget/intellirepo-chat.js"></script>
<script>
  IntelliRepoChat.init({
    apiKey: 'rh_live_internal_key',
    title: 'Company Wiki',
    welcomeMessage: 'Ask about policies, procedures, or benefits.'
  });
</script>

Learning Platform

<script src="https://lms.company.com/widget/intellirepo-chat.js"></script>
<script>
  IntelliRepoChat.init({
    apiKey: 'rh_live_training_key',
    collectionId: 'training-materials-uuid',
    title: 'Course Assistant',
    primaryColor: '#7C3AED'
  });
</script>

Security

API Key Scopes

The widget API key should have:

  • read scope (to search documents)
  • chat scope (to use chat endpoints)

Never use a key with write scope in a public widget.

Collection Restrictions

For public-facing widgets, create an API key restricted to specific collections:

  1. Go to Settings > API Keys
  2. Create a key with read and chat scopes
  3. Restrict to only public/safe collections

Rate Limiting

Widget queries count toward your plan's query limit. Monitor usage in Settings > Usage.


Troubleshooting

Widget Not Appearing

  1. Check browser console for JavaScript errors
  2. Verify the API key is valid
  3. Ensure the script URL is correct
  4. Check for JavaScript conflicts

"Unauthorized" Errors

  1. Verify API key has chat scope
  2. Check if key was revoked
  3. Ensure collection access is correct (if restricted)

Slow Responses

  1. Response time depends on document count
  2. Consider scoping to a specific collection
  3. Check your internet connection

CORS Errors

If you see CORS errors, contact support to add your domain to the allowed origins.


CSS Customization

The widget uses shadow DOM for isolation. Override styles with CSS:

.intellirepo-chat-button {
  /* Customize the floating button */
}
 
.intellirepo-chat-window {
  /* Customize the chat window */
}

Single Page Applications

For SPAs (React, Vue, Angular), initialize after the page loads:

// React example
useEffect(() => {
  IntelliRepoChat.init({ apiKey: 'rh_live_xxx' });
 
  return () => {
    IntelliRepoChat.destroy();
  };
}, []);

Related Articles


Need Help?

Contact our support team if you need help with the widget.