xiaohongshu
xiaohongshu
lark-bot-integration
Deploy and manage Lark (Feishu) bot for Milady meme generation, command handling, and team collaboration. Use when setting up Lark webhooks, handling bot commands, deploying to production, or integrating with Lark messaging.
Full skill instructions
Complete Lark (Feishu/飞书) bot system for interactive Milady meme generation and team collaboration.
Deploy a fully-featured Lark bot that:
# Set environment variables
export LARK_APP_ID="cli_xxxxxxxxxxxxx"
export LARK_APP_SECRET="your_app_secret"
# Verify configuration
python scripts/setup_webhook.py --verify
# Start on port 8000
python webhook_server.py
# Or use startup script
./start_lark_bot.sh
# Get your public URL (use ngrok or public server)
python scripts/setup_webhook.py --url https://your-domain.com/webhook
# Get group chat ID for posting
python scripts/get_chat_id.py
| Command | Description | Example |
|---|---|---|
/milady | Generate Milady meme | /milady 5050 |
/milady [layers] | Add accessories | /milady 5050 Hat:Beret.png |
/milady [text] | Add text overlay | /milady 5050 top:GM bottom:WAGMI |
/memegen | Classic meme templates (207+) | /memegen drake old way new way |
| Command | Description | Cost | Example |
|---|---|---|---|
/milady_illusion | Illusion Diffusion effect | $0.006 | /milady_illusion 5050 |
/milady_replace | FLUX Fill Pro replace | $0.05 | /milady_replace 5050 hat red cap |
/milady_replace_sam | SAM + FLUX replace | $0.05 | /milady_replace_sam 5050 glasses cool shades |
| Command | Description | Cost | Example |
|---|---|---|---|
/tweet gm | Generate GM tweet | ~$0.02 | /tweet gm |
/tweet insight | Generate insight tweet | ~$0.03 | /tweet insight data ownership |
/tweet casual | Generate casual tweet | ~$0.02 | /tweet casual weekend vibes |
/tweet reply | Generate reply tweet | ~$0.02 | /tweet reply Great point! |
| Command | Description | Cost | Example |
|---|---|---|---|
/monitor mentions | Check @mentions | FREE | /monitor mentions |
/monitor account | Monitor user tweets | FREE | /monitor account vitalikbuterin |
/monitor opportunities | Find interaction opportunities | FREE | /monitor opportunities |
/monitor stats | View monitoring stats | FREE | /monitor stats |
| Command | Description | Cost | Example |
|---|---|---|---|
/training check | Check content freshness | FREE | /training check gm builders |
/training stats | View training stats | FREE | /training stats |
/training add | Add training sample | FREE | /training add gm hello world |
/training freshness | Detailed freshness analysis | FREE | /training freshness test content |
| Command | Description | Example |
|---|---|---|
/help | Show all commands | /help |
/balance | Check Replicate credit | /balance |
/milady 5050
Result: NFT #5050 as image
/milady 5050 Hat:Beret.png Glasses:Sunglasses.png
Result: NFT #5050 + beret + sunglasses
/milady 5050 top:"Good Morning" bottom:"Let's Go"
Result: NFT #5050 with text overlay
/milady 5050 give her a cowboy hat and heart sunglasses
Result: Bot parses "cowboy hat" → Hat:Cowboy.png, "heart sunglasses" → Glasses:Heart Shaped.png
/milady_illusion 5050 spiral pattern
Result: NFT #5050 with illusion diffusion effect ($0.006)
/milady_replace_sam 5050 hat blue baseball cap
Result: SAM detects hat, FLUX replaces with blue baseball cap ($0.05)
/milady_template drake
Result: Random Milady in Drake meme template
User sends message in Lark
↓
Lark sends POST to /webhook
↓
webhook_server.py receives event
↓
LarkMemeBot processes command
↓
Calls MemeGenerator/AI Effects
↓
Uploads result to Lark
↓
User sees image in chat
lark-bot-integration/
├── SKILL.md # This file
├── SETUP_GUIDE.md # Detailed setup
├── COMMAND_REFERENCE.md # All commands
├── DEPLOYMENT.md # Production deployment
├── src/
│ ├── lark_meme_bot.py # Main bot logic
│ ├── webhook_handler.py # Webhook processing
│ └── lark_api.py # Lark API wrapper
├── config/
│ └── lark_config.yaml # Bot configuration
└── scripts/
├── setup_webhook.py # Webhook setup tool
├── get_chat_id.py # Get chat IDs
└── approve.py # Approval workflow
Lark Developer Account
Server with Public URL
Required Permissions
See SETUP_GUIDE.md for step-by-step instructions including:
# Start ngrok tunnel
./start_tunnel.sh
# Ngrok will output URL like: https://abc123.ngrok.io
# Use this as webhook URL: https://abc123.ngrok.io/webhook
# Set webhook
python scripts/setup_webhook.py --url https://abc123.ngrok.io/webhook
from src.lark_meme_bot import LarkMemeBot
# Initialize bot
bot = LarkMemeBot(
app_id=os.getenv("LARK_APP_ID"),
app_secret=os.getenv("LARK_APP_SECRET")
)
# Process incoming message
bot.handle_message(
message_id="om_xxxxx",
chat_id="oc_xxxxx",
text="/milady 5050",
user_id="ou_xxxxx"
)
# In src/lark_meme_bot.py
def handle_custom_command(self, text, chat_id):
"""Add your custom command handler"""
if text.startswith("/mycommand"):
# Your logic here
result = do_something()
# Send response
self.send_message(chat_id, "Done!")
# Upload image if needed
if image_path:
self.upload_image(chat_id, image_path)
from flask import Flask, request
from src.lark_meme_bot import LarkMemeBot
app = Flask(__name__)
bot = LarkMemeBot()
@app.route('/webhook', methods=['POST'])
def webhook():
data = request.get_json()
# Handle event
if data.get('type') == 'message':
bot.handle_message(
message_id=data['message']['message_id'],
chat_id=data['message']['chat_id'],
text=data['message']['text']
)
return {'success': True}
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
bot.send_message(chat_id, "Hello from AI Content Studio! 🎀")
bot.send_card(
chat_id=chat_id,
title="Meme Generated!",
content="Your Milady meme is ready",
image_key=image_key
)
# Upload and send image
image_key = bot.upload_image(
chat_id=chat_id,
image_path="/path/to/meme.png"
)
1. Webhook verification failed
# Check URL is publicly accessible
curl https://your-domain.com/webhook
# Verify in Lark console:
# Settings > Event Subscriptions > Verify URL
2. Messages not received
# Check event subscriptions are enabled
# Required events:
# - im.message.receive_v1
# - im.message.mention_v1
3. Image upload fails
# Check image size (max 10MB for Lark)
# Check file format (PNG, JPG supported)
# Verify upload permission is granted
4. Token expired
# Token auto-refreshes every 2 hours
# Manual refresh:
bot.refresh_token()
For production use with Twitter posting:
# Start approval workflow
python scripts/approve.py
# Bot generates content → sends to Lark
# Team reviews in Lark chat
# Approved tweets get posted to Twitter
1. Bot generates tweet/meme
2. Posts to Lark approval channel
3. Team reacts with ✅ (approve) or ❌ (reject)
4. If approved → Posts to Twitter
5. If rejected → Logs feedback for learning
# Create service file
sudo nano /etc/systemd/system/lark-bot.service
# Add:
[Unit]
Description=Lark Meme Bot
After=network.target
[Service]
Type=simple
User=your_user
WorkingDirectory=/path/to/ai-content-studio
Environment="LARK_APP_ID=cli_xxxxx"
Environment="LARK_APP_SECRET=xxxxx"
ExecStart=/usr/bin/python3 webhook_server.py
Restart=always
[Install]
WantedBy=multi-user.target
# Enable and start
sudo systemctl enable lark-bot
sudo systemctl start lark-bot
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["python", "webhook_server.py"]
# Build and run
docker build -t lark-bot .
docker run -d -p 8000:8000 \
-e LARK_APP_ID=cli_xxxxx \
-e LARK_APP_SECRET=xxxxx \
lark-bot
# Start in background
nohup python3 webhook_server.py > webhook.log 2>&1 &
# Check status
ps aux | grep webhook_server
# View logs
tail -f webhook.log
# View logs
tail -f webhook.log
# Check if running
ps aux | grep webhook_server
# Test webhook
curl -X POST https://your-domain.com/webhook \
-H "Content-Type: application/json" \
-d '{"type":"test"}'
Environment Variables
# Never commit credentials
# Use .env file (add to .gitignore)
LARK_APP_ID=cli_xxxxx
LARK_APP_SECRET=xxxxx
Webhook Verification
# Verify requests come from Lark
def verify_webhook(request):
# Check signature
# Validate timestamp
# Reject invalid requests
Rate Limiting
# Prevent abuse
from flask_limiter import Limiter
limiter = Limiter(app, default_limits=["100 per hour"])
Access Control
# Restrict to specific chats/users
ALLOWED_CHATS = ["oc_xxxxx", "oc_yyyyy"]
if chat_id not in ALLOWED_CHATS:
return "Unauthorized"
# Detect language and respond accordingly
if user_language == "zh-CN":
response = "梗图生成中..."
else:
response = "Generating meme..."
# Define aliases
COMMAND_ALIASES = {
"/m": "/milady",
"/mr": "/milady_random",
"/mi": "/milady_illusion"
}
# Use APScheduler for timed posts
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler()
scheduler.add_job(
func=bot.post_daily_gm,
trigger="cron",
hour=9,
minute=0
)
scheduler.start()
from skills.milady_meme_generator.src.meme_generator_v2 import MemeGeneratorV2
generator = MemeGeneratorV2()
image = generator.generate_meme(nft_id=5050)
bot.upload_image(chat_id, image)
from skills.ai_image_effects.src.flux_fill_pro import FluxFillPro
flux = FluxFillPro()
result = flux.replace_accessory(image, "hat", "cool beanie")
bot.upload_image(chat_id, result)
from skills.twitter_content_ai.src.content_generator import ContentGenerator
content = ContentGenerator()
tweet = content.generate_gm_post()
bot.send_message(chat_id, f"Suggested tweet:\n\n{tweet}")
See DEPLOYMENT.md for comprehensive troubleshooting guide.
Cost: Free (Lark API is free, only AI effects have costs)
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience