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
Frompackages/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:Using Integration Dependencies
Plugins can also depend directly on specific integrations:Installing Plugins in Bots
Frompackages/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: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:Plugin Hooks
Plugins can register hooks to intercept and modify data:Dereferencing Entities
When using interface entities, you may need to dereference them. Frompackages/sdk/src/plugin/definition.ts:352:
z.ref() entities to their actual schemas.
Tables in Plugins
Plugins can define custom tables:Recurring Events
Plugins can emit scheduled events:Workflows (Experimental)
Plugins can define workflows:Plugin Merging
Frompackages/sdk/src/bot/definition.ts:370, when plugins are added to bots:
- Plugin states, events, and actions are prefixed with the plugin alias
- User/conversation/message tags are merged (no prefixing)
- 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