NAME

RiveScript - Rendering Intelligence Very Easily

SYNOPSIS

use RiveScript;

# Create a new RiveScript interpreter.
my $rs = new RiveScript;

# Load a directory of replies.
$rs->loadDirectory ("./replies");

# Load another file.
$rs->loadFile ("./more_replies.rive");

# Stream in some RiveScript code.
$rs->stream (q~
    + hello bot
    - Hello, human.
~);

# Sort all the loaded replies.
$rs->sortReplies;

# Chat with the bot.
while (1) {
    print "You> ";
    chomp (my $msg = <STDIN>);
    my $reply = $rs->reply ('localuser',$msg);
    print "Bot> $reply\n";
}

DESCRIPTION

RiveScript is a simple trigger/response language primarily used for the creation of chatting robots. It's designed to have an easy-to-learn syntax but provide a lot of power and flexibility. For more information, visit http://www.rivescript.com/

METHODS

GENERAL

LOADING AND PARSING

CONFIGURATION

INTERACTION

RIVESCRIPT

This interpreter tries its best to follow RiveScript standards. Currently it supports RiveScript 2.0 documents. A current copy of the RiveScript working draft is included with this package: see RiveScript::WD.

UTF-8 SUPPORT

Version 1.29+ adds experimental support for UTF-8 in RiveScript. It is not enabled by default. Enable it by passing a true value for the utf8 option in the constructor, or by using the --utf8 argument to the rivescript application.

By default (without UTF-8 mode on), triggers may only contain basic ASCII characters (no foreign characters), and the user's message is stripped of all characters except letters and spaces. This means that, for example, you can't capture a user's e-mail address in a RiveScript reply, because of the @ and . characters.

When UTF-8 mode is enabled, these restrictions are lifted. Triggers are only limited to not contain certain metacharacters like the backslash, and the user's message is only stripped of backslashes and HTML angled brackets (to prevent obvious XSS if you use RiveScript in a web application). The <star> tags in RiveScript will capture the user's "raw" input, so you can write replies to get the user's e-mail address or store foreign characters in their name.

CONSTANTS

This module can export some constants.

use RiveScript qw(:standard);

These constants include:

SEE ALSO

RiveScript::WD - A current snapshot of the Working Draft that defines the standards of RiveScript.

http://www.rivescript.com/ - The official homepage of RiveScript.

CHANGES

1.40  Oct 10 2015
- Fix the regexp used when matching optionals so that the triggers don't match
  on inputs where they shouldn't. (RiveScript-JS issue #46)

1.38  Jul 21 2015
- New algorithm for handling variable tags (<get>, <set>, <add>, <sub>,
  <mult>, <div>, <bot> and <env>) that allows for iterative nesting of these
  tags (for example, <set copy=<get orig>> will work now).
- Fix trigger sorting so that triggers with matching word counts are sorted
  by length descending.
- Add support for `! local concat` option to override concatenation mode
  (file scoped)
- Bugfix where Perl object macros set via `setSubroutine()` failed to load
  because they were missing a programming language internally.

1.36  Nov 26 2014
- Relicense under the MIT License.
- Strip punctuation from the bot's responses in UTF-8 mode to
  support compatibility with %Previous.
- Bugfix in deparse(): If you had two matching triggers, one with a %Previous
  and one without, you'd lose the data for one of them in the output.

1.34  Feb 26 2014
- Update README.md to include module documentation for github.
- Fixes to META.yml

1.32  Feb 24 2014
- Maintenance release to fix some errors per the CPANTS.
- Add license to Makefile.PL
- Make Makefile.PL not executable
- Make version numbers consistent

1.30  Nov 25 2013
- Added "TCP Mode" to the `rivescript` command so that it can listen on a
  socket instead of using standard input and output.
- Added a "--data" option to the `rivescript` command for providing JSON
  input as a command line argument instead of standard input.
- Added experimental UTF-8 support.
- Bugfix: don't use hacky ROT13-encoded placeholders for message
  substitutions... use a null character method instead. ;)
- Make .rive the default preferred file extension for RiveScript documents
  instead of .rs (which conflicts with the Rust programming language).
  Backwards compatibility remains to load .rs files, though.

See the Changes file for older change history.

AUTHOR

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

KEYWORDS

bot, chatbot, chatterbot, chatter bot, reply, replies, script, aiml, alpha

COPYRIGHT AND LICENSE

The MIT License (MIT)

Copyright (c) 2015 Noah Petherbridge

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.