Connector Architecture
The integration system is built upon a supervisor-adapter pattern. TheChannelPlatform in the daemon orchestrates various ConnectorAdapter implementations through a ConnectorSupervisor crates/palyra-daemon/src/channels.rs#106-110.
Data Flow: Inbound and Outbound
- Inbound: External events (messages, reactions) are captured by platform-specific adapters, normalized into
InboundMessageEventcrates/palyra-connectors/src/lib.rs#9, and routed to the daemon’s internal state machine via theConnectorRoutercrates/palyra-connectors/src/lib.rs#6. - Outbound: The daemon places messages into an outbox. The
ConnectorSupervisorpolls this outbox and dispatches requests to the appropriateConnectorAdapter::send_outboundimplementation crates/palyra-connectors/src/connectors/echo.rs#43-47.
Code Entity Relationship: Connectors
The following diagram illustrates how abstract connector concepts map to specific Rust entities. Connector System Mapping Sources: crates/palyra-daemon/src/channels.rs#106-132, crates/palyra-connectors/src/connectors/mod.rs#15-18, crates/palyra-connectors/src/lib.rs#2-12Discord Integration
Discord is the primary supported platform for Palyra. It utilizes thepalyra-connector-discord crate for its implementation.
Key Components
- Identity Normalization: Discord IDs are normalized to ensure consistency across the system crates/palyra-daemon/src/channels/discord.rs#13-16.
- Onboarding Probe: A preflight check mechanism verifies bot tokens and permissions before finalizing integration crates/palyra-daemon/src/transport/http/handlers/admin/channels/connectors/discord.rs#6-22.
- Permission Mapping: The system checks for specific Discord permissions such as
View Channels,Send Messages, andAttach Filesto ensure operational readiness crates/palyra-daemon/src/transport/http/handlers/admin/channels/mod.rs#93-104.
Discord Onboarding Flow
The onboarding process involves a preflight check (admin_discord_onboarding_probe_handler) followed by an application step (admin_discord_onboarding_apply_handler) crates/palyra-daemon/src/transport/http/handlers/admin/channels/connectors/discord.rs#6-40.
| Function | File | Purpose |
|---|---|---|
discord_connector_id | crates/palyra-daemon/src/channels/discord.rs | Generates a canonical ID for a Discord instance. |
probe_discord_bot_identity | crates/palyra-daemon/src/transport/http/handlers/admin/channels/mod.rs | Validates bot token and fetches metadata. |
apply_discord_onboarding | crates/palyra-daemon/src/transport/http/handlers/admin/channels/connectors/discord.rs | Persists configuration and enables the connector. |
Slack and Telegram Connectors
While defined in the codebase, the Slack and Telegram connectors are currently in a Deferred state crates/palyra-connectors/src/connectors/slack.rs#19, crates/palyra-connectors/src/connectors/telegram.rs#19.- SlackConnectorAdapter: Returns a permanent failure indicating it is unavailable in the current milestone crates/palyra-connectors/src/connectors/slack.rs#27-29.
- TelegramConnectorAdapter: Similarly returns a permanent failure crates/palyra-connectors/src/connectors/telegram.rs#27-29.
default_adapters() registry crates/palyra-connectors/src/connectors/mod.rs#12-18.
Webhook Integration
The Webhook system allows Palyra to receive asynchronous events from external providers. It is managed by theWebhookRegistry crates/palyra-daemon/src/webhooks.rs#107-111.
Webhook Lifecycle
Webhooks are registered with specific providers and secret tokens stored in theVault.
Webhook Registry Structure
Sources: crates/palyra-daemon/src/webhooks.rs#51-72, crates/palyra-daemon/src/webhooks.rs#107-111, crates/palyra-daemon/src/webhooks.rs#178-187
Implementation Details
- Persistence: Webhooks are stored in a TOML file (
webhooks.toml) crates/palyra-daemon/src/webhooks.rs#16. - Security: Supports signature verification and enforces payload size limits (default 64KB, max 1MB) crates/palyra-daemon/src/webhooks.rs#23-24.
- Validation: The
WebhookReadinesscheck ensures that the associated secret exists in the vault before the webhook is considered active crates/palyra-daemon/src/webhooks.rs#81-86.
CLI Management
Thepalyra CLI provides a webhooks command group for managing these integrations crates/palyra-cli/src/commands/channels/mod.rs#61-63.
| CLI Command | Description |
|---|---|
palyra webhooks add | Registers a new webhook provider and secret. |
palyra webhooks list | Lists all configured webhooks and their readiness status. |
palyra webhooks test | Simulates a webhook delivery to verify configuration. |