Skip to main content
The Connector Framework provides a standardized abstraction for Palyra to interact with external messaging platforms such as Discord, Slack, and Telegram. It is implemented primarily across the palyra-connector-core and palyra-connectors crates. The system decouples the daemon’s internal message routing logic from the platform-specific API implementations (adapters) and provides a robust supervisor to manage connector lifecycles, persistence, and reliability.

Architecture Overview

The framework follows a supervisor-adapter pattern. The ConnectorSupervisor acts as the central management node, overseeing multiple ConnectorInstanceRecord entries stored in a SQLite database.

Key Components

ComponentRoleLocation
ConnectorSupervisorManages lifecycle, outbox processing, and adapter dispatch.crates/palyra-connector-core/src/supervisor.rs#18-22
ConnectorAdapterTrait for platform-specific implementations (e.g., Discord, Echo).crates/palyra-connector-core/src/supervisor.rs#18-22
ConnectorStoreSQLite-backed persistence for connector specs, state, and outbox.crates/palyra-connector-core/src/storage.rs#14-17
ConnectorRouterInterface used by the supervisor to push inbound events to the daemon.crates/palyra-connector-core/src/supervisor.rs#18-22

Data Flow: Inbound and Outbound

The following diagram illustrates the relationship between code entities during message transit. Connector Message Pipeline Sources: crates/palyra-connector-core/src/supervisor.rs#18-22, crates/palyra-daemon/src/channels.rs#106-137

Connector Protocol

The framework uses a standardized protocol for message envelopes to ensure consistency across different platforms.

Message Envelopes

Outbound messages are encapsulated in OutboundMessageRequest crates/palyra-connector-core/src/protocol.rs#6-13. Key fields include:
  • envelope_id: A unique ULID for idempotency.
  • conversation_id: The platform-specific channel or DM identifier.
  • text: The raw message content.
  • attachments: A list of OutboundAttachment refs.
  • a2ui_update: Optional OutboundA2uiUpdate for dynamic UI patches.

Connector Capabilities

Each connector reports its capabilities via ConnectorCapabilitySet crates/palyra-connector-core/src/protocol.rs#205-215. This allows the CLI and Web Console to determine if features like threading, reactions, or message editing are supported for a specific instance crates/palyra-cli/src/client/message.rs#51-56.

ConnectorSupervisor Lifecycle

The ConnectorSupervisor is responsible for the “Ground Truth” state of all connectors.
  1. Initialization: The ChannelPlatform in the daemon initializes the supervisor with a ConnectorStore and a set of ConnectorAdapter implementations crates/palyra-daemon/src/channels.rs#113-132.
  2. Registration: Connectors are registered using a ConnectorInstanceSpec crates/palyra-connector-core/src/protocol.rs#6-13.
  3. Liveness Monitoring: The supervisor tracks ConnectorLiveness (Stopped, Running, Restarting, Crashed) and ConnectorReadiness (Ready, MissingCredential, etc.) crates/palyra-connector-core/src/protocol.rs#110-147.
  4. Outbox Processing: The supervisor maintains an internal outbox in SQLite. If a delivery fails with a RetryClass::ConnectorRestarting error, the supervisor manages the backoff and retry logic crates/palyra-connector-core/src/protocol.rs#6-13.
Lifecycle State Transitions Sources: crates/palyra-connector-core/src/protocol.rs#142-157

Echo Connector and Simulator

For testing and development, the palyra-connectors crate includes an EchoConnectorAdapter.

Echo Connector

The EchoConnectorAdapter crates/palyra-connectors/src/connectors/echo.rs#21-24 provides a loopback mechanism:

CLI Simulator Harness

The Palyra CLI provides commands to interact with connectors directly for diagnostics:

Implementation Details

Storage Schema

The ConnectorStore manages the following entities in SQLite:

Connector Availability Tiers

Connectors are classified by their implementation maturity crates/palyra-connector-core/src/protocol.rs#75-79:
  1. Supported: Fully functional (e.g., Discord).
  2. InternalTestOnly: Used for CI/CD and local dev (e.g., Echo).
  3. Deferred: Planned but not yet implemented (e.g., Slack, Telegram) crates/palyra-connectors/src/connectors/slack.rs#19-19.
Sources: