plugin/scripts/ and use the built-in middleware.js or middleware.py.
This page is for plugin authors. Write scripts and manifest headers. Do not bypass the SDK to call autClaw services directly.
What you can build
Reply to messages
Read user messages, match rule captures, and reply with text, Markdown, or media.
Send media
Send images, voice, video, files, and mixed messages.
Save state
Use default storage or named buckets to save user progress, configuration, and cache data.
Expose routes
Declare
router and method to turn a plugin into an HTTP handler.Choose a language
| Language | Best for | Typical entry |
|---|---|---|
| JavaScript | npm ecosystem, async I/O, and frontend or Node.js experience | middleware.js |
| Python | Data processing, script automation, and AI calls | middleware.py |
- JavaScript
- Python
Use JavaScript when you want npm packages, async I/O, or Node.js experience.
Create a plugin
Create a script
Create a file under
plugin/scripts/, such as plugin/scripts/echo.js or plugin/scripts/echo.py.Write manifest headers
Declare
author, runtime, title, and the trigger. Message plugins usually use rule.Import middleware
Use
require('./middleware.js') in JavaScript or from middleware import ... in Python.Common docs
Manifest headers
Declare the plugin name, author, trigger rules, parameters, dependencies, routes, and scheduled tasks.
JavaScript middleware
Learn JavaScript usage for
Sender, storage, files, routes, input waiting, and cron.Python middleware
Learn Python usage for
Sender, storage, files, routes, input waiting, and cron.Media sending
Send images, voice, video, and files, or handle user-uploaded files.
Plugin files and declarations
| Location | Description |
|---|---|
plugin/scripts/*.js | Regular JavaScript plugins. |
plugin/scripts/*.py | Regular Python plugins. |
plugin/replies/*.js | Legacy reply scripts. Keep using them only when maintaining existing plugins. |
author is required. rule matches messages. See Plugin manifest headers for more fields.
Recommended patterns
- Use
Senderto read context and reply to messages. - Use
replyImage,replyVoice,replyVideo,replyFile, orreplyMixedfor media. - Use
sender.getMediaItems()+downloadAdapterFile(...)for user-uploaded files. - Put configuration fields in
param; put runtime state inbucketSet(...). Bucket names can use.for child levels; prefer at most 3 levels. - Prefer declaring dependencies with
dependency; useimportModule(...)orimport_module(...)for temporary dependencies.
Avoid these patterns
- Do not hard-code runtime credentials, ports, or service addresses.
- Do not bypass the SDK to call autClaw services directly.
- Do not manually parse platform-specific raw file fields. Use SDK download helpers.
- Do not put large datasets into one bucket key. Split data across keys for easier maintenance.