The ultimate AI Chat Bot
component for Next.js
Next AI Bot is the simplest way to integrate
AI into your Next.js application - completely free.
Vercel AI SDK
For Next.js
Open Source
Free to Edit
Get started
It's very simple to use Next AI Bot in your application.
Just follow these steps:
Download
First, you'll need to download the source code from GitHub:
Copy and paste
Next, copy the ai-bot folder into the ./src/app
folder of your Next.js application.
Run the script
In this step, you only need to run the following script from the root of your application:
sh ./src/app/ai-bot/install.shConfigure Environment Variables
Edit your .env file and set these variables bellow:
OPENAI_API_KEY
Generate this key by clicking clicking here. Next AI Bot Next AI Bot is configured by default to use the OpenAI API. If you want to use another provider, you can check the Vercel AI Docs.
OPENAI_API_KEY=YOUR_KEYCRYPTO_JS_KEY
This is a random key that is used to encrypt Next AI Bot's localStorage data. You can input any value.
CRYPTO_JS_KEY=RANDOM_KEYDon't know which value to set here? Click the button below, and we'll generate a random key for you.
Generate random key
Config and Docs
You are free to edit everything as you like. All components are built with Tailwind CSS, so you can open the "ai-bot" folder (./src/app/ai-bot) and modify any component.
However, if you don't want to spend time editing individual files, you can simply edit the Next AI Bot configuration file located at: ./src/app/ai-bot/config.ts. Here, you can easily customize colors, sizes, and text.
AI Bot Config Documentation
Methods
setQuestion
Use this to send any question to the Next AI Bot.
See the example below:
1import { setQuestion } from '@next-ai-bot'
2
3<button onClick={() => setQuestion('What is AI?')} />
setStatus
Change the status of the Next AI Bot modal. It accepts the following values: opened | closed.
See the example bellow:
1import { setStatus } from '@next-ai-bot'
2
3<button onClick={() => setStatus('opened')} />
updateLimit
This function is used for internal control. It is called to update the question limit when the Next AI Bot provides an answer to the user.
1import { updateLimit } from '@next-ai-bot'
2
3<button onClick={() => updateLimit()} />
currentLimit
Returns the current question limit.
1import { currentLimit } from '@next-ai-bot'
2
3<span>{currentLimit}</span> //return a number
data
When a user sends a message to the Next AI Bot, it returns an object containing the question and the modal status.
1import { data } from '@next-ai-bot'
2
3<span>{data.question}</span>
4<span>{data.status}</span> //return 'opened' | 'closed'
Usage
By default, running the install script will wrap your entire application with a context that provides a floating button to call the Next AI Bot. However, if you want to use the Next AI Botanywhere in your application, you can import just the chat bot component. See the example below:
1import AIBot from '@next-ai-bot/components/chat'
2
3<AiBot />
Why not a package?
No! Next AI Bot is not available on npm, bun, or any other package manager!
You might be wondering why. Let me explain.
How many times have you installed a library or component through a package manager, only to find that you needed to modify something later?
If this has happened to you, you're aware of the challenges and potential issues. When I started developing Next AI Bot, the goal was to give users the flexibility to edit anything they want while still providing an easy-to-install and use solution. That’s why it’s not available on any package manager.
Support this project
Did you like Next AI Bot?
I've worked hard on this project and you can help me with any value.
PIX
If you are brazilian, you can give me PIX.