Skip to main content
The Discord Connector provides a high-fidelity bridge between the Palyra platform and the Discord messaging ecosystem. It is implemented as a specialized provider within the palyra-connectors framework, managed by the ChannelPlatform supervisor in the daemon. It supports message normalization, real-time gateway interaction, automated onboarding, and fine-grained mutation governance (edits/deletions/reactions).

Architecture Overview

The Discord implementation is divided into three primary adapter layers that satisfy the ConnectorAdapter trait requirements. These layers isolate the complexities of the Discord API (REST and Gateway) from the internal Palyra routing logic.
LayerResponsibilityKey Entities
GatewayInbound message ingestion and real-time event processing.DiscordGatewayAdapter
TransportOutbound message delivery via Discord REST API.DiscordTransportAdapter
AdminManagement operations: health checks, message search, and deletions.DiscordAdminAdapter

Data Flow: Inbound Message Normalization

When a message is received via the Discord Gateway, it is normalized into a ConnectorMessageRecord before being routed to the palyrad control plane. Sources: crates/palyra-daemon/src/channels.rs#154-161, crates/palyra-connectors/src/providers/discord/adapter/gateway.rs#1-50

Bot Token & Identity Management

Discord connectors are identified by a unique connector_id derived from the Discord Account ID. Tokens are never stored in plaintext configuration; they are referenced via the Palyra Vault.

Message Mutation & Governance

Palyra implements a “Governance” layer for Discord actions like editing or deleting messages. This ensures that the agent’s destructive actions are gated by risk levels and windows of time.

Mutation Classification Logic

The function classify_discord_message_mutation_governance determines if an action requires human-in-the-loop approval based on the age of the message and the type of operation.
OperationWindowDefault Risk
Edit15 MinutesLow
ReactAdd6 HoursLow
DeleteImmediateHigh
Any> 24 HoursHigh (Approval Required)
Sources: crates/palyra-daemon/src/channels/discord.rs#155-190, crates/palyra-daemon/src/channels/discord.rs#191-205

Onboarding Flow

The Onboarding Wizard simplifies the process of connecting a new Discord bot to Palyra. It consists of a probe (preflight) phase and an apply phase.
  1. Probe: Validates the bot token, checks Discord API connectivity, and retrieves bot metadata (Username, Discriminator, Guilds).
  2. Apply: Persists the configuration to the daemon, initializes the Vault entry for the token, and enables the connector.

Onboarding Components

Sources: apps/web/src/features/channels/connectors/discord/components/DiscordOnboardingPanel.tsx#128-135, crates/palyra-daemon/src/transport/http/handlers/admin/channels/connectors/discord.rs#25-41, apps/web/src/consoleApi/channels/discord.ts#73-98

Management Interface

Web Console

The ChannelsSection provides a dedicated tab for Discord management, including:

CLI / Console Handlers

The daemon exposes HTTP handlers for both Admin and Console surfaces to manage Discord-specific lifecycle events:

Implementation Details: ChannelPlatform

The ChannelPlatform struct in the daemon acts as the orchestrator for all connectors, including Discord. Sources: crates/palyra-daemon/src/channels.rs#135-139, crates/palyra-daemon/src/channels/discord.rs#62-80