Expand description
§ralph-telegram
Telegram integration for human-in-the-loop orchestration in Ralph.
This crate provides bidirectional communication between AI agents and humans during orchestration loops via Telegram:
- AI → Human: Agents emit
human.interactevents; the bot sends questions to Telegram - Human → AI: Humans reply or send proactive guidance via Telegram messages
§Key Components
StateManager— Persists chat ID, pending questions, and reply routingMessageHandler— Processes incoming messages and writes events to JSONLTelegramService— Lifecycle management for the bot within the event loop- [
error] — Error types for startup, send, and receive failures
Re-exports§
pub use daemon::TelegramDaemon;
Modules§
Structs§
- Checkin
Context - Additional context for enhanced check-in messages.
- Message
Handler - Processes incoming Telegram messages and writes events to the correct loop’s events.jsonl.
- Pending
Question - A question sent to the human that is awaiting a response.
- State
Manager - Manages persistence of Telegram bot state to disk.
- Telegram
Bot - Wraps a
teloxide::Botand provides formatted messaging for Ralph. - Telegram
Service - Coordinates the Telegram bot lifecycle with the Ralph event loop.
- Telegram
State - Persistent state for the Telegram bot, stored at
.ralph/telegram-state.json.
Enums§
- Telegram
Error - Errors that can occur during Telegram bot operations.
Constants§
- BASE_
RETRY_ DELAY - Base delay for exponential backoff (1 second).
- MAX_
SEND_ RETRIES - Maximum number of retry attempts for sending messages.
Traits§
- BotApi
- Trait abstracting Telegram bot operations for testability.
Functions§
- escape_
html - Escape special HTML characters for Telegram’s HTML parse mode.
- markdown_
to_ telegram_ html - Convert Ralph-generated markdown to Telegram HTML.
- retry_
with_ backoff - Execute a fallible send operation with exponential backoff retry.
Type Aliases§
- Telegram
Result - Result type alias for telegram operations.