{"id":13407499,"url":"https://github.com/aichaos/rivescript-java","last_synced_at":"2026-01-10T12:58:51.658Z","repository":{"id":3066412,"uuid":"4089097","full_name":"aichaos/rivescript-java","owner":"aichaos","description":"A RiveScript interpreter for Java. RiveScript is a scripting language for chatterbots.","archived":false,"fork":false,"pushed_at":"2021-11-05T14:26:10.000Z","size":922,"stargazers_count":64,"open_issues_count":14,"forks_count":38,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-11-14T09:15:50.746Z","etag":null,"topics":["ai","artificial-intelligence","bots","chatbot","chatbots","rivescript"],"latest_commit_sha":null,"homepage":"http://www.rivescript.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aichaos.png","metadata":{"files":{"readme":"README.md","changelog":"Changes.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-04-20T17:06:46.000Z","updated_at":"2023-07-02T21:10:38.000Z","dependencies_parsed_at":"2022-08-27T07:11:09.962Z","dependency_job_id":null,"html_url":"https://github.com/aichaos/rivescript-java","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichaos%2Frivescript-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichaos%2Frivescript-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichaos%2Frivescript-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichaos%2Frivescript-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aichaos","download_url":"https://codeload.github.com/aichaos/rivescript-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243577807,"owners_count":20313703,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","bots","chatbot","chatbots","rivescript"],"created_at":"2024-07-30T20:00:41.207Z","updated_at":"2026-01-10T12:58:51.562Z","avatar_url":"https://github.com/aichaos.png","language":"Java","readme":"# RiveScript-Java\n\n[![Gitter](https://badges.gitter.im/aichaos/rivescript-java.svg)](https://gitter.im/aichaos/rivescript-java?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n[![Build Status](https://travis-ci.org/aichaos/rivescript-java.svg?branch=master)](https://travis-ci.org/aichaos/rivescript-java)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.rivescript/rivescript-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.rivescript/rivescript-core)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\n## Introduction\n\nThis is a RiveScript interpreter library written for the Java programming\nlanguage. RiveScript is a scripting language for chatterbots, making it easy\nto write trigger/response pairs for building up a bot's intelligence.\n\n## About RiveScript\n\nRiveScript is a scripting language for authoring chatbots. It has a very\nsimple syntax and is designed to be easy to read and fast to write.\n\nA simple example of what RiveScript looks like:\n\n```\n+ hello bot\n- Hello human.\n```\n\nThis matches a user's message of \"hello bot\" and would reply \"Hello human.\"\nOr for a slightly more complicated example:\n\n```\n+ my name is *\n* \u003cformal\u003e == \u003cbot name\u003e =\u003e \u003cset name=\u003cformal\u003e\u003eWow, we have the same name!\n* \u003cget name\u003e != undefined =\u003e \u003cset name=\u003cformal\u003e\u003eDid you change your name?\n- \u003cset name=\u003cformal\u003e\u003eNice to meet you, \u003cget name\u003e!\n```\n\nThe official website for RiveScript is https://www.rivescript.com/\n\nTo test drive RiveScript in your web browser, try the\n[RiveScript Playground](https://play.rivescript.com/).\n\n## Documentation\n\n* API Documentation: \u003chttp://www.javadoc.io/doc/com.rivescript/rivescript-core/\u003e\n* Working Draft: \u003chttp://www.rivescript.com/wd/RiveScript\u003e\n\nAlso check out the [**RiveScript Community Wiki**](https://github.com/aichaos/rivescript/wiki)\nfor common design patterns and tips \u0026 tricks for RiveScript.\n\n## Installation\n\nAdd the `rivescript-core` dependency to your project:\n\n_Maven_:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.rivescript\u003c/groupId\u003e\n  \u003cartifactId\u003erivescript-core\u003c/artifactId\u003e\n  \u003cversion\u003e0.10.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n_Gradle_:\n\n```groovy\ndependencies {\n    compile \"com.rivescript:rivescript-core:0.10.0\"\n}\n```\n\nIf you want to use RiveScript in a Spring Boot application see the \nSpring Boot Starter [section](#spring-boot-starter).\n\n## Usage\n\nWhen used as a library for writing your own chatbot, the synopsis is as follows:\n\n```java\nimport com.rivescript.Config;\nimport com.rivescript.RiveScript;\n\n// Create a new bot with the default settings.\nRiveScript bot = new RiveScript();\n\n// To enable UTF-8 mode, you'd have initialized the bot like:\nRiveScript bot = new RiveScript(Config.utf8());\n\n// Load a directory full of RiveScript documents (.rive files)\nbot.loadDirectory(\"./replies\");\n\n// Load an individual file.\nbot.LoadFile(\"./testsuite.rive\");\n\n// Sort the replies after loading them!\nbot.sortReplies();\n\n// Get a reply.\nString reply = bot.reply(\"user\", \"Hello bot!\");\n```\n\nThe `rivescript-core` distribution also includes an interactive shell for testing your\nRiveScript bot. Run it with the path to a folder on disk that contains your\nRiveScript documents. Example:\n\n    java com.rivescript.cmd.Shell [options] \u003c/path/to/documents\u003e\n\n## Configuration\n\nThe `com.rivescript.RiveScript` constructor takes an optional `Config` instance. \nHere is a full example with all the supported options. You only need to provide \nvalues for configuration options that are different to the defaults.\n\n```java\nRiveScript bot = new RiveScript(Config.newBuilder()\n        .throwExceptions(false)          // Whether exception throwing is enabled\n        .strict(true)                    // Whether strict syntax checking is enabled\n        .utf8(false)                     // Whether UTF-8 mode is enabled\n        .unicodePunctuation(\"[.,!?;:]\")  // The unicode punctuation pattern\n        .forceCase(false)                // Whether forcing triggers to lowercase is enabled\n        .concat(ConcatMode.NONE)         // The concat mode\n        .depth(50)                       // The recursion depth limit \n        .sessionManager(sessionManager)  // The session manager for user variables\n        .errorMessages(errors)           // Map of custom error messages\n        .build());\n```\n\nFor convenience, you can use shortcuts:\n\n```java\n// The default constructor uses a basic configuration.\nRiveScript bot = new RiveScript();\n\n// This is similar as:\nRiveScript bot = new RiveScript(Config.basic());\n\n// To use the basic configuration with UTF-8 mode enabled use: \nRiveScript bot = new RiveScript(Config.utf8());\n```\n\n## UTF-8 Support\n\nUTF-8 support in RiveScript is considered an experimental feature. It is\ndisabled by default.\n\nBy default (without UTF-8 mode on), triggers may only contain basic ASCII\ncharacters (no foreign characters), and the user's message is stripped of all\ncharacters except letters, numbers and spaces. This means that, for example,\nyou can't capture a user's e-mail address in a RiveScript reply, because of\nthe @ and . characters.\n\nWhen UTF-8 mode is enabled, these restrictions are lifted. Triggers are only\nlimited to not contain certain metacharacters like the backslash, and the\nuser's message is only stripped of backslashes and HTML angled brackets\n(to protect from obvious XSS if you use RiveScript in a web application).\nAdditionally, common punctuation characters are stripped out, with the default\nset being `[.,!?;:]`. This can be overridden by providing a new regexp\nstring to the `Config.Builder#unicodePunctuation()` method. Example:\n\n```java\n// Make a new bot with UTF-8 mode enabled and override the punctuation\ncharacters that get stripped from the user's message.\nRiveScript bot = new RiveScript(Config.Builder\n        .utf8()\n        .unicodePunctuation(\"[.,!?;:]\")\n        .build());\n```\n\nThe `\u003cstar\u003e` tags in RiveScript will capture the user's \"raw\" input, so you can\nwrite replies to get the user's e-mail address or store foreign characters in\ntheir name.\n\n## Spring Boot Starter\n\nAdd the `rivescript-spring-boot-starter` dependency to your project:\n\n_Maven_:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.rivescript\u003c/groupId\u003e\n  \u003cartifactId\u003erivescript-spring-boot-starter\u003c/artifactId\u003e\n  \u003cversion\u003e0.10.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n_Gradle_:\n\n```groovy\ndependencies {\n    compile \"com.rivescript:rivescript-spring-boot-starter:0.10.0\"\n}\n```\n\nThe starter will automatically add the `rivescript-core` dependency to your \nproject and trigger the auto configuration to create the `RiveScript` bot \ninstance.\n\nAlthough the auto configuration will use sensible defaults to create the bot \ninstance, the following properties can be specified inside your \n`application.properties`/`application.yml` file (or as command line switches)\nto customize the auto configuration behaviour:\n\n```txt\nrivescript:\n  enabled: true # Enable RiveScript for the application.\n  source-path: classpath:/rivescript/ # The comma-separated list of RiveScript source files and/or directories.\n  file-extensions: .rive, .rs # The comma-separated list of RiveScript file extensions to load.\n  throw-exceptions: false # Enable throw exceptions.\n  strict: true # Enable strict syntax checking.\n  utf8: false # Enable UTF-8 mode.\n  unicode-punctuation: [.,!?;:] # The unicode punctuation pattern (only used when UTF-8 mode is enabled).\n  force-case: false # Enable forcing triggers to lowercase.\n  concat: none # The concat mode (none|newline|space).\n  depth: 50 # The recursion depth limit.\n  error-messages: # The custom error message overrides. For instance `rivescript.error-messages.deepRecursion=Custom Deep Recursion Detected Message`\n  object-handlers: # The comma-separated list of object handler names to register (currently supported: `groovy`, `javascript`, `ruby`).\n```\n\nTo automatically register custom Java subroutines and/or non-default supported\nobject handlers in the created `RiveScript` bot instance, define appropriate \nbeans in your application context like:\n\n```java\n@Bean\npublic Map\u003cString, Subroutine\u003e subroutines() {\n    // The key is the name of the Java object macro to register.\n    Map\u003cString, Subroutine\u003e subroutines = new HashMap\u003c\u003e();\n    subroutines.put(\"subroutine1\", new Subroutine1());\n    subroutines.put(\"subroutine2\", new Subroutine2());\n    return subroutines;\n}\n\n@Bean\npublic Map\u003cString, ObjectHandler\u003e objectHandlers() {\n    // The key is the name of the programming language to register.\n    Map\u003cString, ObjectHandler\u003e objectHandlers = new HashMap\u003c\u003e();\n    objectHandlers.put(\"handler1\", new ObjectHandler1());\n    objectHandlers.put(\"handler2\", new ObjectHandler2());\n    return objectHandlers;\n}\n```\n\n## Building\n\nTo compile, test, build all jars and docs run:\n\n    ./gradlew build\n\nTo install all jars into your local Maven cache run:\n\n    ./gradlew install\n\n## Samples\n\nThe `/samples` folder contains various samples of Java RiveScript bot implementations.\n\n* `rsbot` - The `RSBot.java` is a simple implementation using the `com.rivescript.cmd.Shell`.\n\n  These commands may be used at your input prompt in RSBot:\n\n      /quit        - Quit the program\n      /dump topics - Dump the internal topic/trigger/reply struct (debugging)\n      /dump sorted - Dump the internal trigger sort buffers (debugging)\n      /last        - Print the last trigger you matched.\n\n  To execute `RSBot` to begin chatting with the demo Eliza-based run:\n\n      ./gradlew :rivescript-samples-rsbot:runBot --console plain\n\n* `spring-boot-starter-rsbot` - This example uses the RiveScript Spring Boot Starter to \n  auto-configure the `RiveScript` bot instance. \n  \n  To begin chatting with the demo bot run:\n  \n      ./gradlew :rivescript-samples-spring-boot-starter-rsbot:bootRun --console plain\n\n## Authors\n\n* Noah Petherbridge, https://www.kirsle.net/\n* Marcel Overdijk, https://twitter.com/marceloverdijk\n\n## License\n\n```\nThe MIT License (MIT)\n\nCopyright (c) 2016 the original author or authors.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","funding_links":[],"categories":["Tools"],"sub_categories":["Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faichaos%2Frivescript-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faichaos%2Frivescript-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faichaos%2Frivescript-java/lists"}