Skip to main content
plugin/scripts/middleware.py is the SDK for regular Python plugins. Use it to create Sender, read the current context, reply to messages, store data, wait for input, handle payments, download user-uploaded files, handle HTTP routes, push proactively, and manage runtime scheduled tasks.
New plugins should prefer from middleware import Sender, getSenderID. Do not hard-code credentials, ports, or autClaw internal service addresses.

Quick start

Python SDK methods are synchronous. Failures raise Exception; catch exceptions in flows that send network requests, media, or files, and reply with an actionable message.

Browse by task

Context and base types

Import style, senderID, response wrappers, SendReceipt, MediaItem, and download return bodies.

Sender message capabilities

Read users and chats, match parameters, reply with text/media, recall, and use replyMixed(...).

Wait for input and payment

listen(...), input(...), waitPay(exitcode, timeout, amount=None), and amount-matching details.

Events, media, and files

getMediaItems(), fileDownload(...), downloadAdapterFile(...), and getGroupMemberList(...).

Storage and routes

Default storage, named buckets, and HTTP router request and response aliases.

Proactive push

Targets, account selection, and return values for push(...) / pushImage(...) / pushMixed(...).

Tools, Cron, and group management

import_module(...), system utilities, Cron, group invite/mute/announcement.

Python signatures

Navigation-indexed .pyi-style signatures for IDEs and AI retrieval through MCP.

Common imports

Common rules:
  • Use Sender to handle the current message, route request, or event.
  • Use top-level functions for global operations, such as bucketGet(...), pushImage(...), and fileDownload(...).
  • Business timeout parameters for listen(...), input(...), and waitPay(...) use milliseconds.
  • Serialize objects with json.dumps(...) before saving them with set(...) / bucketSet(...).

Actual differences from JavaScript middleware

This table is checked against the current plugin/scripts/middleware.py and plugin/scripts/middleware.js:
All Python child pages are included in docs.json navigation. Mintlify indexes navigation pages for MCP search by default, so AI tools can retrieve these split reference pages.

Python plugin context and base types

Import middleware.py, create Sender, and understand common return values in Python plugins.

Python Sender message capabilities

Use Python Sender to read user and chat information, reply with text, Markdown, media, and mixed messages, and recall messages.

Python wait for input and payment

Use listen, input, and waitPay in Python plugins to wait for user input, capture media, and handle payment amount matching.

Python events, media, and files

Read event data, get media items, download user-uploaded files, and get group member lists in Python plugins.

Python plugin storage and routes

Use default storage, named buckets, and HTTP router request and response helpers in Python plugins.

Python plugin proactive push

Use Python push, pushImage, and pushMixed to proactively send text, media, and mixed messages, and choose the sending account.

Python tools, Cron, and groups

Use import_module, system utilities, Cron scheduled tasks, and group management methods in Python plugins.

Python middleware.py signatures

Use .pyi-style signatures to quickly retrieve public middleware.py functions, Sender methods, and Cron methods.
Last modified on June 3, 2026