
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
FlowChat is a Rails framework for building sophisticated conversational workflows for USSD and WhatsApp messaging. Define multi-step conversations as Ruby classes with automatic session management, input validation, and cross-platform compatibility.
Add to your Gemfile:
gem 'flow_chat'
Then run:
bundle install
Create a flow in app/flow_chat/welcome_flow.rb
:
class WelcomeFlow < FlowChat::Flow
def main_page
name = app.screen(:name) do |prompt|
prompt.ask "What's your name?",
transform: ->(input) { input.strip.titleize }
end
language = app.screen(:language) do |prompt|
prompt.select "Choose language:", ["English", "French", "Spanish"]
end
app.say "Hello #{name}! Language set to #{language}."
end
end
Create a controller:
class UssdController < ApplicationController
skip_forgery_protection
def process_request
processor = FlowChat::Ussd::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
Add route in config/routes.rb
:
post 'ussd' => 'ussd#process_request'
Configure credentials in config/credentials.yml.enc
:
whatsapp:
access_token: "your_access_token"
phone_number_id: "your_phone_number_id"
verify_token: "your_verify_token"
app_secret: "your_app_secret"
Create a controller:
class WhatsappController < ApplicationController
skip_forgery_protection
def webhook
processor = FlowChat::Whatsapp::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
Add route:
match '/whatsapp/webhook', to: 'whatsapp#webhook', via: [:get, :post]
Flows define conversation logic. Screens collect user input with automatic validation:
class RegistrationFlow < FlowChat::Flow
def main_page
email = app.screen(:email) do |prompt|
prompt.ask "Enter email:",
validate: ->(input) { "Invalid email" unless input.include?("@") },
transform: ->(input) { input.downcase.strip }
end
confirmed = app.screen(:confirm) do |prompt|
prompt.yes? "Create account for #{email}?"
end
if confirmed
create_account(email)
app.say "Account created successfully!"
else
app.say "Registration cancelled."
end
end
end
prompt.ask()
- Free-form input with optional validationprompt.select()
- Force selection from predefined optionsprompt.yes?()
- Simple yes/no questionsSend messages outside of flows:
config = FlowChat::Whatsapp::Configuration.from_credentials
client = FlowChat::Whatsapp::Client.new(config)
# Send messages
client.send_text("+1234567890", "Hello!")
client.send_buttons("+1234567890", "Choose:", [
{ id: 'option1', title: 'Option 1' },
{ id: 'option2', title: 'Option 2' }
])
FlowChat includes a powerful built-in simulator with a modern web interface for testing both USSD and WhatsApp flows:
Features:
See the Testing Guide for complete setup instructions and testing strategies.
See the examples directory for complete implementations:
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that flow_chat demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.