FlowChat is a powerful Rails framework for building sophisticated conversational interfaces across multiple platforms with a pluggable gateway architecture. Create interactive flows with menus, prompts, validation, media support, and session management using a unified, intuitive API that works across USSD, WhatsApp, Telegram, HTTP, and any custom platforms you build.
- π Unified API: Single codebase that works across all platforms
- π Pluggable Gateways: Extensible architecture supporting multiple backends per platform
- π± Multi-Platform: Out of the box support for USSD, WhatsApp, Telegram, HTTP, and more, with simulator for testing
- π― Screen-Based Navigation: Intuitive screen() method for building conversational flows
- πΎ Advanced Session Management: Flexible session boundaries and storage options
- π§ Middleware Architecture: Extensible middleware system for custom processing
- π¨ Rich Prompts: Support for text, media, selections, yes/no prompts, validation, and transformations
- π Built-in Instrumentation: Comprehensive logging and metrics collection
- π§ͺ Testing Support: Built-in simulator for development and testing
- π’ Multi-Tenancy: In-built support for custom configuration per tenant and URL-based isolation
- π Background Processing: Job queue support for WhatsApp messaging
Add FlowChat to your Rails application:
# Gemfile
gem 'flow_chat'bundle install# app/flow_chat/welcome_flow.rb
class WelcomeFlow < FlowChat::Flow
def main_page
name = app.screen(:name) do |prompt|
prompt.ask "Welcome! What's your name?",
transform: ->(input) { input.strip.titleize }
end
choice = app.screen(:main_menu) do |prompt|
prompt.select "Hi #{name}! Choose:", {
"1" => "Account Info",
"2" => "Make Payment",
"3" => "Support"
}
end
case choice
when "1"
show_account_info
when "2"
make_payment
when "3"
app.say "Call us: 123-456-7890"
end
end
# ... implement your flow methods
end# app/controllers/ussd_controller.rb
class UssdController < ApplicationController
skip_forgery_protection
def process_request
processor = FlowChat::Processor.new(self) do |config|
config.use_gateway FlowChat::Ussd::Gateway::Nalo
config.use_session_store FlowChat::Session::CacheSessionStore
end
processor.run WelcomeFlow, :main_page
end
end# app/controllers/whatsapp_controller.rb
class WhatsappController < ApplicationController
skip_forgery_protection
def webhook
processor = FlowChat::Processor.new(self) do |config|
config.use_gateway FlowChat::Whatsapp::Gateway::CloudApi
config.use_session_store FlowChat::Session::CacheSessionStore
end
processor.run WelcomeFlow, :main_page
end
end# app/controllers/telegram_controller.rb
class TelegramController < ApplicationController
skip_forgery_protection
def webhook
processor = FlowChat::Processor.new(self) do |config|
config.use_gateway FlowChat::Telegram::Gateway::BotApi
config.use_session_store FlowChat::Session::CacheSessionStore
end
processor.run WelcomeFlow, :main_page
end
end# app/controllers/api_controller.rb
class ApiController < ApplicationController
def chat
processor = FlowChat::Processor.new(self) do |config|
config.use_gateway FlowChat::Http::Gateway::Simple
config.use_session_store FlowChat::Session::CacheSessionStore
end
processor.run WelcomeFlow, :main_page
end
endSame WelcomeFlow works across ALL platforms!
FlowChat uses a composition-based architecture with these core components:
- Processor: Orchestrates request processing through middleware stack
- Gateway: Platform-specific request/response handling (Nalo, WhatsApp Cloud API)
- App: Unified application interface with screen-based navigation
- Session: Flexible session management with configurable boundaries
- Middleware: Extensible processing pipeline
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Gateway β -> β Session β -> β Custom β
β β β Middleware β β Middleware β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β
v
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Flow/Action β <- β Executor β <- β App β
β β β β β β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
FlowChat's power comes from its pluggable gateway system. Each platform can have multiple gateway implementations:
# Create your own SMS gateway
class MyCompany::Sms::Gateway::Twilio
def initialize(app, config)
@app = app
@config = config
end
def call(context)
# Parse Twilio webhook, set context values
context["request.msisdn"] = params["From"]
context["request.platform"] = :sms
context.input = params["Body"]
# Process through middleware
type, prompt, choices, media = @app.call(context)
# Send response via Twilio API
send_sms_response(prompt, to: context["request.msisdn"])
end
# Optional: Configure platform-specific middleware
def self.configure_middleware_stack(builder, custom_middleware)
builder.use MyCompany::Sms::MessageTransformMiddleware
builder.use custom_middleware
end
end
# Use your custom gateway
processor = FlowChat::Processor.new(self) do |config|
config.use_gateway MyCompany::Sms::Gateway::Twilio, sms_config
end- Getting Started Guide - Comprehensive setup and first app
- Architecture Overview - Deep dive into FlowChat's design
- Configuration - Complete configuration reference
- USSD Development - USSD-specific features and examples
- WhatsApp Development - WhatsApp Business API integration
- Telegram Development - Telegram Bot API integration
- HTTP Development π§ - API endpoints and webhooks
- Multi-Platform Apps π§ - Building unified experiences
- Gateway Development - Creating custom gateways and platforms
- Session Management π§ - Session boundaries and storage
- Middleware Development π§ - Creating custom middleware
- Testing & Simulation - Testing strategies and simulator usage
- Background Jobs π§ - Async processing for WhatsApp
- Instrumentation - Monitoring, logging, and error tracking
- Core API π§ - Processor, App, Flow classes
- Prompts & Validation π§ - Interactive prompts and validation
- Gateways π§ - Platform gateway interfaces
- Session Stores π§ - Session storage options
Build conversational flows using the intuitive screen() method:
def registration_flow
# Each screen automatically handles state and navigation
email = app.screen(:email) do |prompt|
prompt.ask "Enter your email:",
validate: ->(input) {
"Invalid email" unless input.include?("@")
}
end
name = app.screen(:name) do |prompt|
prompt.ask "Enter your full name:",
transform: ->(input) { input.strip.titleize }
end
# Confirmation screen with rich prompts
confirmed = app.screen(:confirm) do |prompt|
prompt.yes? "Confirm registration for #{name} (#{email})?"
end
if confirmed
create_user(name, email)
app.say "Welcome #{name}! Registration complete."
else
app.say "Registration cancelled."
end
endWrite once, run everywhere:
class MenuFlow < FlowChat::Flow
def main_menu
choice = app.screen(:menu) do |prompt|
prompt.select "Choose an option:", {
"info" => "π Information", # Rich for WhatsApp
"help" => "β Help", # Falls back to text for USSD
"exit" => "π Exit"
}
end
# Same logic works on both platforms
handle_choice(choice)
end
endConfigure sessions for your use case:
# Durable sessions across timeouts
processor = FlowChat::Processor.new(self) do |config|
config.use_durable_sessions # Uses user identifier (usually phone number) for session ID
end
# Cross-platform sessions
processor = FlowChat::Processor.new(self) do |config|
config.use_cross_platform_sessions # Share sessions between platforms (e.g. USSD & WhatsApp)
end
# URL-based multi-tenancy
processor = FlowChat::Processor.new(self) do |config|
config.use_url_isolation # tenant1.app.com vs tenant2.app.com
end| Platform | Available Gateways | Features |
|---|---|---|
| USSD | Nalo β
, Custom |
Pagination, choice mapping, session management |
CloudApi β
, Custom |
Rich media, buttons, lists, templates, background jobs | |
| Telegram | BotApi β
, Custom |
Inline keyboards, rich media, callbacks, group chats |
| HTTP | Simple β
, Custom |
Testing, webhooks, API endpoints, JSON responses |
| Simulator | Built-in β | Development testing, conversation replay, flow debugging |
| Custom | Your Gateway | Implement any platform by creating a gateway class |
β = Included with FlowChat
# Built-in gateways (included with FlowChat)
config.use_gateway FlowChat::Ussd::Gateway::Nalo
config.use_gateway FlowChat::Whatsapp::Gateway::CloudApi, whatsapp_config
config.use_gateway FlowChat::Telegram::Gateway::BotApi, telegram_config
config.use_gateway FlowChat::Http::Gateway::Simple
# Custom gateway examples (you would build these)
config.use_gateway MyCompany::Sms::Gateway::Twilio, twilio_config
config.use_gateway MyCompany::Slack::Gateway::BoltJS, slack_config- USSD Banking App π§ - Complete banking flow with validation
- WhatsApp Customer Service π§ - Media support and templates
- HTTP API Chatbot π§ - JSON API for web/mobile integration
- Multi-Platform E-commerce π§ - Unified shopping across USSD, WhatsApp, and HTTP
- Multi-Tenant SaaS π§ - URL-based tenant isolation
- Custom Gateway Example π§ - Building a Telegram gateway
FlowChat includes a built-in simulator interface for easy development and testing:
# Simulator is automatically enabled in development
processor = FlowChat::Processor.new(self) do |config|
config.use_gateway FlowChat::Ussd::Gateway::Nalo # or any gateway
end
# Explicitly control simulator mode if needed
processor = FlowChat::Processor.new(self, enable_simulator: false) do |config|
# Disable simulator even in development
endThe simulator provides a web interface for testing your flows during development. It works the same regardless of which gateway you're using, allowing you to test your conversational logic before deploying to actual platforms.
Learn more: Testing & Simulation Guide
We welcome contributions!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
FlowChat is released under the MIT License.
- Documentation: Comprehensive guides in the docs/ directory
- Issues: GitHub Issues
- Discussions: GitHub Discussions
FlowChat is developed by Radioactive Labs. Commercial support, custom development, and consulting services are available.
Ready to build amazing conversational experiences? Check out the Getting Started Guide to create your first FlowChat application.