⭐ If this plugin helps you, please give it a star! ⭐
Author: bikeread
Version: 7
Type: extension
GitHub: Repository | Issues
🚀 Love this project? Show your support by giving it a ⭐ on GitHub!
💡 Found it useful? Help others discover it by starring the repository!
🎯 Want updates? Star and watch to get notified of new features!
The Dify WeChat Official Account Plugin is designed for content creators and public account owners who want to integrate AI capabilities into their WeChat Official Accounts. It provides 24/7 intelligent customer service and content assistance.
- After installing the plugin, create a new endpoint
- Configure the following settings:
- Endpoint Name: Any name you prefer
- APP: Select the Dify application that will handle user messages
- AppID: Your Official Account's AppID
- WeChat Token: Copy from your WeChat Official Account platform
- EncodingAESKey: Copy from your WeChat Official Account platform (leave empty if not configured)
- AppSecret: Your Official Account's AppSecret
- Timeout Message: A message to show when response takes longer than 15 seconds (default: "内容生成耗时较长,请稍等...")
- Retry Wait Timeout Ratio: Retry wait timeout ratio between 0.1-1.0 (default: 0.7)
- Enable Custom Message: Enable customer service messages (requires customer service message permission, default: false)
- Continue Waiting Message: Continue waiting prompt message (default: "生成答复中,继续等待请回复1")
- Max Continue Count: Maximum continue waiting count (default: 2)
- WeChat API Proxy URL: Custom WeChat API proxy address (default: api.weixin.qq.com, do not include https://, http is not supported)
Note: The timeout message is important because WeChat requires a response within 15 seconds. If your AI application takes longer to generate a complete response:
- The timeout message will be sent as an immediate response
- If AppID and AppSecret are configured, the complete AI response will be sent via WeChat's customer service message API
- Please ensure your Official Account has permission to send customer service messages
- Log in to WeChat Official Account Platform (https://mp.weixin.qq.com/)
- Go to "Settings & Development" -> "Basic Settings"
- Under "Server Configuration":
- Copy one of the two endpoint URLs from your plugin configuration
- Paste it into the "Server URL" field
- Set the same Token as configured in your plugin
- Choose message encryption method (Plain Text or Secure Mode)
- If using Secure Mode, set the same EncodingAESKey as in your plugin
- Click "Submit" to save the configuration
- After saving both plugin and WeChat configurations
- Send a test message to your Official Account
- If you receive an AI response, the configuration is successful
🎉 Success! If everything works perfectly, consider giving this project a ⭐ to help others find it!
This plugin supports multiple types of messages that your users can send to your WeChat Official Account:
- Users can send regular text messages
- Relevant input parameters:
msgId: Unique message ID msgType: Message type ("text") fromUser: Sender's OpenID createTime: Message creation timestamp content: The text message content
- Users can send image content
- The system provides image URL to AI for processing
- Relevant input parameters:
msgId: Unique message ID msgType: Message type ("image") fromUser: Sender's OpenID createTime: Message creation timestamp picUrl: URL of the image sent by user
- Users can send voice recordings
- The system converts voice to base64 format for AI processing
- Relevant input parameters:
msgId: Unique message ID msgType: Message type ("voice") fromUser: Sender's OpenID createTime: Message creation timestamp media_id: WeChat media ID for the voice voice_base64: Base64 encoded voice data voice_media_type: Media type of the voice voice_format: Format of the voice (default "amr")
- Users can share links to articles/websites
- The system extracts link information for AI processing
- Relevant input parameters:
msgId: Unique message ID msgType: Message type ("link") fromUser: Sender's OpenID createTime: Message creation timestamp url: The shared URL title: Title of the shared link description: Description of the shared link
Your Dify application can access all these parameters in the conversation context and respond accordingly.
This plugin uses a modular design with the following main components:
endpoints/
├── wechat/ # Core WeChat processing module
│ ├── __init__.py # Package initialization
│ ├── models.py # WechatMessage model definition
│ ├── parsers.py # XML parser definition
│ ├── formatters.py # Response formatter definition
│ ├── factory.py # Message handler factory
│ ├── crypto.py # WeChat message encryption tools
│ ├── retry_tracker.py # Message retry tracker
│ ├── api/ # API-related
│ │ ├── __init__.py # API package initialization
│ │ └── custom_message.py # Customer service message sender
│ └── handlers/ # Message handlers
│ ├── __init__.py # Handlers package initialization
│ ├── base.py # Abstract handler base class
│ ├── text.py # Text message handler
│ ├── image.py # Image message handler
│ ├── voice.py # Voice message handler
│ ├── link.py # Link message handler
│ └── unsupported.py # Unsupported message type handler
├── wechat_get.py # Handle WeChat server verification
└── wechat_post.py # Handle user messages
