Python module for sending 7 types of messages via Feishu (Lark) Bot API
π Language / θ―θ¨οΌπ¨π³ δΈζ | π¬π§ English
A Python module for sending multi-type messages to Feishu (Lark) via the Open API Bot identity β not a webhook. Supports text, image, file, audio, video, rich text (post), and interactive card messages with automatic token management.
You've built a Python script that needs to send messages to Feishu β but the webhook isn't enough.
- You want to send images, files, audio, video β Feishu webhooks only support text and simple cards
- Your token expires every 2 hours β without automatic refresh, your bot goes silent until you manually re-authenticate
- You need interactive cards β the raw Feishu Open API is verbose and error-prone to call directly
- You have multiple automation scripts β each one ends up duplicating the same Feishu integration code
Feishu Bot Pusher wraps all of this into a single from feishu_bot import FeiShuBot. One import, 7 message types, automatic token management. Your scripts stay clean, your team stays notified.
flowchart LR
subgraph YourCode["π§© Your Application"]
APP[Your Script]
end
subgraph Module["π¦ feishu_bot.py"]
FB[FeiShuBot Class]
TM[Token Manager<br/>auto-refresh]
FU[File Uploader<br/>auto-upload]
end
subgraph Feishu["βοΈ Feishu OpenAPI"]
API[Open API Gateway]
end
APP --> FB
FB --> TM
FB --> FU
FB --> API
style APP fill:#6366f1,color:#fff,stroke:none
style FB fill:#0ea5e9,color:#fff,stroke:none
style TM fill:#0ea5e9,color:#fff,stroke:none
style FU fill:#0ea5e9,color:#fff,stroke:none
style API fill:#f59e0b,color:#fff,stroke:none
| # | Feature | Description |
|---|---|---|
| 1 | 7 Message Types | Text, image, file, audio, video, rich text, interactive card |
| 2 | Bot Identity | Sends as a Feishu Bot (not a webhook) |
| 3 | Auto Token Mgmt | Caches tenant_access_token with auto-refresh |
| 4 | Media Auto-Upload | Uploads images/files before sending |
| 5 | Flexible Config | Env vars, config file, or constructor args |
| Requirement | Version |
|---|---|
| Python | 3.7+ |
| requests | Any recent version |
| Feishu App | Self-built app with Bot capability enabled |
pip install requestsfrom feishu_bot import FeiShuBot
bot = FeiShuBot()
# Send text
bot.send_text("Hello from Feishu Bot")
# Send image
bot.send_image("screenshot.png")
# Send rich text
bot.send_post("Notice", [
{"tag": "md", "text": "**Update**: v2.0 released"},
{"tag": "a", "text": "Details", "href": "https://example.com"},
])feishu-bot-pusher/
βββ feishu_bot.py # Core module β FeiShuBot class
βββ feishu_config.json # Config file (optional)
βββ .env.example # Environment variable template
βββ requirements.txt # requests
βββ LICENSE # MIT
βββ README.md / README.zh.md
Can I send messages to a group chat instead of an individual user? Yes. Feishu Bot supports both private chat and group chat. Set the receive_id_type to chat_id to send to a group.
Does this support Feishu interactive cards with buttons?
Yes. send_card() supports color headers, buttons, markdown content, and dividers. You pass a standard Feishu card JSON structure.
How does token auto-refresh work? The FeiShuBot caches tenant_access_token in memory and automatically requests a new one before it expires β so you never get 99991663 auth errors.
Can I use this with multiple Feishu apps? Yes. Create multiple FeiShuBot instances with different app_id/app_secret pairs. Each manages its own token lifecycle independently.
MIT Β© 2026 Ryan Dong
Ryan Dong β AI Product Manager & Full-Stack Developer
I bridge the gap between AI capabilities and production-ready software. My work spans the full stack: from designing AI-powered product features and integrating LLM APIs, to building modular backend services and shipping clean, documented code.
| Role | Focus |
|---|---|
| π§ AI Product Manager | Product strategy, AI feature design, prompt engineering, model selection |
| π» Full-Stack Developer | Python, FastAPI, Google Apps Script, automation pipelines, API integration |
This repository is part of a personal toolbox β a growing collection of practical, reusable modules that solve real automation problems. Each project is designed to be independently useful and easily integrated into larger systems.
π¬ donglinfei@gmail.com β open to business discussions, collaborations, and recruiting inquiries.
Ryan Dong β donglinfei@gmail.com