Skip to content

Enhanced Messenger Integration (Telegram Voice, WhatsApp, Channel Abstraction) #30

@dzianisv

Description

@dzianisv

Overview

Enhance messenger integrations inspired by OpenClaw, a popular personal AI assistant project (167k stars) with comprehensive multi-channel support.

Features

1. Voice Messages in Telegram (High Priority)

  • Handle voice notes sent to the Telegram bot
  • Use existing Whisper STT server to transcribe audio
  • Send transcription to OpenCode, return response as text
  • Support opus/ogg audio format conversion

2. WhatsApp via Baileys (High Priority)

  • Add WhatsApp channel using Baileys library
  • QR code pairing flow for device linking
  • Store credentials in ~/.opencode-manager/credentials/whatsapp/
  • Per-chat session management (like Telegram)
  • Message queueing to prevent race conditions

3. Pairing Security Model (High Priority)

  • Replace simple allowlist with pairing code system
  • Generate 8-character codes for unknown senders
  • CLI command: opencode-manager pairing approve <channel> <code>
  • 60-minute TTL for pending requests
  • Max 3 pending pairing requests at a time
  • Store approved contacts in database

4. Channel Abstraction Layer (Medium Priority)

  • Create Channel interface with common capabilities
  • Define ChannelCapabilities type (chatTypes, media, threads, reactions)
  • Abstract message sending/receiving
  • Support for text, audio, images, and files
  • Per-channel configuration in settings

5. Telegram Settings UI (Medium Priority)

  • Add Telegram settings page in web UI
  • Configure bot token via UI (not just env vars)
  • Manage allowlist via UI
  • View active sessions
  • Test bot connectivity

Technical Approach

Channel Interface (TypeScript)

interface Channel {
  id: string;
  name: string;
  capabilities: ChannelCapabilities;
  
  start(): Promise<void>;
  stop(): Promise<void>;
  send(chatId: string, message: OutboundMessage): Promise<void>;
  onMessage(handler: MessageHandler): void;
}

interface ChannelCapabilities {
  chatTypes: ('direct' | 'group' | 'channel')[];
  media: boolean;
  voice: boolean;
  reactions: boolean;
  threads: boolean;
}

Libraries

  • Telegram: grammy (already using)
  • WhatsApp: @whiskeysockets/baileys
  • Audio: ffmpeg for format conversion

Acceptance Criteria

  • Send voice note to Telegram bot → gets transcribed and responded to
  • Link WhatsApp via QR code → send/receive messages
  • Unknown sender gets pairing code → approved via CLI → can chat
  • Telegram settings configurable via web UI
  • All channels use common Channel interface

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions