# Channel plugin protocol (v1) A channel plugin connects openbee to a chat platform that is not built in. It runs as a child process of openbee and talks to it over stdin/stdout. Plugins can be written in any language. ## Package layout A plugin is a directory with an `openbee.plugin.json` manifest at its root: ```json { "protocol_version": 1, "id": "discord", "name": { "en": "Discord", "zh": "Discord" }, "description": { "en": "Discord bot channel" }, "command": ["node", "dist/index.js"], "version": "0.1.0", "icon": "icon.svg", "config": [ { "key": "token", "type": "secret", "required": true, "label": { "en": "Bot token", "zh": "机器人 Token" } }, { "key": "allowed_guilds", "type": "list" }, { "key": "max_media_size", "type": "int", "default": 10485760 } ] } ``` | Field | Rules | |---|---| | `protocol_version` | Must be `1`. Each plugin `type` has its own protocol version. | | `type` | Optional. `channel` (the default, so existing channel manifests need no change) or `engine`. An `engine` plugin follows the [engine plugin protocol](engine-plugin-protocol.md) instead of this one. Channel and engine plugins share one id space. | | `id` | Channel id and session key prefix. Matches `^[a-z][a-z0-9_-]{1,31}$`. Cannot be `local`. | | `name`, `description` | A string or an object keyed by language (`en`, `zh`). Lookups fall back to `en`. | | `command` | Program and arguments, run with the plugin directory as working directory. `node` runs on the JavaScript runtime openbee picks (see [Runtime](#runtime)). Otherwise an absolute path is used as-is; a path starting with `.` or containing a separator is relative to the plugin directory; anything else is looked up on `PATH`. | | `setup` | Optional. `{"command": [...], "label": ...}`: an interactive step `openbee plugin configure` runs before asking for `config[]`, for platforms that log in with a QR code or a browser instead of a pasted token. `command` follows the same rules as the top-level `command`; `label` names the step in prompts. See [Setup](#setup). | | `version` | Optional. `package.json` `version` wins when present. | | `icon` | Optional. Path of an SVG file inside the plugin, shown wherever plugins are listed; without it openbee shows the initials of `name`. See [Icon](#icon). | | `config[]` | Settings openbee stores for the plugin and validates before starting it. `type` is `string`, `secret`, `bool`, `int` or `list` (list of strings). `required`, `default`, `label` and `help` are optional. `random_default: true` (only for `string`) makes openbee fill in a random value when the field has no value yet, which suits access codes. `enabled` and `bot_name` are reserved keys and cannot be declared. | One plugin provides exactly one channel. ### Icon openbee paints the icon in the colour of the text around it, so draw it in one colour with `currentColor`; only its shape and opacity are kept. A manifest whose icon breaks these rules is rejected: | Rule | | |---|---| | Location | A relative path inside the plugin directory, ending in `.svg`; not a symlink. Include the file in the npm package. | | Size | At most 32 KB. | | Root | One `` element. A square `viewBox` fits best. | | Not allowed | `