Overview
This node provides multiple operations, including PHP serialization/unserialization and sending broadcast messages via WeChat. Focusing on the 微信群发 (WeChat Broadcast) operation, it enables users to send messages to either WeChat group chats or individual contacts.
Typical use cases include:
- Sending announcements or updates to a specific WeChat group.
- Broadcasting promotional messages or alerts to selected friends.
- Automating message delivery through an already logged-in WeChat account or by scanning a QR code to log in dynamically.
For example, a marketing team could automate sending a text or image message to a customer group chat every morning, or a user could quickly notify all friends about an event.
Properties
Name | Meaning |
---|---|
使用已登录的微信账号 (useLoggedInAccount) | Whether to use an already logged-in WeChat account (via a prior login node). Boolean true/false. |
消息类型 (messageType) | Type of message to send. Options: 文本消息 (text), 图片消息 (image). |
消息内容 (messageContent) | Content of the text message to send. Only used if messageType is "text". |
图片URL (imageUrl) | URL of the image to send. Only used if messageType is "image". |
接收者类型 (recipientType) | Recipient type. Options: 群聊 (room/group chat), 好友 (contact/friend). |
接收者名称 (recipientName) | Name of the recipient group or friend to send the message to. |
等待时间(秒) (waitTime) | Maximum wait time in seconds for QR code login when not using an already logged-in account. |
Output
The node outputs JSON objects with the following structure depending on success or failure:
On success:
{ "success": true, "operation": "wechatBroadcast", "messageType": "text" | "image", "recipientType": "room" | "contact", "recipientName": "<name>", "message": "<text content or image URL>", "usedLoggedInAccount": true | false }
On failure:
{ "success": false, "operation": "wechatBroadcast", "error": "<error message>" }
No binary data output is produced by this operation.
Dependencies
- The node depends on the
wechaty
library to interact with WeChat accounts. - It uses
file-box
to handle image URLs for sending images. - If using an already logged-in account, the global environment must have a valid WeChaty instance and login state.
- If not using a logged-in account, the node will start a new WeChaty instance and require scanning a QR code within the specified wait time to log in.
- No explicit API keys are required, but the user must authenticate via WeChat login (QR code scan or prior login node).
Troubleshooting
Common issues:
- Failure to find the specified group chat or contact by name results in errors like "找不到群聊:
" or "找不到好友: ". - Login timeout if QR code is not scanned within the wait time, resulting in "登录超时,请扫码登录".
- Using the option to send with an already logged-in account without having one active causes an immediate error indicating no logged-in account found.
- Failure to find the specified group chat or contact by name results in errors like "找不到群聊:
Error resolution:
- Verify the exact spelling of the group or contact name matches WeChat.
- Ensure the WeChaty instance is properly logged in before using the "use logged-in account" option.
- When not using a logged-in account, be ready to scan the QR code promptly within the wait time.
- Check network connectivity as WeChaty requires internet access to communicate with WeChat servers.
Links and References
This summary covers the WeChat broadcast operation of the node based on static analysis of the provided source code and property definitions.