Plugins
Getting Started

Plugin Getting Started

Build your first Agentbase plugin in 5 minutes.

Prerequisites

  • Node.js 20+
  • pnpm 9+
  • An Agentbase instance running locally

Create a New Plugin

mkdir my-first-plugin
cd my-first-plugin
npm init -y
npm install @agentbase/plugin-sdk

Write the Plugin

Create src/index.ts:

import { createPlugin } from "@agentbase/plugin-sdk";
 
export default createPlugin({
  name: "my-first-plugin",
  version: "1.0.0",
  description: "My first Agentbase plugin",
  author: "Your Name",
 
  // Hook into platform events
  hooks: {
    "app:init": async (context) => {
      context.api.log("My plugin is running!");
    },
    "conversation:start": async (context, conversationId) => {
      context.api.log(`New conversation started: ${conversationId}`);
    },
  },
 
  // Transform data with filters
  filters: {
    "prompt:modify": async (context, prompt) => {
      // Add a prefix to all prompts
      return `[Enhanced] ${prompt}`;
    },
  },
 
  // Plugin settings UI
  settings: {
    greeting: {
      type: "string",
      label: "Custom Greeting",
      default: "Hello from my plugin!",
    },
    enabled: {
      type: "boolean",
      label: "Enable enhanced responses",
      default: true,
    },
  },
 
  onActivate: async (context) => {
    context.api.log("Plugin activated!");
  },
 
  onDeactivate: async (context) => {
    context.api.log("Plugin deactivated!");
  },
});

Available Hooks

Actions (fire-and-forget)

HookDescriptionArguments
app:initApplication initialized
app:requestIncoming API requestrequest object
conversation:startNew conversation createdconversationId
conversation:endConversation completedconversationId
plugin:activatePlugin activatedpluginId
plugin:deactivatePlugin deactivatedpluginId
user:loginUser logged inuserId
user:registerNew user registereduserId

Filters (transform values)

FilterDescriptionValue
prompt:modifyModify the prompt before sendingprompt string
response:modifyModify the AI responseresponse string
message:beforeSendBefore message is sent to AImessage object
message:afterReceiveAfter receiving AI responsemessage object
config:modifyModify application configconfig object
theme:modifyModify theme settingstheme object

Test Your Plugin

Install the plugin through the Agentbase dashboard:

  1. Go to Dashboard → My Plugins
  2. Click Upload Plugin
  3. Select your built plugin bundle
  4. Activate it on an application

Next Steps