RiveScript-rb

A RiveScript interpreter for Ruby 3.3+.

Maintained at jvmlab.org by Byte (byte@jvmlab.org). Derived from the MIT-licensed rivescript-js implementation.

Requirements

  • Ruby >= 3.3.0 (developed on 3.3.8)

In an application (Bundler)

Add to your Gemfile:

gem "rivescript", "~> 0.1.2"

Then:

bundle install

Use it only through Bundler:

bundle exec ruby app.rb
bundle exec riveshell

System / user gem (CLI and scripts)

gem install rivescript

Put Ruby gem binaries on your PATH if needed:

export PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"

Then:

riveshell

From GitHub or this repository

# Gemfile (development / unreleased tip)
gem "rivescript",
    git: "https://github.com/LilOleByte/rivescript-rb.git",
    tag: "v0.1.2"
bundle install
bundle exec rake package          # builds pkg/rivescript-0.1.2.gem + verifies contents
gem install --user-install pkg/rivescript-0.1.2.gem

Usage

require "rivescript"

bot = RiveScript.new
bot.load_directory(RiveScript.brain_path)  # bundled sample brain
# or: bot.load_directory("./my-custom-brain")
bot.sort_replies

puts bot.reply("localuser", "Hello bot")

Load from a string:

bot = RiveScript.new
bot.stream(<<~RIVE)
  + hello bot
  - Hello, human!
RIVE
bot.sort_replies
puts bot.reply("user", "hello bot")

Interactive shell

bundle exec riveshell                 # Bundler apps
riveshell                             # after gem install
riveshell /path/to/custom-brain       # your own replies

Options: --debug, --utf8.

Object macros (Ruby)

> object setname ruby
  return args[0]
< object

+ my name is *
- <set name=<call>setname <star></call>>Nice to meet you, <get name>.

Object macros run real Ruby. Only load brains you trust. Disable with RiveScript.new(enable_object_macros: false).

Develop / test this gem

bundle install
bundle exec rake test
bundle exec rake package

License

MIT — see LICENSE.

Original RiveScript copyright (c) Noah Petherbridge / AiChaos. Ruby port copyright (c) 2026 Byte <byte@jvmlab.org> (jvmlab.org).