How to Manage Channels
Channels connect GSV to messaging platforms. Each channel runs as a separate Cloudflare Worker with its own Durable Object for maintaining persistent connections. The gateway communicates with channels via Service Bindings.
Deploy channels
Channels are deployed alongside the gateway. Include them during initial deployment:
gsv deploy up --allOr deploy a specific channel:
gsv deploy up -c channel-whatsapp
gsv deploy up -c channel-discordBoth WhatsApp and Discord channels require an always-on Durable Object. The free Cloudflare tier supports one always-on DO. Running multiple channels or multiple accounts within a channel requires a paid Workers plan.
WhatsApp
Connect WhatsApp
WhatsApp uses QR-code authentication via the Baileys library. The connection runs in a Durable Object that maintains the WebSocket to WhatsApp's servers.
gsv channel whatsapp loginThis displays a QR code in your terminal. Scan it with WhatsApp on your phone (Settings > Linked Devices > Link a Device).
You can specify an account ID if you want to manage multiple WhatsApp accounts:
gsv channel whatsapp login my-second-accountCheck WhatsApp status
gsv channel whatsapp statusDisconnect WhatsApp
Stop the connection (keeps credentials for reconnection):
gsv channel whatsapp stopLog out completely (clears stored credentials):
gsv channel whatsapp logoutAfter logout, you'll need to scan the QR code again to reconnect.
WhatsApp reconnection
The WhatsApp Durable Object automatically reconnects when the connection drops. Stored auth credentials survive DO hibernation, so the connection resumes without re-scanning the QR code unless you explicitly log out.
Discord
Set up a Discord bot
Before connecting, you need a Discord bot token:
- Go to Discord Developer Portal
- Create a New Application
- Go to the Bot tab, click Add Bot, then Reset Token to get your token
- Enable MESSAGE CONTENT INTENT in the Bot tab
- Invite the bot to your server using:
https://discord.com/oauth2/authorize?client_id=<APP_ID>&permissions=101376&scope=bot
Pass the bot token during deployment:
gsv deploy up -c channel-discord --discord-bot-token "$DISCORD_BOT_TOKEN"Start the Discord bot
gsv channel discord startThe Discord channel maintains a Gateway WebSocket connection to Discord's API, handling heartbeats and message dispatch through the Durable Object.
Check Discord status
gsv channel discord statusStop the Discord bot
gsv channel discord stopConfigure channel access control
Each channel has a DM policy that controls who can message the agent.
Pairing mode (default for WhatsApp)
Unknown senders trigger a pairing request. You approve them via CLI:
# List pending pairing requests
gsv pair list
# Approve a sender
gsv pair approve whatsapp "+1234567890"
# Reject a sender
gsv pair reject whatsapp "+1234567890"Allowlist mode
Only specific senders can message:
gsv config set channels.whatsapp.dmPolicy "allowlist"
gsv config set channels.whatsapp.allowFrom '["+1234567890", "+0987654321"]'Open mode (default for Discord)
Anyone can message. Use with caution:
gsv config set channels.discord.dmPolicy "open"Monitor channel status
List all connected channel accounts:
gsv channel listHow inbound messages route to sessions
- A message arrives at the channel worker (e.g., WhatsApp DO receives a message)
- The channel DO calls
env.GATEWAY.channelInbound()via Service Binding RPC - The gateway checks the sender against the channel's DM policy
- If allowed, the gateway resolves the agent ID (using agent bindings if configured)
- The gateway builds a session key based on
dmScopeand identity links - The message is routed to the appropriate Session DO
- The Session DO runs the agent loop (LLM + tools)
- The response is sent back through the channel via
channel.send()
Troubleshooting
WhatsApp QR code not appearing: Check that the channel-whatsapp worker is deployed (gsv deploy status -c channel-whatsapp) and that you have network connectivity to the gateway.
WhatsApp disconnects frequently: The DO may be hibernating and failing to resume. Check gsv channel whatsapp status for the connection state. Try gsv channel whatsapp logout then gsv channel whatsapp login for a fresh session.
Discord bot not responding: Verify the bot has the MESSAGE CONTENT INTENT enabled and is invited to the server with correct permissions. Check gsv channel discord status.
Messages from unknown senders are blocked: Check your DM policy. In pairing mode, senders need explicit approval. In allowlist mode, add the sender's ID to the allowlist. Run gsv pair list to see pending requests.