NAME

rivescript - A command line frontend to the Perl RiveScript interpreter.


SYNOPSIS

  $ rivescript [options] [path to RiveScript documents]


DESCRIPTION

This is a command line front-end to the RiveScript interpreter. This script obsoletes the old rsdemo, and can also be used non-interactively by third party programs. To that end, it supports a variety of input/output and session handling methods.

If no RiveScript document path is given, it will default to the example brain that ships with the RiveScript module, which is based on the Eliza bot.


OPTIONS

--debug, -d

Enables debug mode. This will print all debug data from RiveScript to your terminal. If you'd like it to log to a file instead, use the --log option instead of --debug.

--log FILE

Enables debug mode and prints the debug output to FILE instead of to your terminal.

--json, -j

Runs rivescript in JSON mode, for running the script in a non-interactive way (for example, to use RiveScript in a programming language that doesn't have a native RiveScript library). See JSON Mode for details.

--strict, --nostrict

Enables strict mode for the RiveScript parser. It's enabled by default, use --nostrict to disable it. Strict mode prevents the parser from continuing when it finds a syntax error in the RiveScript documents.

--depth=50

Override the default recursion depth limit. This controls how many times RiveScript will recursively follow redirects to other replies. The default is 50.

--help

Displays this documentation in your terminal.


USAGE

Interactive Mode

This is the default mode used when you run rivescript without specifying another mode. This mode behaves similarly to the old rsdemo script and lets you chat one-on-one with your RiveScript bot.

This mode can be used to test your RiveScript bot. Example:

  $ rivescript /path/to/rs/files

JSON Mode

This mode should be used when calling from a third party program. In this mode, data that enters and leaves the script are encoded in JSON.

Example:

  $ rivescript --json /path/to/rs/files

The format for incoming JSON data is as follows:

  {
    "username": "localuser",
    "message":  "Hello bot!",
    "vars": {
      "name": "Aiden"
    }
  }

Here, username is a unique name for the user, message is their message to the bot, and vars is a hash of any user variables your program might be keeping track of (such as the user's name and age).

The response from rivescript will look like the following:

  {
    "status": "ok",
    "reply":  "Hello, human!",
    "vars": {
      "name": "Aiden"
    }
  }

Here, status will be "ok" or "error", reply is the bot's response to your message, and vars is a hash of the current variables for the user (so that your program can save them somewhere).

End of Message

There are two ways you can use the JSON mode: "fire and forget," or keep a stateful session open.

In "fire and forget," you open the program, print your JSON input and send the EOF signal, and then rivescript sends you the JSON response and exits.

In a stateful session mode, you must send the text __END__ on a line by itself after you finish sending your JSON data. Then rivescript will process it, return its JSON response and then also say __END__ at the end.

Example:

  {
    "username": "localuser",
    "message": "Hello bot!",
    "vars": {}
  }
  __END__

And the response:

  {
    "status": "ok",
    "reply": "Hello, human!",
    "vars": {}
  }
  __END__

This way you can reuse the same pipe to send and receive multiple messages.


SEE ALSO

RiveScript, the Perl RiveScript interpreter.


AUTHOR

Noah Petherbridge, http://www.kirsle.net


LICENSE

  RiveScript - Rendering Intelligence Very Easily
  Copyright (C) 2008  Casey Kirsle
  
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA