Skip to main content

Crate bob_chat

Crate bob_chat 

Source
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

  • ChatAdapter trait — implement once per platform; covers posting, editing, deleting, reactions, ephemeral messages, DMs, modals, file uploads, and event streaming.
  • ChatBot orchestrator — register adapters and typed handlers, then call ChatBot::run to 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 messagesCardElement (buttons, sections, images, fields) with a plain-text fallback renderer.
  • ModalsModalElement with text inputs, selects, and radio selects.
  • EmojiWellKnownEmoji (35 variants) with platform-specific format maps and a custom-emoji escape hatch.
  • StreamingTextStream and fallback_stream for progressive message delivery via post-then-edit.
  • AttachmentsAttachment, FileUpload for file handling.
  • Error typesChatError with adapter, transport, rate-limit, auth, not-found, not-supported, and closed variants.

§Module Map

ModulePurpose
adapterChatAdapter trait definition
botChatBot orchestrator and handler registration
cardCard/rich-message element types
emojiEmoji types and well-known mappings
errorChatError enum
eventChatEvent variants and event structs
fileAttachment and file upload types
messageMessage types (postable, incoming, sent, ephemeral)
modalModal form dialog types
streamStreaming text types
threadThreadHandle 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 ChatAdapter trait 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§

ChannelMessage
Re-export channel types from bob_core for convenience. Incoming message from a channel to the agent.
ChannelOutput
Re-export channel types from bob_core for convenience. Outgoing agent response delivered back through the channel.

Enums§

ChannelError
Re-export channel types from bob_core for convenience. Errors that can occur during channel I/O.

Traits§

Channel
Re-export channel types from bob_core for convenience. Abstract channel for multi-endpoint agent interaction.