Skip to main content
The Connector Framework provides a standardized abstraction for integrating external messaging platforms (e.g., Discord, Slack, Telegram) into the Palyra ecosystem. It is primarily implemented across the palyra-connector-core and palyra-connectors crates, defining how the Palyra daemon communicates with third-party APIs while maintaining consistent message routing, delivery guarantees, and security policies.

Architecture Overview

The framework follows a supervisor-adapter pattern. The ConnectorSupervisor manages the lifecycle and state of various ConnectorAdapter implementations.

Code Entity Mapping

The following diagram maps high-level framework concepts to their specific implementation entities in the codebase.
ConceptCode EntityRole
Adapter InterfaceConnectorAdapterTrait defining how to send messages and report capabilities.
Lifecycle ManagerConnectorSupervisorOrchestrates starting, stopping, and monitoring connector instances.
PersistenceConnectorStoreTrait for persisting connector configuration and state.
Routing LogicConnectorRouterLogic for dispatching inbound/outbound messages to the correct adapter.
Outbound RequestOutboundMessageRequestStandardized payload for sending messages to external platforms.
Diagram: Connector Framework Entity Map Sources: crates/palyra-connector-core/src/lib.rs#1-23, crates/palyra-connectors/src/lib.rs#1-12

ConnectorAdapter Trait

The ConnectorAdapter is the core trait that every platform integration must implement. It defines the identity, availability, and message delivery capabilities of a connector.

Key Functions

Outbound Messaging and Delivery

When the system sends a message, it uses the OutboundMessageRequest struct, which contains the target conversation, text, and optional attachments crates/palyra-connector-core/src/protocol.rs#312-332. The result of a send operation is a DeliveryOutcome: Sources: crates/palyra-connector-core/src/supervisor.rs#30-65, crates/palyra-connector-core/src/protocol.rs#26-100

Connector Lifecycle and Supervision

The ConnectorSupervisor manages ConnectorInstanceRecord objects, which represent configured instances of a connector (e.g., a specific Discord bot).

ConnectorInstanceRecord

This record tracks the operational state of a connector instance:

Dead-Letter Handling

If a message fails delivery after the configured maximum attempts (defined in ChannelRouterConfig.max_retry_attempts crates/palyra-daemon/src/channel_router.rs#182-182), it is moved to a dead-letter state. The DeadLetterRecord captures the failed OutboundMessageRequest along with the final error reason for manual operator intervention crates/palyra-connector-core/src/storage.rs#104-115. Sources: crates/palyra-connector-core/src/storage.rs#24-50, crates/palyra-daemon/src/channel_router.rs#178-192

Data Flow: Message Delivery

The following diagram illustrates the flow of an outbound message from the Palyra CLI/Daemon through the framework to an external platform. Diagram: Outbound Message Data Flow Sources: crates/palyra-cli/src/commands/message.rs#47-81, crates/palyra-cli/src/client/message.rs#95-123, crates/palyra-daemon/src/channel_router.rs#215-235

EchoConnector (Testing)

The EchoConnectorAdapter is a reference implementation used for internal testing and validation of the framework crates/palyra-connectors/src/connectors/echo.rs#21-24.

Features

Sources: crates/palyra-connectors/src/connectors/echo.rs#1-92

Capabilities and Discovery

Connectors report their capabilities via the ConnectorCapabilitySet crates/palyra-connector-core/src/protocol.rs#205-215. This allows the UI and CLI to gracefully degrade or inform the user when certain actions (like editing or reacting to messages) are not supported by a specific platform. The CLI uses the capabilities command to query these from the daemon:
  1. Calls runtime.message_capabilities() crates/palyra-cli/src/commands/message.rs#35-44.
  2. The daemon responds with a MessageCapabilities struct crates/palyra-cli/src/client/message.rs#51-56.
  3. The CLI filters SUPPORTED_MESSAGE_ACTIONS and UNSUPPORTED_MESSAGE_ACTIONS to display status to the operator crates/palyra-cli/src/client/message.rs#16-25.
Sources: crates/palyra-cli/src/client/message.rs#43-56, crates/palyra-connector-core/src/protocol.rs#173-215