Skip to Content
Widgets & Integrations💬 Chat Widget

Chat Widget

Introduction

The DocsGPT Widget is a powerful tool that allows you to integrate AI-driven document assistance directly into your web applications. This guide will walk you through embedding the DocsGPT Widget into your projects, whether you’re using React, plain HTML, or Nextra. Enhance your user experience by providing seamless access to intelligent document search and chatbot capabilities.

Try out the interactive widget showcase and customize its parameters at the DocsGPT Widget Demo .

Setup

Installation

Make sure you have Node.js and npm (or yarn, pnpm) installed in your project. Navigate to your project directory in the terminal and install the docsgpt package:

npm install docsgpt

Usage

In your React component file, import the DocsGPTWidget component:

import { DocsGPTWidget } from "docsgpt";
🔗

Which apiHost? It is the URL of the DocsGPT API, not the app you log into. For DocsGPT Cloud that is https://gptcloud.arc53.com — which is also the widget’s built-in default, so you can omit the prop entirely. Self-hosting? Use your own API URL (http://localhost:7091 by default), not the frontend URL. A “Couldn’t generate a response” error in the chat or a CORS message in the console almost always means this is pointing at the frontend instead of the API.

Now, you can embed the widget within your React component’s JSX:

<DocsGPTWidget apiHost="https://gptcloud.arc53.com" apiKey="your-agent-api-key" avatar="https://your-cdn/avatar.png" title="Get AI assistance" description="DocsGPT's AI Chatbot is here to help" heroTitle="Welcome to DocsGPT !" heroDescription="This chatbot is built with DocsGPT and utilises GenAI, please review important information using sources." theme="dark" buttonIcon="https://your-icon" buttonBg="#222327" />

Properties Table

The DocsGPT Widget offers a range of customizable properties that allow you to tailor its appearance and behavior to perfectly match your web application. These parameters can be modified directly when embedding the widget in your React components or HTML code. Below is a detailed overview of each available prop:

PropTypeDefault ValueDescription
apiHoststring"https://gptcloud.arc53.com"The URL of your DocsGPT API backend (DocsGPT Cloud by default). Self-hosted: your API URL, e.g. http://localhost:7091.
apiKeystringa DocsGPT demo agent’s keyThe API key of your published agent (see Agent API keys). If you omit it, the widget answers from a public DocsGPT demo agent, not your documents. Always set it.
avatarstringbuilt-in placeholderURL for the avatar image shown in the chatbot header. Defaults to a person on the brand-colour circle, drawn inline, so no image is fetched unless you supply one.
heroIconstringthe DocsGPT markURL for the image on the welcome card shown before the first question. Defaults to the DocsGPT mark on the brand-colour circle, drawn inline. It is separate from avatar, so setting one leaves the other as it is.
titlestring"Get AI assistance"Title text shown in the chatbot header.
descriptionstring"DocsGPT's AI Chatbot is here to help"Sub-title or descriptive text displayed below the title in the chatbot header.
heroTitlestring"Welcome to DocsGPT !"Welcome message displayed when the chatbot is initially opened.
heroDescriptionstring"This chatbot is built with DocsGPT and utilises GenAI, please review important information using sources."Introductory text providing context or disclaimers about the chatbot.
theme"dark" | "light""dark"Color theme of the widget interface.
buttonIconstringa chat-bubble iconURL for the icon image used in the widget’s launch button. Defaults to a chat-bubble icon drawn inline.
buttonTextstring"Ask a question"Label of the widget’s launch button.
buttonBgstringthe theme’s brand colourBackground of the widget’s launch button: #7d54d1 in the light theme, #8855f1 in the dark one. Accepts any CSS background value.
size"small" | "medium" | "large" | { custom: { width, height, maxWidth?, maxHeight? } }"medium"Size of the chat panel: small is 320px × 400px, medium is 400px × 80vh, and large opens a centered 666px × 75vh modal. custom takes CSS sizes.
showSourcesbooleantrueShows the sources an answer was based on, and turns the answer’s [n] citations into links to them. Set false to hide both. See Sources and citations.
collectFeedbackbooleantrueShows like/dislike buttons on answers and sends the feedback to DocsGPT.
defaultOpenbooleanfalseOpens the chat panel on page load instead of showing only the launch button.
allowedFileExtensionsstring[]unsetFile extensions the composer accepts, e.g. ['.pdf', '.docx', '.md', '.png']. Setting it turns on attachments: an Attach button, drag-and-drop onto the panel, and paste-to-attach. Leave it unset to keep attachments off.
showMicButtonbooleanfalseAdds a microphone that dictates a question into the input using the browser’s Web Speech API. No backend STT provider needed; hides itself where the browser lacks the API.
poweredByboolean | { label: string; href?: string }trueThe credit line under the input. true shows “Powered by DocsGPT”, false hides it, and an object replaces it. See Branding.

