We use cookies

Your privacy is important to us. By clicking "Necessary cookies only", you agree that we can use essential cookies to ensure you get the best experience on our website in accordance with our Cookie Policy.

🔥 40% OFF LIFETIME while offer lasts • All Future Pro Components + 500 Domain Searches • Code: LAUNCH40CLAIM

chatbot

Crafted with ancient wisdom. Powered by modern magic. By druid/ui.

chatbot

chatbot

AI Agent answers instantly

Ask for the team if needed

👋 Hey there! I'm an AI Chatbot. Feel free to ask me anything!
5:51 AM
Bot · .

The Chatbot component provides an interactive chat interface for users to communicate with an AI or automated system.

Installation

Copy and paste the following code into your project.

Pre-requisites & dependencies

1. Install the required dependencies:

npx shadcn@latest init

You can also find installation instructions for shadcn/ui at shadcn.com.

Setup

1. Install dependencies:

npm install @ai-sdk/anthropic ai

2. Add your API key to your environment variables (.env or on your hosting platform):

ANTHROPIC_API_KEY=your_api_key_here

3. Configure app/api/chat/route.ts as needed. By default, it uses Claude 3.5 Haiku with a simple chatbot prompt.

Examples

Basic Usage

Import and add the Chatbot component anywhere in your app. It includes a floating button that opens the chat interface.

import { Chatbot } from "@/components/ui/chatbot"

export default function ChatExample() {
  return (
    <Chatbot />
  )
}

Props

PropTypeDefaultDescription
fixedbooleantrueWhether to fix the chatbot to the viewport
openbooleanfalseInitial open state of the chatbot
initialMessagestring"👋 Hey there!..."First message shown in the chat
titlestring"AI Chatbot"Title displayed in the chat header
descriptionstring"By druid/ui"Subtitle shown below the title
descriptionIconLucideIconSparklesIcon shown next to description
botIconLucideIcon | stringBotIcon or image URL for bot avatar
chatIconLucideIcon | stringMessageSquareIcon for chat toggle button
placeholderTextstring"Ask a question..."Placeholder text for input field
position"bottom-right" | "bottom-left" | "top-right" | "top-left""bottom-right"Position of the chat button when fixed
widthstring"400px"Width of the chat window
heightstring"704px"Height of the chat window
mobileFullScreenbooleantrueWhether to show fullscreen on mobile devices
showTimestampbooleantrueShow message timestamps
showAvatarbooleantrueShow bot avatar in messages
buttonRoundedCornersstring"rounded-full"Border radius for the toggle button
animatedbooleantrueEnable animations
customStylesReact.CSSPropertiesCustom CSS styles for container
modelstring-AI model to use for chat
systemPromptstring-System prompt for AI context
onSendMessage(message: string) => void-Callback when user sends a message
onReceiveMessage(message: string) => void-Callback when bot responds
onOpenChange(open: boolean) => void-Callback when chat open state changes