A modern, customizable AI chatbot built with Next.js, Vercel AI SDK, and Google Gemini. Features include rate limiting, bot protection, and a beautiful UI.
- 🚀 Quick Start
- ⚙️ Customization
- 🎨 UI Customization
- 🔧 Technical Details
- 🚀 Deployment
- 🛠️ Troubleshooting
- 📝 License
git clone https://github.com/rryyqn/ai-chatbot.git
cd ai-chatbot-template
pnpm installCreate a .env.local and add your API keys:
ARCJET_KEY=
GOOGLE_GENERATIVE_AI_API_KEY=
NEXT_PUBLIC_APP_URL=localhostARCJET_KEY- Get from Arcjet DashboardGOOGLE_GENERATIVE_AI_API_KEY- Get from Google AI StudioNEXT_PUBLIC_APP_URL- Uselocalhostfor local development, use deployed url in production (eg.https://ai-chatbot.vercel.app)
pnpm devVisit http://localhost:3000 to see your chatbot!
Edit lib/config.ts to customize your chatbot.
name - Chatbot name
welcomeMessage - Initial message in the chat (supports choice and link syntax)
ui.windowTitle - Chat window title text
ui.inputPlaceholder - Placeholder text for message input
ui.avatarImage - AI's avatar image (place in public folder)
ui.avatarFallback - Fallback avatar image placeholder
rateLimit.capacity - Maximum requests allowed in a burst
rateLimit.refillRate - How many tokens are added per interval
rateLimit.interval - How often tokens are refilled (in seconds)
api.model - AI model from Gemini
api.systemPrompt - system instruction for AI response (supports choice and link syntax)
enableBotDetection - Block automated bots
enableShield - Protect against common attacks
allowedBots - Specify which bot categories to allow
The choice and link syntax renders the interactive buttons at the bottom of AI response. These can be used by the AI for conversation flows, creating quick response suggestions and links to relevant resources.
Use this in your system prompt:
When appropriate, you can these formats to allow users to continue the chat or click a link. Put it at the bottom of the response with no punctuation:
- {{choice:Option Name}} - Creates clickable choice buttons
- {{link:https://url.com|Button Text}} - Creates clickable link buttons
The chatbot uses Tailwind CSS. Key styling files:
app/globals.css- Global styles and themecomponents/ui/- Reusable UI componentscomponents/Chatbot.tsx- Direct chatbot styles
- Frontend: Next.js 15 with React 19
- AI: Vercel AI SDK with Google Gemini
- Security: Arcjet for rate limiting and bot protection
- Styling: Tailwind CSS with custom design system
- Animations: Framer Motion
- ✅ Real-time streaming responses
- ✅ Rate limiting and bot protection
- ✅ Mobile-responsive design
- ✅ Customizable UI and behavior
- ✅ TypeScript support
- ✅ Error handling and retry logic
├── app/
│ ├── api/chat/route.ts # Chat API endpoint
│ ├── page.tsx # Main page
│ └── globals.css # Global styles
├── components/
│ ├── ai-elements/ # Chat-specific components
│ ├── ui/ # Reusable UI components
│ └── Chatbot.tsx # Main chatbot component
├── lib/
│ ├── config.ts # Configuration file
│ ├── arcjet.ts # Security configuration
│ └── utils.ts # Utility functions
└── public/ # Static assets (AI avatar image)
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy!
The app works on any platform that supports Next.js:
- Netlify
- Railway
- Render
- DigitalOcean App Platform
Q: I’m getting auth errors from Google AI / Arcjet
A: Confirm keys are correct and not expired. Verify the correct environment variables are set in your environment/hosting provider.
Q: I'm getting 403 forbidden errors
A: Set the NEXT_PUBLIC_APP_URL in your .env to your deployed URL, eg. ai-chatbot.vercel.app
MIT License - feel free to use this template for your projects!
Happy coding! 🎉