Expand description
§Bob Chat
Platform-agnostic chat abstractions for the Bob Agent Framework.
§Overview
bob-chat provides the structured chat layer that sits between chat
platform APIs (Slack, Discord, Telegram, CLI, etc.) and the agent loop.
It ships a trait-based adapter model, a central event-driven orchestrator
(ChatBot), and rich message primitives.
§Features
ChatAdaptertrait — implement once per platform; covers posting, editing, deleting, reactions, ephemeral messages, DMs, modals, file uploads, and event streaming.ChatBotorchestrator — register adapters and typed handlers, then callChatBot::runto poll all adapters concurrently and dispatch events.ChatEvent— seven event variants (Message, Mention, Reaction, Action, SlashCommand, ModalSubmit, ModalClose).ThreadHandle— scoped handle passed to handlers for replying, subscribing to threads, and managing ephemeral messages with DM fallback.- Rich messages —
CardElement(buttons, sections, images, fields) with a plain-text fallback renderer. - Modals —
ModalElementwith text inputs, selects, and radio selects. - Emoji —
WellKnownEmoji(35 variants) with platform-specific format maps and a custom-emoji escape hatch. - Streaming —
TextStreamandfallback_streamfor progressive message delivery via post-then-edit. - Attachments —
Attachment,FileUploadfor file handling. - Error types —
ChatErrorwith adapter, transport, rate-limit, auth, not-found, not-supported, and closed variants.
§Module Map
| Module | Purpose |
|---|---|
adapter | ChatAdapter trait definition |
bot | ChatBot orchestrator and handler registration |
card | Card/rich-message element types |
emoji | Emoji types and well-known mappings |
error | ChatError enum |
event | ChatEvent variants and event structs |
file | Attachment and file upload types |
message | Message types (postable, incoming, sent, ephemeral) |
modal | Modal form dialog types |
stream | Streaming text types |
thread | ThreadHandle for in-handler interaction |
§Quick Start
use bob_chat::{ChatBot, ChatBotConfig};
let mut bot = ChatBot::new(ChatBotConfig::default());
// Register a mention handler.
bot.on_mention(|thread, message| async move {
let _ = thread.post("Hello! You said: ".to_owned() + &message.text).await;
});
// Add platform adapters and run.
// bot.add_adapter(my_slack_adapter);
// bot.run().await?;Re-exports§
pub use adapter::ChatAdapter;pub use bot::ChatBot;pub use bot::ChatBotConfig;pub use card::ActionElement;pub use card::ActionsElement;pub use card::ButtonElement;pub use card::ButtonStyle;pub use card::CardChild;pub use card::CardElement;pub use card::FieldElement;pub use card::FieldsElement;pub use card::ImageElement;pub use card::SectionElement;pub use card::TextElement;pub use card::TextStyle;pub use card::render_card_as_text;pub use emoji::DefaultEmojiResolver;pub use emoji::EmojiFormats;pub use emoji::EmojiResolver;pub use emoji::EmojiValue;pub use emoji::WellKnownEmoji;pub use error::ChatError;pub use event::ActionEvent;pub use event::ChatEvent;pub use event::ModalCloseEvent;pub use event::ModalSubmitEvent;pub use event::ReactionEvent;pub use event::SlashCommandEvent;pub use file::Attachment;pub use file::AttachmentKind;pub use file::FileUpload;pub use message::AdapterPostableMessage;pub use message::Author;pub use message::EphemeralMessage;pub use message::IncomingMessage;pub use message::PostableMessage;pub use message::SentMessage;pub use modal::ModalChild;pub use modal::ModalElement;pub use modal::RadioSelectElement;pub use modal::SelectElement;pub use modal::SelectOption;pub use modal::TextInputElement;pub use stream::StreamOptions;pub use stream::TextStream;pub use stream::fallback_stream;pub use thread::ThreadHandle;
Modules§
- adapter
- The core
ChatAdaptertrait that each chat platform implements. - bot
- Central orchestrator for chat event handling.
- card
- Card element types and builders for interactive rich messages.
- emoji
- Emoji types with well-known mappings and custom emoji support.
- error
- Chat-specific error types.
- event
- Chat event types for adapter-to-bot communication.
- file
- File attachment and upload types.
- message
- Core message types for the chat channel layer.
- modal
- Modal element types and builders for interactive form dialogs.
- stream
- Streaming text types for progressive message delivery.
- thread
- Thread handle for interacting with a conversation thread.
Structs§
- Channel
Message - Re-export channel types from
bob_corefor convenience. Incoming message from a channel to the agent. - Channel
Output - Re-export channel types from
bob_corefor convenience. Outgoing agent response delivered back through the channel.
Enums§
- Channel
Error - Re-export channel types from
bob_corefor convenience. Errors that can occur during channel I/O.
Traits§
- Channel
- Re-export channel types from
bob_corefor convenience. Abstract channel for multi-endpoint agent interaction.