Skip to main content

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 Receive function
Use Cases:
  • 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
Use Cases:
  • 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 Code
2. Start Single-Node WuKongIM
3. Create Plugin Project

Plugin 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:
Configuration Tags:
  • json: Configuration item name
  • label: Display name in management interface
  • placeholder: Input placeholder text
  • default: Default value
  • required: Whether required

Plugin Compilation and Installation

Compilation

1. Build Plugin
2. Upload Plugin Upload the compiled .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
2. Bind Users (User Plugins Only) For user plugins, you need to bind specific users:
  • Go to User Management
  • Select target user
  • Bind plugin to user

API Reference

Send Message

Update Message

Logging

Best Practices

  1. Error Handling
    • Always handle errors gracefully
    • Use appropriate logging levels
    • Don’t panic in plugin code
  2. Performance
    • Avoid blocking operations
    • Use goroutines for heavy processing
    • Implement proper timeouts
  3. Security
    • Validate all input data
    • Sanitize user content
    • Use secure API calls
  4. Configuration
    • Provide sensible defaults
    • Validate configuration values
    • Document all configuration options