Reusable primitives for Cloudflare Workers that need to:
- Forward content (an email, a notification, anything) to a Telegram chat or Discord channel via a bot.
- Route replies from those channels back to the original source (typically an email address).
The crate provides:
botrelay::telegram— a minimal Telegram Bot API client (sendMessage,setWebhook) and typedUpdateparsing for the webhook endpoint.botrelay::discord— a minimal Discord Bot API client (createMessagewith components), Ed25519 interaction-signature verification (WebCrypto), and typedInteractionparsing including modal submissions.botrelay::reply— a smallReplyContexttype (alias, original sender, subject) you store per forwarded message so the webhook handler can look it up and send a reply back through whatever channel the original content came from.
It doesn't own storage or the send-reply side — each consumer plugs in its own KV and outbound mechanism. That's the whole point: both cutout (email proxy) and concierge-worker (business messaging) embed the same primitives with different backends.
[dependencies]
botrelay = { git = "https://github.com/ananthb/botrelay-rs" }use botrelay::telegram::{TelegramBot, SendMessage};
let bot = TelegramBot::new(std::env::var("TELEGRAM_BOT_TOKEN").unwrap());
let msg = bot.send_message(SendMessage {
chat_id: "123456".into(),
text: "Hello!".into(),
..Default::default()
}).await?;See the crate docs for Discord and reply-routing.