Plugins
Extend OpenAgent with custom channels, model providers, and tools.
Plugins
OpenAgent's plugin system lets you extend the platform without modifying core code. Plugins can add new model providers, messaging channels, document parsers, embedding models, and agent tools.
Plugin Types
| Type | What it adds |
|---|---|
| Model Provider | A new LLM or embedding model provider |
| Channel | A new messaging platform integration |
| Document Parser | Support for a new file format |
| Tool | A new built-in tool available to agents |
| Storage | A new file storage backend |
| Embedding | A new embedding model provider |
Installing Plugins
Plugins are Go packages that register themselves with OpenAgent at startup. Installing a plugin requires rebuilding the application.
- Add the plugin package to
go.mod:
go get github.com/example/openagent-plugin-myprovider- Import the plugin in
main.goto trigger itsinit()registration:
import _ "github.com/example/openagent-plugin-myprovider"- Rebuild and restart:
go build -o openagent && ./openagent- Create a custom
Dockerfilethat extends the base image:
FROM openagent/openagent:latest AS base
# Add your plugin
COPY plugin-myprovider.so /app/plugins/
# Or build from source with the plugin included
FROM golang:1.21 AS builder
WORKDIR /app
COPY . .
RUN go get github.com/example/openagent-plugin-myprovider
RUN go build -o openagent main.go- Rebuild your custom image and restart.
Building a Plugin
Plugins implement one of OpenAgent's provider interfaces. Here's an example model provider plugin:
Model Provider Plugin
package myprovider
import (
"github.com/the-open-agent/openagent/model"
)
func init() {
model.RegisterProvider("my-provider", &MyProvider{})
}
type MyProvider struct{}
func (p *MyProvider) GetCompletion(ctx context.Context, req *model.CompletionRequest) (*model.CompletionResponse, error) {
// Call your model API here
resp, err := callMyAPI(req.Messages, req.Model, req.Temperature)
if err != nil {
return nil, err
}
return &model.CompletionResponse{
Content: resp.Text,
Usage: model.Usage{InputTokens: resp.InTokens, OutputTokens: resp.OutTokens},
}, nil
}
func (p *MyProvider) ListModels() []string {
return []string{"my-model-v1", "my-model-v2"}
}Channel Plugin
package mychannel
import (
"github.com/the-open-agent/openagent/channels"
)
func init() {
channels.Register("my-channel", &MyChannel{})
}
type MyChannel struct {
token string
}
func (c *MyChannel) Configure(config map[string]string) error {
c.token = config["token"]
return nil
}
func (c *MyChannel) SendMessage(ctx context.Context, chatID string, msg *channels.Message) error {
return sendToMyPlatform(c.token, chatID, msg.Text)
}
func (c *MyChannel) StartReceiving(ctx context.Context, handler channels.MessageHandler) error {
// Set up webhook or polling to receive messages
return listenForWebhooks(ctx, c.token, handler)
}Plugin Configuration
After installing and registering a plugin, configure it in the dashboard under Settings → Providers (for model providers) or Channels → Add Channel (for channel plugins). The plugin's registered name appears in the provider/channel type dropdown.
Official Plugin Ideas
The following are good candidates for community plugins:
Notion Integration
Sync Notion pages to a knowledge base automatically.
Google Drive
Index Google Docs and Sheets from Drive.
Voice Channel
Phone call support via Twilio or similar providers.
CRM Integration
Sync customer data from Salesforce or HubSpot.
Plugin SDK Reference
Interfaces to implement
| Interface | Package | Description |
|---|---|---|
ModelProvider | model | LLM completion |
EmbeddingProvider | embedding | Text embeddings |
Channel | channels | Messaging integration |
DocumentParser | txt | File format parser |
StorageProvider | storage | File storage backend |
Registration functions
| Function | Description |
|---|---|
model.RegisterProvider(name, provider) | Register an LLM provider |
embedding.RegisterProvider(name, provider) | Register an embedding provider |
channels.Register(name, channel) | Register a channel |
txt.RegisterParser(ext, parser) | Register a document parser |
storage.RegisterProvider(name, provider) | Register a storage backend |
All registration functions are idempotent and safe to call from init(). They panic if a name is registered twice, so use unique plugin names.