Attachments and Voice Input

Both features are off until you turn them on, and each has a cost worth knowing about.

Attachments are enabled by allowedFileExtensions, which acts as both the switch and the filter. Every attached file is uploaded to /api/store_attachment, parsed, and its text sent with the question, billed against the token budget of the key owner’s account. Which types are worth that depends on your assistant, so there is no default list. A leading dot is optional ('pdf' works) and matching is case-insensitive.

Files that finish uploading before the question is sent are attached to it, and the send waits while any are still uploading or parsing, so a file is never silently dropped. The list only filters what the picker offers: a file it allows but the backend cannot parse is still refused by the server, and the reason appears under that file’s chip.

Voice input is enabled by showMicButton and uses the browser’s Web Speech API. Words appear in the input as they are spoken and extend whatever was already typed, so a question you had started typing survives. Nothing is uploaded to DocsGPT and no STT_PROVIDER is needed.

It is off by default because of where the audio goes. Outside the Chromium builds that expose on-device recognition, the browser forwards the microphone to its vendor’s speech service — Google’s, in Chrome’s case. That is a third-party data flow on your page, so it is your decision to enable.

Browser support is uneven, and the microphone hides itself where it cannot work. Chrome, Edge and Safari have the API, Firefox does not enable it, and it requires a secure origin (HTTPS, or localhost).

<DocsGPTWidget apiKey="your-agent-api-key" allowedFileExtensions={['.pdf', '.docx', '.md', '.png']} showMicButton />

Sources and citations

Each answer that used your documents shows a Sources row with the number of sources. It starts collapsed, so the answer comes first; selecting it opens the list.

  • A source that is a web page, such as a page ingested with the crawler or sitemap loader, is a link that opens the page in a new tab.
  • A source that is an uploaded file shows its title and the passage that was used. It is not a link, because a visitor has no way to open a file from your library.

When the agent cites its sources with [1], [2] and so on, each number becomes a small button in the answer. Selecting it opens the Sources list, scrolls to that source and highlights it. A grouped citation such as [1, 3] becomes one button per number. To get numbered citations, ask for them in the agent’s prompt; see Citations in Customizing Prompts.

Links in an answer open in a new tab, so the visitor stays on your page. A plain web address the model writes out, such as https://example.com, becomes a link too.


Branding

Three properties change what the widget shows of DocsGPT:

  • avatar sets the image in the chat header.
  • heroIcon sets the image on the welcome card. It defaults to the DocsGPT mark.
  • poweredBy sets the credit line under the input. Pass false to hide it, or an object with your own label and href. When the label starts with “Powered by”, only the name after it becomes the link.
<DocsGPTWidget apiKey="your-agent-api-key" avatar="https://your-cdn/assistant.png" heroIcon="https://your-cdn/logo.png" poweredBy={{ label: 'Powered by Acme', href: 'https://acme.example' }} />

Notes on Widget Properties

  • Full Customization: Every property listed in the table can be customized. Override the defaults to create a widget that perfectly matches your branding and application context. From avatars and titles to color schemes, you have fine-grained control over the widget’s presentation.
  • API Key Handling: Set apiKey to the API key of a published agent; the widget answers with that agent’s knowledge, prompt and tools. See Agent API keys. If you leave apiKey out, the widget falls back to a built-in key for a public DocsGPT demo agent: on DocsGPT Cloud it silently answers from that demo agent instead of your documents, and on a self-hosted instance the key is invalid and requests fail. apiHost for DocsGPT Cloud is https://gptcloud.arc53.com.

Explore and Customize Further

The DocsGPT Widget is fully open-source, allowing for deep customization and extension beyond the readily available props.

The complete source code for the React-based widget is available in the extensions/react-widget directory within the main DocsGPT GitHub Repository . Feel free to explore the code, fork the repository, and tailor the widget to your exact requirements.

Last updated on