* feat: add VK channel support - Add VK channel implementation using vksdk - Support text messages and media attachments - Implement Long Poll API for real-time messaging - Add group chat support with trigger prefixes - Add user whitelist (allow_from) configuration - Add VK channel documentation Files: - pkg/channels/vk/: VK channel implementation - pkg/config/config.go: Add VKConfig structure - pkg/channels/manager.go: Register VK channel - pkg/gateway/gateway.go: Import VK channel package - docs/channels/vk/: Usage documentation * test: add unit tests for VK channel - Test channel initialization with various configurations - Test allow_from whitelist functionality - Test group trigger configuration - Test max message length (4000 chars) - Test message splitting logic - Test attachment processing All tests passing ✓ * fix: resolve linting issues in VK channel - Format VKConfig struct tags to comply with golines - Remove unused mu sync.Mutex field - Remove unused stripPrefix method All tests passing ✓ * style: format VKConfig with golines - Align struct tags to match project style - Match formatting with other channel configs (Telegram, etc.) - Fix golines linting error * style: fix struct tag formatting in config.go * docs: update VK channel docs to use secure token storage * feat(vk): add voice capabilities support - Implement VoiceCapabilities() method for VK channel - Add audio_message attachment handling in processAttachments - Add comprehensive tests for voice capabilities - Support both ASR (speech-to-text) and TTS (text-to-speech) * docs: add VK channel to documentation and update voice support - Add VK channel to README.md and README.zh.md channel lists - Update VK channel documentation with voice message support - Document ASR and TTS capabilities for VK channel - Add voice transcription configuration reference
6.0 KiB
VK (VKontakte)
The VK channel uses Bots Long Poll API for bot-based communication with VK social network. It supports text messages, media attachments (photos, videos, audio, documents, stickers), and group chat interactions.
Configuration
{
"channels": {
"vk": {
"enabled": true,
"token": "NOT_HERE",
"group_id": 123456789,
"allow_from": ["123456789"],
"group_trigger": {
"mention_only": false,
"prefixes": ["/bot", "!bot"]
}
}
}
}
| Field | Type | Required | Description |
|---|---|---|---|
| enabled | bool | Yes | Whether to enable the VK channel |
| token | string | Yes | Set to NOT_HERE - token is stored securely (see Token Storage) |
| group_id | int | Yes | VK Community ID (Group ID) |
| allow_from | array | No | Allowlist of user IDs; empty means all users are allowed |
| group_trigger | object | No | Configuration for group chat triggers |
Token Storage
For security reasons, the VK access token should not be stored directly in the configuration file. Instead:
- Set
tokento"NOT_HERE"in the configuration - Store the actual token using one of these methods:
- Environment variable: Set
PICOCLAW_CHANNELS_VK_TOKENenvironment variable - Secure storage: Use PicoClaw's secure token storage mechanism
- Environment variable: Set
Example using environment variable:
export PICOCLAW_CHANNELS_VK_TOKEN="vk1.a.abc123..."
Group Trigger Configuration
| Field | Type | Description |
|---|---|---|
| mention_only | bool | Only respond when bot is mentioned in group chats |
| prefixes | []string | List of prefixes that trigger bot response in group chats |
Setup
1. Create a VK Community
- Go to VK and log in
- Create a new community or use an existing one
- Note your Community ID (found in the community URL, e.g.,
public123456789)
2. Enable Messages
- Go to your community page
- Click "Manage" → "Messages" → "Community Messages"
- Enable community messages
3. Create Access Token
- Go to "Manage" → "API usage" → "Access tokens"
- Click "Create token"
- Select the following permissions:
messages- Access to messagesphotos- Access to photos (optional)docs- Access to documents (optional)
- Copy the generated access token
- Store the token securely (see Token Storage section below)
4. Configure PicoClaw
- Add the token to your PicoClaw configuration
- Set the
group_idto your community ID (numeric value) - (Optional) Configure
allow_fromto restrict which user IDs can interact
Features
Supported Message Types
- Text messages: Full support for text messages
- Photos: Photos are displayed as
[photo]placeholder - Videos: Videos are displayed as
[video]placeholder - Audio: Audio files are displayed as
[audio]placeholder - Voice messages: Voice messages are displayed as
[voice]placeholder and support transcription - Documents: Documents are displayed as
[document: filename] - Stickers: Stickers are displayed as
[sticker]placeholder
Voice Support
The VK channel supports both voice message reception and text-to-speech capabilities:
- ASR (Automatic Speech Recognition): Voice messages can be transcribed to text using configured voice models
- TTS (Text-to-Speech): Text responses can be converted to voice messages
To enable voice transcription, configure a voice model in your providers setup. See Voice Transcription for details.
Group Chat Support
The VK channel supports group chats with configurable triggers:
- Mention-only mode: Bot only responds when mentioned
- Prefix mode: Bot responds to messages starting with specified prefixes
- Permissive mode: Bot responds to all messages (default)
Message Length
VK has a maximum message length of 4000 characters. PicoClaw automatically splits longer messages into multiple parts.
Example Configuration
Basic Configuration
{
"channels": {
"vk": {
"enabled": true,
"token": "NOT_HERE",
"group_id": 123456789
}
}
}
With User Whitelist
{
"channels": {
"vk": {
"enabled": true,
"token": "NOT_HERE",
"group_id": 123456789,
"allow_from": ["123456789", "987654321"]
}
}
}
With Group Chat Triggers
{
"channels": {
"vk": {
"enabled": true,
"token": "NOT_HERE",
"group_id": 123456789,
"group_trigger": {
"prefixes": ["/bot", "!bot"]
}
}
}
}
Troubleshooting
Bot Not Responding
- Check that the access token is valid
- Verify that the
group_idis correct - Ensure the user ID is in
allow_fromif configured - Check PicoClaw logs for error messages
Permission Errors
Make sure the access token has the necessary permissions:
messages- Required for sending and receiving messagesphotos- Optional, for handling photo attachmentsdocs- Optional, for handling document attachments
Group Chat Issues
If the bot doesn't respond in group chats:
- Check
group_triggerconfiguration - Try using a prefix to trigger the bot
- Check if the bot has permission to read group messages
API Reference
The VK channel uses the VK SDK for Go library, which supports VK API version 5.199.
For more information about VK API, see: