Skip to main content
The Channel Platform is the subsystem responsible for bridging the Palyra daemon with external communication platforms (Discord, Slack, Telegram) and ingesting data via generic webhooks. It manages the lifecycle of connectors, handles asynchronous message routing, maintains dead-letter queues for failed deliveries, and enforces security policies for inbound and outbound traffic.

Channel Platform Architecture

The ChannelPlatform serves as the high-level coordinator within the daemon crates/palyra-daemon/src/channels.rs#106-110. It encapsulates the ConnectorSupervisor, which manages individual connector instances and their associated storage.

Data Flow: Inbound & Outbound

The system uses a decoupled architecture where the daemon communicates with connectors via a ConnectorRouter implementation. For the daemon, this is typically the GrpcChannelRouter crates/palyra-daemon/src/channels.rs#125-126.
  1. Inbound Flow: A platform adapter (e.g., DiscordConnectorAdapter) receives a message, wraps it in an InboundMessageEvent, and submits it to the ConnectorSupervisor. The supervisor then uses the ConnectorRouter to dispatch it into the daemon’s internal run orchestration pipeline.
  2. Outbound Flow: When an agent produces a response, the daemon enqueues an OutboundMessageRequest crates/palyra-connectors/src/lib.rs#10. The supervisor picks this up, identifies the correct adapter, and attempts delivery.

Connector Management & Supervision

The ConnectorSupervisor is responsible for the health and persistence of all connectors crates/palyra-connector-core/src/supervisor.rs. It uses a SQLite-backed ConnectorStore to persist instance specifications and message queues crates/palyra-daemon/src/channels.rs#119.

System Entity Mapping: Connector Supervision

ComponentCode EntityResponsibility
SupervisorConnectorSupervisorManages adapter lifecycles and task scheduling.
StoreConnectorStorePersists ConnectorInstanceRecord and OutboxEntryRecord.
AdapterConnectorAdapterTrait for platform-specific logic (Discord, Echo, etc.).
RouterConnectorRouterInterface for dispatching inbound messages to the daemon.
Sources: crates/palyra-daemon/src/channels.rs#106-132, crates/palyra-connectors/src/lib.rs#2-12

Connectors & Adapters

Palyra supports multiple connector types, categorized by their ConnectorAvailability crates/palyra-connectors/src/lib.rs#5.

Discord Connector

The Discord connector is the primary production-ready channel. It handles:

Reliability: Dead-Letter Queues & Retries

The supervisor maintains an outbox for each connector. If a delivery fails, the system classifies the error via RetryClass crates/palyra-connectors/src/lib.rs#11: Sources: crates/palyra-connectors/src/connectors/mod.rs#16-18, crates/palyra-daemon/src/transport/http/handlers/admin/channels/mod.rs#113-147

Channel Routing & Security

The ChannelRouter manages how inbound messages are mapped to agent sessions and enforces access control crates/palyra-daemon/src/channel_router.rs#178-192.

Routing Rules

Each channel can be configured with specific ChannelRoutingRule parameters:

Direct Message (DM) Pairing

To prevent spam and unauthorized access via DMs, Palyra implements a DirectMessagePolicy crates/palyra-daemon/src/channel_router.rs#57-61:
  1. Deny: All DMs are ignored.
  2. Allow: All DMs are processed.
  3. Pairing: Requires a PairingCodeRecord. Users must provide a valid code to establish a PairingGrantRecord crates/palyra-daemon/src/channel_router.rs#104-110.

Code Logic: DM Pairing Flow

Sources: crates/palyra-daemon/src/channel_router.rs#84-158

Webhook Ingestion

The WebhookRegistry manages generic HTTP callback integrations crates/palyra-daemon/src/webhooks.rs#107-111. Webhooks allow external systems to push data into Palyra’s event stream.

Configuration & Security

Implementation Details

The WebhookRegistry provides a list_views method to return WebhookIntegrationView objects for the UI, ensuring that readiness is checked (verifying if the secret exists in the vault) before reporting the integration as “Ready” crates/palyra-daemon/src/webhooks.rs:189-216, 75-86. Sources: crates/palyra-daemon/src/webhooks.rs#52-72, crates/palyra-daemon/src/webhooks.rs#178-187

Administrative Interface

The daemon exposes HTTP handlers for managing the channel platform under the /admin/v1/channels and /admin/v1/webhooks paths.

Channel Operations Snapshot

The build_channel_operations_snapshot function aggregates real-time metrics for the UI crates/palyra-daemon/src/transport/http/handlers/admin/channels/mod.rs#55-61:

CLI Commands

The palyra channels and palyra webhooks command families provide terminal access to these features crates/palyra-cli/src/commands/channels/mod.rs#61-63. Sources: crates/palyra-daemon/src/transport/http/handlers/admin/channels/mod.rs#29-53, crates/palyra-cli/src/commands/channels/mod.rs#206-224