Overview
WuKongIM defines a set of plugin rules that third-party developers can implement to extend or enhance existing WuKongIM message processing logic. Through plugins, you can implement features like sensitive word filtering, message search, AI chat, and more.Plugin functionality is only supported in WuKongIM version 2.1.3 and above
Plugin Types
User Plugins
User plugins can receive all messages from users bound to the plugin. After installation, they need to be bound to users to take effect. Features:- Only process messages from bound users
- Suitable for AI chat, personal assistant scenarios
- Implement
Receivefunction
- Chat with large language models: Bind specific user UID, sending messages to this user means sending to the LLM
- Personal assistant: Provide customized services for specific users
Global Plugins
Global plugins can receive all messages in the system. After installation, they take effect globally. Features:- Monitor all system messages
- No need to bind users
- Suitable for system-level functionality
- Sensitive word filtering: Monitor every sent message for filtering
- Message search: Build search index for all messages
- Data analysis: Statistics and analysis of message data
Development Environment Setup
Prerequisites
- Go language environment (currently plugin development only supports Go)
- WuKongIM source code or running instance
- Go PDK plugin development library
Environment Preparation
1. Download WuKongIM Source CodePlugin Development
Basic Structure
Here’s a complete plugin development example:Core Interfaces
PluginInfo
Plugin information structure:Message
Message structure received by plugin:Plugin Types
Plugin Configuration
Plugins can define configuration items that users can set in the WuKongIM management interface:json: Configuration item namelabel: Display name in management interfaceplaceholder: Input placeholder textdefault: Default valuerequired: Whether required
Plugin Compilation and Installation
Compilation
1. Build Plugin.so file to WuKongIM management interface.
Installation and Configuration
1. Install Plugin In WuKongIM management interface:- Go to Plugin Management
- Upload plugin file
- Configure plugin parameters
- Enable plugin
- Go to User Management
- Select target user
- Bind plugin to user
API Reference
Send Message
Update Message
Logging
Best Practices
-
Error Handling
- Always handle errors gracefully
- Use appropriate logging levels
- Don’t panic in plugin code
-
Performance
- Avoid blocking operations
- Use goroutines for heavy processing
- Implement proper timeouts
-
Security
- Validate all input data
- Sanitize user content
- Use secure API calls
-
Configuration
- Provide sensible defaults
- Validate configuration values
- Document all configuration options

