What are Interfaces?
Interfaces are abstract contracts that define standard behaviors and data structures. They enable:- Interoperability: Plugins work with any integration implementing an interface
- Standardization: Common operations have consistent APIs
- Swappability: Switch between providers without changing plugin code
- Type Safety: Strongly typed contracts enforced at compile and runtime
Interface Architecture
Creating an Interface
Frompackages/sdk/src/interface/definition.ts:82, interfaces are defined using InterfaceDefinition:
Interface Components
Entities
Entities define shared data models that integrations must provide:Entities are referenced using callbacks in actions, events, and channels. This enables type-safe generic schemas.
Actions
Actions define operations that integrations must implement:Events
Events define notifications that integrations can emit:Channels
Channels define communication pathways:Implementing Interfaces in Integrations
Integrations implement interfaces using theextend() method. From packages/sdk/src/integration/definition/index.ts:246:
Entity Mapping
Theentities store provides access to integration entities:
The integration’s entity schema must be compatible with (extend) the interface’s entity schema. Additional properties are allowed.
Using Interfaces in Plugins
Plugins declare interface dependencies. Frompackages/sdk/src/plugin/definition.ts:162:
Wiring Interfaces in Bots
When adding plugins to bots, you wire interface dependencies to specific integrations:The same plugin can be added multiple times with different backing integrations, enabling A/B testing and fallbacks.
Entity Dereferencing
When using interface entities, references need to be resolved at runtime. Frompackages/sdk/src/bot/definition.ts:506:
z.ref() with actual schemas from backing integrations.
Built-in Interfaces
Botpress provides several standard interfaces:LLM Interface
LLM Interface
Standard interface for Large Language Models (OpenAI, Anthropic, Cerebras, etc.)Entities:
Actions:
Location:
modelRef, messageActions:
generateContent, listLanguageModelsLocation:
@botpress/interface-llmReadable Interface
Readable Interface
Standard interface for read operations on resourcesActions:
Location:
read, listLocation:
interfaces/readable/Creatable Interface
Creatable Interface
Standard interface for creating resourcesActions:
Location:
createLocation:
interfaces/creatable/Updatable Interface
Updatable Interface
Standard interface for updating resourcesActions:
Location:
updateLocation:
interfaces/updatable/Deletable Interface
Deletable Interface
Standard interface for deleting resourcesActions:
Location:
deleteLocation:
interfaces/deletable/HITL Interface
HITL Interface
Human-in-the-loop interface for agent handoffActions:
Location:
createTicket, assignAgent, closeTicketLocation:
interfaces/hitl/Interface Versioning
Interfaces use semantic versioning:- Major: Breaking changes to entities, actions, or events
- Minor: New optional entities, actions, or events
- Patch: Bug fixes, documentation updates
Advanced: Generic Schemas
Interfaces use generic schemas with entity references:packages/sdk/src/interface/definition.ts:119, these callbacks receive entity references at definition time.
Best Practices
Minimal APIs
Keep interfaces focused. Define only essential actions and entities for the use case.
Backward Compatibility
Use minor versions for additions. Major versions for breaking changes.
Rich Metadata
Provide clear titles, descriptions, and attributes for all interface components.
Flexible Entities
Design entities to accommodate different provider implementations. Use optional fields.
Example: Storage Interface
Complete example of a storage interface:Next Steps
Integrations
Learn how to implement interfaces in integrations
Plugins
Use interfaces to build cross-platform plugins
Examples
Browse interface examples
Architecture
Understand how interfaces fit into the platform