1.0.4 • Published 5 months ago
@agient/chatbot v1.0.4
Create AI chatbot assistants with minimal setup. Implement tools that will allow your chatbots to perform actions and fetch data from your website.
📦 Installation
using npm
npm i @agient/chatbot
using yarn
yarn add @agient/chatbot
using pnpm
pnpm add @agient/chatbot
using bun
bun i @agient/chatbot
🚀 Quick Start
Heading to agient.dev and create your own chatbot project. Once you've created your project, you'll receive an API key that you'll need to initialize the chatbot in your application.
import { createAgient } from '@agient/chatbot';
// Initialize the chatbot with your API key
const agient = createAgient('your-api-key');
agient.on('getWeather', async args => {
return 'The weather is currently sunny and 75°F';
});
⚙️ Configuration Options
The createAgient
function accepts the following options:
interface AgientOptions {
/**
* Whether to automatically start the chat widget when initialized.
* If false, the widget will need to be manually started.
* @default true
*/
autoStart?: boolean;
}
🔨 Tool Handling
The chatbot supports custom tools that can be implemented to perform specific actions. Tools must first be registered inside your chatbot at https://agient.dev. Then you can implement them by their names. Here's how to implement a tool:
import { createAgient } from '@agient/chatbot';
const agient = createAgient('your-api-key');
agient.on('incrementCounter', async ({ by }) => {
const newCount = await incrementCounter(by);
return `The counter is now ${newCount}`;
});