You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP β†’
Socket
Book a DemoInstallSign in
Socket

react-chat-ai-widget

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-chat-ai-widget

Enhance user experience with a smart widget that combines AI assistants and live chat. Automate support, stay available 24/7, and boost customer engagement effortlessly.

1.6.9
latest
Source
npmnpm
Version published
Weekly downloads
177
-63.51%
Maintainers
0
Weekly downloads
Β 
Created
Source

πŸ€– React Chat AI Widget

React Chat AI Widget is a plug-and-play React component that lets you embed a fully customizable, intelligent chatbot into your app β€” with zero backend setup required.

It supports Hugging Face or Replicate APIs for real-time AI responses, making it ideal for customer support, onboarding, FAQs, smart documentation bots, and more.

npm downloads license

✨ Features

  • πŸ€– AI chatbot powered by Hugging Face or Replicate
  • ⚑ No backend needed – fully client-side with secure token proxy
  • 🎯 Behavior-aware via use cases (e.g. support, documentation, etc.)
  • 🧩 Built with React + TypeScript
  • 🎨 Fully customizable UI and styles
  • πŸ” Tokens are secured β€” never exposed to the client
  • πŸ§ͺ Ready for testing with Vitest and Cypress

πŸ“¦ Installation

npm install react-chat-ai-widget
import { ChatWidget } from "react-chat-ai-widget";

<ChatWidget
  title="InsightFlow"
  direction="left" // or "right" (default)
  huggingface="YOUR_HUGGINGFACE_TOKEN"
  // replicate="YOUR_REPLICATE_TOKEN" (use one or the other)
  config={{
    temperature: 0.7,
    max_tokens: 200,
    top_p: 0.9,
    frequency_penalty: 0.5,
    model: "microsoft/DialoGPT-large",
    stop_sequences: ["\n\n", "Human:", "Bot:"],
  }}
  //replicate and huggingFace has different config
  data={{
    useCase: "customer-support",
    questions: [
      {
        question: "What are your business hours?",
        answer: "We’re open Monday to Friday from 10am to 4pm.",
        category: "general",
        confidence: 0.98,
      },
      {
        question: "Who wrote Don Quixote?",
        answer: "Miguel de Cervantes.",
        category: "literature",
        confidence: 0.92,
      },
    ],
  }}
  chatStyles={{}}
  formStyles={{
    inputStyles: {},
    buttonStyles: {},
    formStyles: {},
  }}
/>;

🎨 Styling

To ensure the ChatWidget renders properly, import the style file in your main entry point:

import "react-chat-ai-widget/dist/React-Chat-Widget.css";

You can customize the layout using either class names or inline style objects.

🧩 Component Props

PropTypeRequiredDescription
titlestringNoChat header title. Defaults to "AI Assistant".
dataobjectYesContains pre-defined Q&A and optional use case.
huggingfacestringConditionalYour Hugging Face API token. Do not use with replicate.
replicatestringConditionalYour Replicate API token. Do not use with huggingface.
directionstringNo"left" or "right". Default is "right".
chatClassNamestringNoCustom class for chat container.
chatStylesobjectNoInline styles for chat container.
headerClassNamestringNoCustom class for header.
headerStylesobjectNoInline styles for header section.
formStylesobjectNoObject containing style overrides for the form.
β”” inputStylesobjectNoStyles for the input field.
β”” buttonStylesobjectNoStyles for the submit button.
β”” formStylesobjectNoStyles for the entire form container.
configobjectNoConfiguration for the AI service.

🧠 Data Format

Define a list of questions and answers the chatbot can use, with an optional useCase to control tone or behavior.

{
  useCase: "qa-bot", // or "customer-support", "documentation", "strict-compliance"
  questions: [
    {
      question: "Your question here?",
      answer: "The chatbot response.",
      category: "general",
      confidence: 0.85 // Value between 0 and 1
    },
    // Add as many as needed
  ]
}

Supported useCase values

  • "customer-support": Friendly, helpful support tone
  • "documentation": Technical, concise answers
  • "qa-bot": Default Q&A with open logic
  • "strict-compliance": Controlled, policy-aware responses

πŸ” Token Security

Your API tokens are never exposed to the client.

  • βœ… Hugging Face or Replicate tokens are sent securely through a proxy
  • βœ… No direct client-to-model communication
  • βœ… Fully encrypted and safe

πŸ–ΌοΈ Chat Preview

Chat aligned leftChat aligned right
Left ChatRight Chat

πŸ”§ Advanced Model Configuration

Take full control of your AI's behavior with comprehensive model customization options:

πŸŽ›οΈ Core Parameters

  • temperature (0.0 - 2.0) - Controls response creativity and randomness

  • 0.1 = Focused, deterministic responses

  • 0.7 = Balanced creativity (recommended)

  • 1.5 = Highly creative, varied outputs

  • max_tokens (1 - 4096) - Maximum response length

  • 50 = Short, concise answers

  • 150 = Standard responses

  • 500+ = Detailed, comprehensive replies

🎯 Fine-Tuning Options

  • top_p (0.0 - 1.0) - Nucleus sampling for response diversity
  • frequency_penalty (-2.0 - 2.0) - Reduces repetitive content
  • presence_penalty (-2.0 - 2.0) - Encourages topic exploration
  • stop_sequences - Custom stop words to control response endings
  • model - Choose specific AI models for different capabilities

πŸ’‘ Example Configuration

config={{
 temperature: 0.7,
 max_tokens: 200,
 top_p: 0.9,
 frequency_penalty: 0.5,
 model: "microsoft/DialoGPT-large",
 stop_sequences: ["\n\n", "Human:", "Bot:"]
}}

⚠️ Notes

  • Do not use both huggingface and replicate props at the same time.

  • You must import the CSS file for the widget to render correctly.

  • The chatStyles and headerStyles props override any class-based styles (chatClassName, headerClassName).

    ⚠️ Important Note for Hugging Face Users If you're using this chatbot with Hugging Face and plan to enable mode (or similar streaming indicators), make sure to set max_tokens to at least 500 in your configuration.

    is necessary because consumes a significant number of tokens during generation. If max_tokens is too low, the assistant's response might get cut off or fail to generate properly.

πŸ§ͺ Testing

  • Includes support for unit and UI testing using Vitest and Cypress.
  • Example test commands:
npm run test        # Vitest
npm run dev         # Local dev mode
npm run lint        # ESLint
npm run build       # Production build

🚧 Upcoming Features

πŸ›οΈ Product Recommendation Engine

  • The chatbot will soon be able to recommend products based on user questions, behavior, and preferences in real time.

  • 🌐 Multi-language support

  • 🌎 Internationalization (i18n)

  • πŸ“Š Analytics Dashboard (Q3 2024) Conversation insights and performance metrics.

  • πŸ”— Integration Plugins (Q4 2024) Direct integrations with popular platforms (Shopify, WordPress, etc.).

πŸ“„ License

MIT Β© Jorge Ernesto

Keywords

chatbot

FAQs

Package last updated on 26 Jul 2025

Did you know?

Socket

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.

Install

Related posts