Package Information
Available Nodes
Documentation
n8n-nodes-wechat-official
๐ Professional WeChat Official Account integration for n8n workflows
This is an n8n community node that provides comprehensive WeChat Official Account API integration, enabling you to automate WeChat content management, user interactions, and media operations within your n8n workflows.
WeChat Official Account is China's leading social media platform for businesses, allowing organizations to create official accounts for customer engagement, content publishing, and service delivery.
n8n is a fair-code licensed workflow automation platform.
๐ Table of Contents
- โจ Key Features
- ๐ Quick Start
- ๐ฆ Installation
- ๐ Authentication
- โ๏ธ Operations
- ๐ค AI Tool Integration
- ๐ณ Docker Deployment
- ๐ Usage Examples
- ๐ง Development
- ๐ค Contributing
- ๐ License
- ๐ Support
โจ Key Features
๐ฏ Core Capabilities
- ๐ Smart Token Management - Automatic access token caching and refresh
- ๐ Complete Material Management - Upload images, voice, video, and thumbnails
- ๐ Draft Management - Create, edit, and publish article drafts
- ๐ก๏ธ Robust Error Handling - Comprehensive error codes mapping and retry mechanisms
- ๐ High Performance - Batch processing and intelligent rate limiting
- ๐ Enterprise Security - IP whitelist support and credential encryption
๐ค Advanced Integration
- ๐ง Dual Usage Mode - Works as both workflow node and AI tool (
usableAsTool: true) - ๐ Batch Operations - Efficient bulk media uploads and content management
- ๐ Real-time Monitoring - Built-in logging and performance metrics
- ๐ Multi-environment Support - Production and sandbox environments
๐ ๏ธ Developer Experience
- ๐ Comprehensive Documentation - Detailed guides and examples
- ๐งช Full Test Coverage - Jest-based testing suite
- ๐จ TypeScript Support - Full type safety and IntelliSense
- ๐ ESLint Integration - Code quality and consistency
๐ Quick Start
Prerequisites
- n8n instance (version 1.0.0 or higher)
- WeChat Official Account with API access
- Node.js 20.15 or higher
1-Minute Setup
Install the node:
npm install n8n-nodes-wechat-officialConfigure credentials in n8n:
- App ID: Your WeChat Official Account App ID
- App Secret: Your WeChat Official Account App Secret
- Environment: Choose 'production' or 'sandbox'
Start automating - Add the WeChat Official Account node to your workflow!
๐ฆ Installation
Method 1: npm Installation (Recommended)
# Install globally for n8n
npm install -g n8n-nodes-wechat-official
# Or install in your n8n project
npm install @xwang152/n8n-nodes-wechat-official
Method 2: Community Node Installation
- Go to Settings > Community Nodes in your n8n instance
- Click Install a community node
- Enter:
@xwang152/n8n-nodes-wechat-official - Click Install
For detailed instructions, follow the n8n community nodes installation guide.
Method 3: Manual Installation
# Clone the repository
git clone https://github.com/xwang152-jack/n8n-nodes-wechat-official.git
cd n8n-nodes-wechat-official
# Install dependencies and build
npm install
npm run build
# Link to your n8n installation
npm link
๐ Authentication
Setting Up Credentials
This node requires WeChat Official Account API credentials:
| Field | Description | Required | Example |
|---|---|---|---|
| App ID | WeChat Official Account App ID | โ | wx1234567890abcdef |
| App Secret | WeChat Official Account App Secret | โ | abcdef1234567890... |
| Environment | API environment | โ | production or sandbox |
| Server IP | Your server IP for whitelist | โ ๏ธ | 192.168.1.100 |
Getting Your Credentials
Access WeChat Platform
- Visit WeChat Official Account Platform
- Login with your account credentials
Navigate to Developer Settings
- Go to Development > Basic Configuration
- Copy your App ID and App Secret
Configure IP Whitelist (Production Only)
- Add your server IP to the whitelist
- This is mandatory for production API access
Security Best Practices
- โ Store credentials securely in n8n credential store
- โ Use environment variables for sensitive data
- โ Regularly rotate App Secret (recommended: every 90 days)
- โ Monitor API usage and access logs
- โ Enable IP whitelist for production environments
โ๏ธ Operations
๐ Access Token Management
- Get Access Token - Retrieve and cache access tokens
- โก Automatic caching (2-hour validity)
- ๐ Smart refresh mechanism
- ๐ก๏ธ Error handling for expired tokens
๐ Material Management
Upload Image - Upload images for articles and media
- ๐ธ Support for base64 encoded images
- โ Automatic format validation (JPG, PNG)
- ๐ Size limit validation (up to 10MB)
- ๐ Returns media_id for further use
Upload Media - Upload permanent media files
- ๐ต Voice: MP3, WMA, WAV, AMR (up to 60s, 2MB)
- ๐ฌ Video: MP4 (up to 10MB)
- ๐ผ๏ธ Thumbnail: JPG, PNG (up to 64KB)
- ๐ฆ Batch upload capabilities
- ๐ File validation and error reporting
๐ Draft Management
Add Draft - Create new article drafts
- ๐ Rich text content support
- ๐ผ๏ธ Media attachment handling
- ๐ Draft validation and preview
- ๐ Content statistics
Publish Draft - Publish draft articles
- ๐ Automatic publishing workflow
- ๐ Status tracking and confirmation
- ๐ Error recovery mechanisms
- ๐ Scheduled publishing support
๐ค AI Tool Integration
This node supports AI Tool Calling Mode (usableAsTool: true), enabling seamless integration with AI assistants and automated systems.
Integration Methods
1. Workflow Node
[Trigger] โ [WeChat Official Account] โ [Other Nodes]
2. AI Tool Calling
// AI assistants can directly invoke node functions
const result = await wechatNode.execute({
resource: 'material',
operation: 'uploadImage',
image: 'base64_encoded_image'
});
3. API Integration
# Direct API integration
curl -X POST /api/wechat/upload-image \
-H "Content-Type: application/json" \
-d '{"image": "base64_encoded_image"}'
Benefits of AI Integration
- ๐ค AI Assistant Integration - Let AI manage WeChat operations automatically
- ๐ง Programmatic Access - Use in custom scripts and applications
- ๐ฆ Batch Processing - Efficient bulk operations
- โก Real-time Integration - Immediate response for time-sensitive tasks
- ๐ Event-driven Automation - Trigger actions based on external events
๐ณ Docker Deployment
Quick Start with Docker Compose
version: '3.8'
services:
n8n:
image: n8nio/n8n:latest
container_name: n8n-wechat
ports:
- "5679:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=password
volumes:
- n8n_data:/home/node/.n8n
- ./dist:/home/node/.n8n/custom # Plugin files
command: >
sh -c "mkdir -p /home/node/.n8n/custom &&
chown -R node:node /home/node/.n8n/custom &&
n8n start"
volumes:
n8n_data:
Deployment Steps
Build the plugin:
npm run buildStart with Docker Compose:
docker-compose up -dAccess n8n:
- URL: http://localhost:5679
- Username: admin
- Password: password
Verification
# Check plugin installation
docker exec n8n-wechat ls -la /home/node/.n8n/custom
# Verify plugin files
docker exec n8n-wechat find /home/node/.n8n/custom -name '*.js' -type f
๐ Usage Examples
Example 1: Automated Content Publishing
{
"workflow": {
"nodes": [
{
"name": "Upload Thumbnail",
"type": "n8n-nodes-wechat-official",
"parameters": {
"resource": "material",
"operation": "uploadImage",
"image": "{{ $binary.data.data }}"
}
},
{
"name": "Create Article Draft",
"type": "n8n-nodes-wechat-official",
"parameters": {
"resource": "draft",
"operation": "addDraft",
"title": "{{ $json.title }}",
"content": "{{ $json.content }}",
"thumb_media_id": "{{ $node['Upload Thumbnail'].json.media_id }}"
}
},
{
"name": "Publish Article",
"type": "n8n-nodes-wechat-official",
"parameters": {
"resource": "draft",
"operation": "publishDraft",
"media_id": "{{ $node['Create Article Draft'].json.media_id }}"
}
}
]
}
}
Example 2: Batch Media Upload
{
"resource": "material",
"operation": "uploadMedia",
"type": "image",
"media": [
{"name": "product1.jpg", "data": "base64_data_1"},
{"name": "product2.jpg", "data": "base64_data_2"},
{"name": "product3.jpg", "data": "base64_data_3"}
]
}
Example 3: AI-Powered Content Management
// AI assistant automatically manages WeChat content
const aiWorkflow = {
trigger: 'schedule',
actions: [
{
tool: 'wechat-official-account',
operation: 'generateContent',
parameters: {
topic: 'daily news',
style: 'professional',
includeImages: true
}
},
{
tool: 'wechat-official-account',
operation: 'publishDraft',
parameters: {
scheduleTime: 'tomorrow 9:00 AM'
}
}
]
};
๐ง Development
Requirements
- Node.js: >= 20.15.0
- TypeScript: >= 5.8.0
- n8n: >= 1.0.0
Development Setup
# Clone repository
git clone https://github.com/xwang152-jack/n8n-nodes-wechat-official.git
cd n8n-nodes-wechat-official
# Install dependencies
npm install
# Start development mode
npm run dev
Available Scripts
# Build project
npm run build
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Watch mode for tests
npm run test:watch
# Code linting
npm run lint
# Fix linting issues
npm run lintfix
# Format code
npm run format
Project Structure
n8n-nodes-wechat-official/
โโโ ๐ credentials/ # Authentication credentials
โ โโโ WechatOfficialAccountApi.credentials.ts
โโโ ๐ nodes/
โ โโโ ๐ WechatOfficialAccount/ # Main node implementation
โ โโโ ๐ types/ # TypeScript type definitions
โ โโโ ๐ utils/ # Utility functions
โ โโโ WechatOfficialAccount.node.ts
โ โโโ wechat.svg # Node icon
โโโ ๐ test/ # Test files
โโโ ๐ dist/ # Built files
โโโ ๐ package.json
โโโ ๐ tsconfig.json
โโโ ๐ jest.config.js
โโโ ๐ README.md
Testing
# Run all tests
npm test
# Run specific test file
npm test -- WechatOfficialAccount.test.ts
# Run tests with coverage report
npm run test:coverage
Code Quality
This project maintains high code quality standards:
- โ TypeScript - Full type safety
- โ ESLint - Code linting and style enforcement
- โ Prettier - Code formatting
- โ Jest - Comprehensive testing
- โ Husky - Git hooks for quality checks
๐ค Contributing
We welcome contributions! Please see our Contributing Guide for details.
How to Contribute
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Follow TypeScript best practices
- Write comprehensive tests for new features
- Update documentation for API changes
- Follow the existing code style
- Add meaningful commit messages
๐ License
MIT License - see the LICENSE file for details.
๐ Support
Getting Help
If you encounter issues or need assistance:
- ๐ Check Documentation - Review this README and inline documentation
- ๐ Search Issues - Look through existing GitHub issues
- ๐ Create New Issue - Submit a detailed bug report or feature request
- ๐ฌ Community Support - Join the n8n Community Forum
- ๐ง Direct Contact - Email: xwagn152@163.com
Troubleshooting
Common Issues
Q: "Access token invalid" error
A: Check your App ID and App Secret, ensure IP whitelist is configured correctly.
Q: "Media upload failed" error
A: Verify file format and size limits, check network connectivity.
Q: "Draft publishing failed" error
A: Ensure draft content is complete and complies with WeChat specifications.
API Limitations
- Access Token: Valid for 7200 seconds (2 hours) - automatically managed
- Temporary Materials: Valid for 3 days
- API Call Frequency: Follow WeChat Official Account Platform rate limits
- File Size Limits: Images (10MB), Voice (2MB), Video (10MB)
Resources
- ๐ WeChat Official Account API Documentation
- ๐ n8n Community Nodes Documentation
- ๐ WeChat Official Account Platform
- ๐ฌ n8n Community Forum
๐ Ready to automate your WeChat Official Account?
Install Now โข View Examples โข Get Support
Made with โค๏ธ by xwang152-jack
โญ Star this repo if it helped you! โญ