Skip to main content

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
Interfaces act as the “glue” between plugins (consumers) and integrations (providers).

Interface Architecture

Creating an Interface

From packages/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 the extend() method. From packages/sdk/src/integration/definition/index.ts:246:

Entity Mapping

The entities 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. From packages/sdk/src/plugin/definition.ts:162:
Implementation:

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. From packages/sdk/src/bot/definition.ts:506:
This replaces z.ref() with actual schemas from backing integrations.

Built-in Interfaces

Botpress provides several standard interfaces:
Standard interface for Large Language Models (OpenAI, Anthropic, Cerebras, etc.)Entities: modelRef, message
Actions: generateContent, listLanguageModels
Location: @botpress/interface-llm
Standard interface for read operations on resourcesActions: read, list
Location: interfaces/readable/
Standard interface for creating resourcesActions: create
Location: interfaces/creatable/
Standard interface for updating resourcesActions: update
Location: interfaces/updatable/
Standard interface for deleting resourcesActions: delete
Location: interfaces/deletable/
Human-in-the-loop interface for agent handoffActions: createTicket, assignAgent, closeTicket
Location: 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
Plugins should specify compatible interface versions. Breaking changes require updating both interface and implementations.

Advanced: Generic Schemas

Interfaces use generic schemas with entity references:
From 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