1.0.0 • Published 1 year ago

react-gemini-ai-chatbot v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

React Gemini AI Chat bot

React AI Chatbot is a React component package that allows developers to easily integrate a chatbot powered by Google's Gemini AI model into their client websites for help desk purposes, queries, and more.

Features

  • Integration of Google's Gemini AI model for conversational interactions.
  • Customizable chatbot appearance and behavior.
  • Predefined training data structure for easy setup.
  • Support for training prompts to guide AI model interactions.

Installation

Install react-ai-chatbot with npm

npm install react-gemini-ai-chatbot

Install react-ai-chatbot with yarn

yarn add react-gemini-ai-chatbot

Basic usage

Step 1: Generate API Key

Before using the React AI Chatbot component, you need to generate an API key from the(Google AI Studio). This API key will be used to authenticate requests to the Gemini AI model.

Step 2: Import ReactAiChatBot

To use the React AI Chatbot component, simply import it into your React application and pass the required props:

import React from "react";
import { ReactAiChatBot } from "react-gemini-ai-chatbot";

const MyChatbot = () => {
  const geminiApiKey = "YOUR_GEMINI_API_KEY";
  const trainingData = [{}]

  return (
    <ReactAiChatBot
      geminiApiKey={geminiApiKey}
      trainingData={trainingData}
      // Add other props as needed
    />
  );
};

export default MyChatbot;

Predefined Example

To help you get started quickly, the package includes a predefined example of a fitness club. However, it's essential to customize this data according to your specific requirements before deploying the chatbot in your application.

Props

The following props are available for customization:

PropDescription
geminiApiKeyAPI key for the Gemini AI service.
styleCustom styles to be applied to the chatbot component.
primaryColorPrimary color for the chatbot component.
secondaryColorSecondary color for the chatbot component.
textColorText color for the chatbot component.
backgroundColorBackground color for the chatbot component.
widthWidth of the chatbot component.
heightHeight of the chatbot component.
geminiModelModel name for the Gemini AI service.
chatbotNameName of the chatbot.
chatBotImgImage URL for the chatbot avatar.
chatTitleTitle for the chat interface.
trainingDataTraining data for the chatbot.
trainingPromptPrompt for the chatbot to use during training.
loadingCompLoading component displayed while the chatbot is processing a request.

Training Data

The trainingData prop in the ReactAiChatBot component requires JSON-formatted data containing all the necessary information about your service, company, or any other relevant content. This data is crucial for training the AI model to understand and respond to user queries effectively.

[
  {
    "name": "Services",
    "subcategories": [
      {
        "name": "Overview",
        "details": [
          "Our fitness center name is 'Golds gym'",
          "State-of-the-art gym equipment",
          "Personalized training programs",
          "Group fitness classes",
          "Nutritional counseling"
        ]
      },
      {
        "name": "Prices",
        "details": [
          { "plan": "Basic Membership", "price": "$30/month" },
          { "plan": "Premium Membership", "price": "$50/month" },
          { "plan": "Personal Training Session", "price": "$50/hour" },
          { "plan": "Group Fitness Class", "price": "$10/class" }
        ]
      }
      // Add more subcategories as needed
    ]
  },
  {
    "name": "Location",
    "subcategories": [
      {
        "name": "Address",
        "details": "123 Fitness Street, City, Country"
      },
      {
        "name": "Map",
        "details": "https://maps.app.goo.gl/WcpDGC6NRXohbC6r7"
      }
    ]
  }
  // Add more categories as needed
]