Skip to main content

What are Plugins?

Plugins are reusable packages that extend bot functionality without being tied to a specific platform. They work across any bot and can integrate with multiple platforms through interfaces. Plugins provide:
  • Actions: Reusable operations (analytics tracking, logging)
  • States: Data schemas (analytics data, configuration)
  • Events: Custom events (metrics recorded, thresholds exceeded)
  • Event Handlers: React to bot events
  • Message Handlers: Process messages
  • Tables: Custom data storage

Plugin Architecture

Creating a Plugin

Plugin Definition

From packages/sdk/src/plugin/definition.ts:162, plugins are defined using PluginDefinition:

Plugin Implementation

Implement the plugin’s runtime behavior:

Using Interface Dependencies

Plugins can depend on interfaces to work with any compatible integration:
Implementation using the interface:

Using Integration Dependencies

Plugins can also depend directly on specific integrations:

Installing Plugins in Bots

From packages/sdk/src/bot/definition.ts:281, add plugins to bots:
Plugin actions and states are automatically prefixed with the plugin alias. For example, analytics:trackEvent and analytics:userMetrics.

Plugin State Scoping

Plugin states are namespaced to avoid conflicts:
From packages/sdk/src/consts.ts, the separator between plugin alias and name is :.

Plugin Actions

Call plugin actions from bot handlers:

Plugin Event Handlers

Plugins can register event handlers that run automatically:
These handlers run in addition to the bot’s own handlers.

Plugin Hooks

Plugins can register hooks to intercept and modify data:

Dereferencing Entities

When using interface entities, you may need to dereference them. From packages/sdk/src/plugin/definition.ts:352:
This resolves z.ref() entities to their actual schemas.

Tables in Plugins

Plugins can define custom tables:
Use tables in actions:

Recurring Events

Plugins can emit scheduled events:

Workflows (Experimental)

Plugins can define workflows:

Plugin Merging

From packages/sdk/src/bot/definition.ts:370, when plugins are added to bots:
  1. Plugin states, events, and actions are prefixed with the plugin alias
  2. User/conversation/message tags are merged (no prefixing)
  3. Tables and workflows are merged directly

Publishing Plugins

1

Develop

Create your plugin:
2

Build

Build the plugin implementation:
3

Deploy Private

Deploy to your workspace:
4

Test

Install in test bots and verify functionality
5

Deploy Public

Publish to the Botpress Hub:

Best Practices

Use Interfaces

Depend on interfaces instead of specific integrations for maximum reusability.

Namespace Properly

Plugin states and actions are automatically prefixed. Design accordingly.

Document Dependencies

Clearly document which interfaces or integrations your plugin requires.

Handle Errors

Gracefully handle cases where dependencies aren’t available or properly configured.

Examples

Simple Analytics Plugin

Plugin with Interface Dependency

Next Steps

Interfaces

Learn how to use interfaces in plugins

Bots

Install plugins in your bots

Examples

Browse plugin examples

SDK Reference

Explore the complete plugin API