Xianyu Auto-Reply System: Multi-Account Management and Intelligent Trading Solution

This article is based entirely on the official documentation of the open-source project xianyu-auto-reply. For learning purposes only – commercial use is strictly prohibited. Full copyright terms appear at the end.

Why Businesses Need Xianyu Automation Tools

Managing multiple Xianyu accounts presents three core challenges:

  1. Delayed message responses causing lost customers
  2. Time-consuming repetitive shipping operations
  3. Inefficient multi-account switching

This article details an open-source automation solution for Xianyu that provides:

  • Intelligent message replies (keyword matching + AI responses)
  • Fully automated shipping processes
  • Unified multi-account management
  • Smart product data analysis

Core Feature Overview

🔐 Multi-User Security System

graph LR
A[User Registration] --> B[Email Verification]
B --> C[CAPTCHA Validation]
C --> D[JWT Authentication]
D --> E[Isolated Data Storage]
  • Three-layer security:

    1. Email + CAPTCHA dual verification at registration
    2. Token-based session management
    3. Physically isolated user data storage

📱 Multi-Account Management Architecture

graph TB
ControlCenter --> Account1[Xianyu Account A]
ControlCenter --> Account2[Xianyu Account B]
ControlCenter --> Account3[Xianyu Account N]
Account1 --> IndependentEngine
Account2 --> IndependentEngine
Account3 --> IndependentEngine
  • Key capabilities:

    • Unlimited account additions
    • Real-time account status monitoring
    • Batch start/stop operations

🤖 Intelligent Reply Workflow

graph LR
ReceiveMessage --> CheckProductKeywords --> MatchFound? --> SendSpecificReply
CheckProductKeywords --> NoMatch? --> CheckGeneralKeywords --> MatchFound? --> SendGeneralReply
CheckGeneralKeywords --> NoMatch? --> GenerateAIResponse

Reply priority system:

  1. Product-specific keyword replies (highest priority)
  2. Global keyword replies
  3. AI-generated responses

Dynamic variables support:

"Hello {username}, the {product_name} you inquired about is in stock. Orders ship within {delivery_time}!"

🚚 Automated Shipping Process

Shipping triggers:

  • Buyer payment notifications
  • Price negotiation messages (“small knife”)
  • Custom trigger conditions

Shipping mechanism:

sequenceDiagram
Buyer->>System: Completes payment
System->>Database: Queries product specs
Database-->>System: Returns specification data
System->>ShippingRules: Matches coupon/card
ShippingRules-->>System: Returns key data
System->>Buyer: Automatically sends key
System->>XianyuAPI: Confirms shipment

Error prevention:

  • Duplicate shipment detection
  • Automatic retries on failure
  • Operation log tracking

🛍️ Product Management System

Dual data channels:

  1. Automatic collection from messages
  2. Active retrieval via Xianyu API

Multi-spec product handling:

| Product ID | Spec Name  | Stock | Price | Status  |
|------------|------------|-------|-------|---------|
| 1001       | Monthly    | 50    | 15    | Enabled |
| 1001       | Quarterly  | 20    | 40    | Disabled|
| 1002       | Standard   | 100   | 10    | Enabled |

🔍 Real Product Search Technology

Data collection process:

  1. Launch browser via Playwright
  2. Simulate user search behavior
  3. Parse actual page data
  4. Sort by “Want Count” metric

Sample output:

{
  "Product Title": "NetEase Cloud Music Monthly Membership",
  "Price": "¥8.99",
  "Want Count": 2450,
  "Seller Location": "Shanghai",
  "Product Link": "https://..."
}

Technical Architecture Analysis

System Architecture Diagram

graph TD
A[Web Interface] --> B[FastAPI Service]
B --> C[Cookie Manager]
C --> D[Account 1 WS]
C --> E[Account 2 WS]
D --> F[Message Processor]
E --> F
F --> G[SQLite Database]

Core Module Functions

Module File Function Description
Start.py System entry point
XianyuAutoAsync.py WebSocket message handling
reply_server.py Web service endpoints
db_manager.py Multi-user database management
ai_reply_engine.py AI response engine
item_search.py Product search implementation

