FlowChat

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+.

Gem Version CI Ruby >= 3.0 License: MIT

Install

# Gemfile
gem "flow_chat"
bundle install

Set a cache for the session store, for example FlowChat::Config.cache = Rails.cache. No migrations, no generators.

The 30-second tour

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.

What you get

Documentation