Chat SDK for Ruby
Build bots that work across every chat platform. One API, normalized events, cards DSL, streaming โ write once, deploy to Slack, Teams, Google Chat, and more.
bot = ChatSDK::Chat.new(
user_name: "my-bot",
adapters: {
slack: ChatSDK::Slack::Adapter.new,
teams: ChatSDK::Teams::Adapter.new
},
state: ChatSDK::State::Redis.new
)bot.on_new_mention do |thread, message|
thread.subscribe
thread.post("Hi #{message.author.name}!")
end
bot.on_reaction(%w[thumbsup]) do |event|
event.thread.post("Thanks for the reaction!")
end
bot.on_slash_command("/weather") do |event|
forecast = Weather.fetch(event.text)
event.respond(forecast)
endthread.post(ChatSDK.card(title: "Deploy v2.1.0") do
text "Ready to ship to production"
fields do
field "Branch", "main"
field "Author", "@alice"
end
actions do
button "Approve", id: "deploy:approve", style: :primary
button "Cancel", id: "deploy:cancel", style: :danger
link_button "View diff", url: "https://github.com/..."
end
end)bot.on_new_mention do |thread, message|
# Fetch conversation history
history = ChatSDK::AI.to_ai_messages(thread.messages)
# Stream any LLM response back to chat
response = MyLLM.stream(messages: history)
thread.post_ai_stream(response)
endEverything you need
A complete framework for multi-platform chat bots โ from webhook ingestion to LLM streaming.
Normalized Events
Mentions, messages, reactions, actions, slash commands โ one handler signature across every platform.
๐Cards DSL
Ruby blocks that render as Slack Block Kit, Teams Adaptive Cards, or Google Chat Card V2.
๐คAI Ready
Convert chat history to LLM format. Provider-agnostic tool definitions with approval gates.
๐Streaming
Progressive message editing with throttled updates. Pass any Enumerable from your LLM.
๐Pluggable Adapters
Slack, Teams, Google Chat, Mattermost โ or build your own with shared contract specs.
๐Production State
Distributed locks, message dedup, TTL storage. Memory for dev, Redis for prod.
Three tiers of control
Use the normalized API or drop down when you need platform-specific access.
thread.post("hello")Cross-platform, zero config
adapter.post_message(...)Platform-aware, normalized format
client.chat_postMessage(...)Full native API access
Start building
Add to your Gemfile and go.