Jido.Chat
is a structured chat room system built in Elixir that enables seamless interaction between human users and AI agents. Built on OTP principles, it provides a robust foundation for real-time chat applications with intelligent participants.
- Flexible Room Creation: Create isolated chat rooms with custom configurations
- Dynamic Supervision: OTP-based room lifecycle management
- Thread Support: Built-in conversation threading capabilities
- Multi-Type Support: Handle both human and AI agent participants
- Role-Based Access: Define participant roles and permissions
- Real-Time Status: Track participant presence and activity
- Rich Message Types: Support for text, system, and rich content messages
- @mentions: Built-in mention parsing and handling
- Thread Management: Organize conversations with threading
- Event-Driven Architecture: Built on Jido's signal system
- Extensible Channel System: Pluggable interfaces for different protocols
- Customizable Behaviors: Override defaults with custom implementations
Add jido_chat
to your dependencies in mix.exs
:
def deps do
[
{:jido_chat, "~> 0.5.0"}
]
end
# Start a basic chat room
{:ok, pid} = Jido.Chat.create_room("project-bus", "main-room")
# Access an existing room
{:ok, pid} = Jido.Chat.get_room("project-bus", "main-room")
# Create participants
{:ok, human} = Jido.Chat.Participant.new("user123", :human,
display_name: "Alice")
{:ok, agent} = Jido.Chat.Participant.new("agent456", :agent,
display_name: "Support Bot")
# Add to room
:ok = Jido.Chat.join_room("project-bus", "main-room", human)
:ok = Jido.Chat.join_room("project-bus", "main-room", agent)
# Send a basic message
{:ok, msg} = Jido.Chat.post_message("project-bus", "main-room",
"user123", "Hello @Support Bot!")
# Send a rich message
{:ok, msg} = Jido.Chat.post_message("project-bus", "main-room",
"agent456",
"Here's a chart",
type: :rich,
payload: %{
type: "chart",
data: [1, 2, 3]
}
)
# Get all messages
{:ok, messages} = Jido.Chat.get_messages("project-bus", "main-room")
# Get thread messages
{:ok, thread} = Jido.Chat.get_thread("project-bus", "main-room", thread_id)
defmodule MyApp.CustomRoom do
use Jido.Chat.Room
@impl true
def handle_message(room, message) do
# Custom message handling logic
{:ok, message}
end
@impl true
def handle_join(room, participant) do
# Custom join logic
{:ok, participant}
end
end
defmodule MyApp.WebSocket.Channel do
@behaviour Jido.Chat.Channel
@impl true
def send_message(room_id, sender_id, content, opts) do
# Implement WebSocket message sending
end
@impl true
def handle_incoming(room_id, message) do
# Handle incoming WebSocket messages
end
end
The package includes a comprehensive test suite:
# Run tests
mix test
# Run tests with coverage
mix test --cover
# Run full quality checks
mix quality
Jido.Chat uses a structured supervision tree for resilience:
Jido.Chat.Application.Supervisor
├── Registry
└── Jido.Chat.Supervisor
├── Room 1
├── Room 2
└── Room N
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
See CONTRIBUTING.md for detailed guidelines.
- HexDocs - API documentation
- Architecture Guide - System design
This project is licensed under the Apache License 2.0 - see LICENSE.md