
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
@chrisabdo/rag-chatbot-widget
Advanced tools
A simple, customizable React component for adding a Retrieval-Augmented Generation (RAG) chatbot widget to your web application.
npm install rag-chatbot-widget
# or
yarn add rag-chatbot-widget
# or
pnpm add rag-chatbot-widget
import { ChatbotWidget } from 'rag-chatbot-widget';
import 'rag-chatbot-widget/styles.css'; // Import the styles
function App() {
return (
<div className="app">
<h1>My Application</h1>
{/* Add the chatbot widget */}
<ChatbotWidget
apiUrl="/api/chat"
title="Knowledge Assistant"
/>
</div>
);
}
The ChatbotWidget
component accepts the following props:
Prop | Type | Default | Description |
---|---|---|---|
title | string | 'RAG Chatbot' | Title for the chatbot modal |
buttonIcon | ReactNode | '💬' | Button icon content (emoji, text, or SVG) |
buttonAriaLabel | string | 'Open chatbot' | Button aria-label for accessibility |
zIndex | number | 9999 | CSS z-index for the widget |
buttonPosition | string | 'bottom-right' | Button position ('bottom-right' , 'bottom-left' , 'top-right' , 'top-left' ) |
buttonClassName | string | '' | Custom class for the button |
theme | string | 'auto' | Widget theme ('light' , 'dark' , 'auto' ) |
Prop | Type | Default | Description |
---|---|---|---|
apiUrl | string | '/api/chat' | API endpoint for the chatbot |
apiHeaders | object | { 'Content-Type': 'application/json' } | Headers for API requests |
placeholder | string | 'Ask a question...' | Placeholder text for the input field |
initialMessages | array | [] | Initial messages to display |
className | string | '' | Custom class for the chat component |
Your backend API should accept POST requests with the following structure:
{
"query": "User's question here"
}
And it should respond with:
{
"response": "Assistant's response here"
}
If you want to use the chat interface without the floating button and modal, you can use the Chat
component directly:
import { Chat } from 'rag-chatbot-widget';
import 'rag-chatbot-widget/styles.css';
function MyCustomChatInterface() {
return (
<div className="chat-container" style={{ height: '500px' }}>
<Chat
apiUrl="/api/chat"
placeholder="Ask me anything..."
/>
</div>
);
}
MIT
FAQs
A simple RAG chatbot widget for web applications
The npm package @chrisabdo/rag-chatbot-widget receives a total of 0 weekly downloads. As such, @chrisabdo/rag-chatbot-widget popularity was classified as not popular.
We found that @chrisabdo/rag-chatbot-widget demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.