Deployment Guide (3 Options)

Option 1: Docker Quick Deployment

# Create data directory
mkdir -p xianyu-auto-reply

# Launch container
docker run -d \
  -p 8080:8080 \
  -v $PWD/xianyu-auto-reply/:/app/data/ \
  --name xianyu-auto-reply \
  registry.cn-shanghai.aliyuncs.com/zhinian-software/xianyu-auto-reply:1.0

Windows users: Replace $PWD with %cd%

Option 2: Source Code Deployment

git clone https://github.com/zhinianboke/xianyu-auto-reply.git
cd xianyu-auto-reply
chmod +x docker-deploy.sh  # Linux/macOS
./docker-deploy.sh

Windows users: Use docker-deploy.bat

Option 3: Local Development Setup

python -m venv venv
source venv/bin/activate  # Linux/macOS
venv\Scripts\activate    # Windows
pip install -r requirements.txt
playwright install chromium
python Start.py

Practical Configuration Guide

Initial Login Setup

  1. Access http://localhost:8080
  2. Use default credentials:

    • Username: admin
    • Password: admin123
  3. Immediately change default password

Adding Xianyu Accounts

  1. Obtain Xianyu cookies
  2. Add new account in system
  3. Enter complete cookie values
  4. Start monitoring task

Configuring Auto-Shipping Rules

1. Navigate to "Shipping Management"
2. Create new rule:
   - Product Keywords: *music membership*
   - Shipping Content: Key data or API links
3. Configure specification matching
4. Enable shipping delay (optional)

Technical Implementation Deep Dive

🔒 Security Architecture

Security Layer Implementation
Authentication JWT tokens + CAPTCHA
Data Storage SQLite encryption
Transport Secure WebSocket channels
Operations Full activity logging

🚀 Performance Optimization

  1. Async architecture: asyncio-based message processing
  2. Connection pooling: Database connection reuse
  3. Smart caching: In-memory frequent data caching
  4. Resource isolation: Per-account runtime environments

🧠 AI Response Configuration

# Sample configuration
ai_engine: openai
api_key: sk-xxxxxxxxxxxx
model: gpt-4
temperature: 0.7
max_tokens: 500

Supported models:

  • OpenAI GPT series
  • Tongyi Qianwen
  • Other API-compatible models

Troubleshooting Guide

1. Docker Container Startup Failure

# Clean and rebuild containers
docker-compose down
docker rm xianyu-auto-reply
docker-compose up -d --build

2. WebSocket Connection Issues

Diagnosis steps:

  1. Open ports 3000-3010 in firewall
  2. Verify cookie validity
  3. Check real-time connection logs

3. Script Execution Errors (Linux/Mac)

# Fix line endings
sed -i 's/\r$//' docker-deploy.sh
chmod +x docker-deploy.sh
./docker-deploy.sh

4. Multi-Spec Product Matching Failures

Resolution strategy:

  1. Ensure consistent specification naming
  2. Configure fallback shipping rules
  3. Enable fuzzy matching mode

5. Image Upload Failures

Solutions:

  1. Verify CDN configuration
  2. Check image format restrictions
  3. Review storage quotas

Technical Support Channels

Community Groups

For technical support, join developer communities:

WeChat Group
WeChat group QR code

QQ Group
QQ group QR code


Copyright and Usage Terms

Permitted Uses

  • ✅ Personal learning and research
  • ✅ Non-commercial technical sharing
  • ✅ Open-source contributions

Prohibited Actions

  • ❌ Any commercial application
  • ❌ Code resale for profit
  • ❌ Removal of copyright information
  • ❌ Illegal operations

Disclaimer

  1. Project provided “as-is” without warranties
  2. Users assume all risks
  3. Illegal usage strictly prohibited

Using this project signifies agreement to these terms


Project Acknowledgements

Development leveraged these open-source projects:


Project URL: https://github.com/zhinianboke/xianyu-auto-reply
Important: This system is for technical research only. Using Xianyu automation tools requires compliance with platform policies