The RiveScript Playground

About the RiveScript Playground

The RiveScript Playground is a web service designed for developing, testing, and sharing RiveScript code snippets that run in the web browser. Unlike the RiveScript.com "Try Online" page, which was designed for absolute beginners to see how RiveScript works, the RiveScript Playground is designed for bot developers to tinker and share their RiveScript snippets.

Table of Contents


How to use the RiveScript Playground

The RiveScript Playground takes some design hints from Google's "Go Playground" and JS Fiddle.

To begin with, you should write or copy RiveScript code into the large text area on the left side of the page. When you're happy with the code, click on the "Run" button to test the code in your browser.

When the "Run" button is clicked, the code editor and certain options become disabled and the "send message" box in the lower right of the page is focused. You can then type a message to send to the bot and click the "Send" button, or hit Return on your keyboard, to see the bot's response.

To stop testing the bot and continue editing the code, click on the "Stop running" button at the top of the page. This switches the playground back into edit mode, allowing you to change the RiveScript source. In edit mode, you can not send a message to the bot again; you must click the "Run" button to test your new code.


How It Works

The RiveScript Playground utilizies the JavaScript version of RiveScript and does all of the processing on your local web browser. It's very similar to the RiveScript.com "Try Online" page in this regard.

You can write and test object macros written in either JavaScript or CoffeeScript. The user variable `origMessage` is available to JavaScript object macros if you want the user's raw, unformatted message without any substitutions or punctuation stripped.

When you click on the "Share" button, a copy of your RiveScript code is stored on the web server and is made available at a unique URL that you can then share with others.


About the Options (Debug, UTF-8 Mode)

The footer of the web page has checkboxes for various options you can enable. The meaning of the options are as follows:

Debug mode

This enables verbose debug logging from the bot. When this box is checked, a debug panel will open on the right side of the page below the Send Message text box, and any debugging output from the bot will be written into this panel (automatically scrolling down as more debug logs are added).

UTF-8 Mode

Unicode support in RiveScript is considered an experimental feature: it wasn't designed with Unicode in mind originally and it hasn't been extensively tested with Unicode.

By default UTF-8 mode is not enabled. The following restrictions are in place within RiveScript in its default configuration:

When you enable UTF-8 mode, these restrictions are loosened:

How to Share Code

One of the best features of the RiveScript Playground is the ability to share your code with others.

To share your code, your code must "compile" first (a RiveScript bot must be able to load your code without giving any error messages). If you are able to test your code by clicking the "Run" button, then it should be ready to share!

Simply click on the "Share" button at the top of the page. Your web browser will redirect to a unique URL that you can then copy and paste to share your code snippet with others.

The following reasonable restrictions are in place when sharing code:

  1. The overall size of your RiveScript source must not exceed 64 KB (that's 64,000 characters!)
  2. Shared code can not be deleted. Be careful about including sensitive information in your RiveScript snippets if you intend to share them. If you need a link to be taken down, contact the owner of the RiveScript Playground web service (if you're reading this on play.rivescript.com, then visit the RiveScript.com contact page to send your request). This web app is open source, so if you're using somebody else's instance of this app you need to get in touch with them instead.

Open Source

The RiveScript Playground is an open source web app released under the GNU General Public License, version 2.

You can view the source code at https://github.com/aichaos/rivescript-playground


Credits

This app was created by Noah Petherbridge, © 2016 — All rights reserved.

See also: