Write a conversation as an ordinary Ruby method. FlowChat runs it across stateless webhooks, on every messaging channel.
FlowChat is a Rails framework for conversational interfaces. A USSD or chat webhook has no memory of the last message; FlowChat replaces the hand-rolled state machine with a session and a replay engine, so the same flow runs on USSD, WhatsApp, Telegram, and HTTP, with per-platform rendering. Ruby 3.0+.
# Gemfile
gem "flow_chat"
bundle install
Set a cache for the session store, for example FlowChat::Config.cache = Rails.cache. No migrations, no generators.
A flow is a class of straight-line Ruby. Each screen is one step in the conversation:
class RegistrationFlow < FlowChat::Flow
def main_page
name = app.screen(:name) { |prompt| prompt.ask "What's your name?" }
email = app.screen(:email) do |prompt|
prompt.ask "Your email?", validate: ->(input) { "Invalid email" unless input.include?("@") }
end
app.say "Welcome #{name}!"
end
end
FlowChat re-runs this method from the top on every webhook. Each screen returns its stored answer when the session has one and re-prompts when it does not, so the method reads as a synchronous script even though each turn is a separate request.
if and case, not a state machine.ask, select, and yes?, with validation and transforms, and buttons or lists where the platform supports them.FlowChat::Input value object, and send media back with a single media: option.