1.2.8 • Published 5 months ago

rawan-bee-bot v1.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

rawan-bee-bot

A flexible, AI-powered chatbot UI component for React, supporting multiple AI providers (OpenAI, Mistral, self-hosted LLMs).

📌 Features

  • Prebuilt Chat UI – Easily embed a chatbot into any React project.
  • Multi-AI Support – Supports OpenAI, Mistral (self-hosted via Ollama).
  • Theming & Customization – Modify UI colors, fonts, and styles.
  • Message Storage – Supports local storage & API-based message saving.
  • Responsive & Mobile-Friendly – Works across all screen sizes.

🚀 Installation

npm install rawan-bee-bot

or

yarn add rawan-bee-bot

🔧 Usage

Import and integrate the chatbot inside your React project:

import React from "react";
import ChatbotUI from "rawan-bee-bot";

const App = () => {
  const saveMessageToDatabase = async (message) => {
    await fetch("https://your-api.com/save-message", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(message),
    });
  };

  return (
    <ChatbotUI
      aiProvider="selfhosted" // Use "openai" for OpenAI API
      apiKey="YOUR_OPENAI_API_KEY" // Required only for OpenAI
      backendUrl="http://localhost:11434/api/generate" // Required only for Mistral (Ollama)
      theme={{
        chatButtonBg: "#B20710",
        chatButtonTextColor: "#ffffff",
        headerBg: "#131834",
        headerTextColor: "#ffffff",
        closeButtonColor: "#ffffff",
        userMessageBg: "#B20710",
        userMessageText: "#ffffff",
        botMessageBg: "#43465e",
        botMessageText: "#ffffff",
        inputContainerBg: "#131834",
        inputFieldBg: "#43465e",
        inputFieldText: "#ffffff",
        sendButtonBg: "#B20710",
        sendButtonTextColor: "#fff",
        typingIndicatorColor: "#fff",
      }}
      onSaveMessage={saveMessageToDatabase}
    />
  );
};

export default App;

🌍 AI Providers

This chatbot supports multiple AI backends. Choose one of the following:

🔹 OpenAI API

  • Set aiProvider="openai" and provide an API key.
<ChatbotUI
  aiProvider="openai"
  apiKey="YOUR_OPENAI_API_KEY"
/>

🔹 Mistral (Self-hosted via Ollama)

  • Requires Ollama installed locally.
  • Runs a Mistral model on http://localhost:11434/api/generate.
<ChatbotUI
  aiProvider="selfhosted"
  backendUrl="http://localhost:11434/api/generate"
/>

🎨 Customization

You can fully customize the chatbot UI with the theme prop:

PropertyDescriptionDefault
chatButtonBgChat button background color#0084ff
chatButtonTextColorChat button text color#fff
headerBgHeader background color#0084ff
headerTextColorHeader text color#fff
closeButtonColorClose button color#fff
userMessageBgUser message background#0084ff
userMessageTextUser message text color#fff
botMessageBgBot message background#e4e6eb
botMessageTextBot message text color#000
inputContainerBgInput container background#f1f1f1
inputFieldBgInput field background#fff
inputFieldTextInput field text color#000
sendButtonBgSend button background#0084ff
sendButtonTextColorSend button text color#fff
typingIndicatorColorTyping indicator color#666

💾 Saving Messages

You can store chat messages locally or send them to a database.

1⃣ Local Storage (Default)

The chatbot automatically saves messages in the browser's localStorage.

2⃣ Save to Database

Pass a function to onSaveMessage to send messages to an API:

const saveMessageToDatabase = async (message) => {
  await fetch("https://your-api.com/save-message", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(message),
  });
};

<ChatbotUI onSaveMessage={saveMessageToDatabase} />;

💻 Development

1️⃣ Clone the Repository

git clone https://github.com/RawanBee/rawan-bee-bot.git
cd rawan-bee-bot
npm install

2️⃣ Build the Project

npm run build

4️⃣ Publish to NPM

npm publish

Screenshot

Here is a preview of the chatbot UI:

Chatbot UI


📝 License

This project is licensed under the MIT License. Feel free to use and modify it.


📞 Support

For questions and issues, open an issue on GitHub.


🚀 Happy Coding! 🎉

1.2.8

5 months ago

1.2.7

5 months ago

1.2.6

5 months ago

1.2.5

5 months ago

1.2.4

5 months ago

1.2.3

5 months ago

1.2.2

5 months ago

1.2.1

5 months ago

1.2.0

5 months ago

1.1.9

5 months ago

1.1.8

5 months ago

1.1.7

5 months ago

1.1.5

5 months ago

1.1.4

5 months ago

1.1.3

5 months ago

1.1.2

5 months ago

1.1.1

5 months ago

1.1.0

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago