JiveScript
Simple & very lightweight chatbot framework. Trigger syntax heavily inspired by the lovely RiveScript.
Installation
Install via npm
:
npm install jivescript
Alternatively, install via yarn
:
yarn add jivescript
Usage
// Your bot's brain: ; const jive = ; // Use `hear()` to supply a pattern (or an array of them) which the bot can// match against what it is told.jive; // Nest more triggers in order to match those ones first so the bot can follow a// thread of conversation, falling back to lower-level triggers if no match is// found for the nested ones.jive; // The callback passed to `hear()` will receive a `message` parameter that// contains information about the matched message, in case you would like to// decide what to say based on that info.jive; jive; // You can return a promise from the callback passed to `hear()` if your// response is dependent on an asynchronous action.jive; // Check the message for what text was replaced in order to customize responsesjive;
// Interacting with your bot: jive;//=> "Well, hi there!" jive;//=> "Kinda." jive;//=> "Sweet." jive;//=> "Error: No matching trigger found!" jive;//=> "Um, WHAT?" jive;//=> "u wot m8" jive;//=> "You said "I ain't got TIME for this", but technically I heard it as "i aint got time for this" jive;//=> "no" jive;//=> "Hi Chad! I'm doing fine this evening, thank you!" jive;//=> "Well, technically I am super depressed, but it's not unmanageable." jive;//=> "Yep! Really lucky: full recovery for my wife, actually!"
Debugging
Pass { debug: true }
to the JiveScript
constructor (or set jive.options.debug = true
after initialization) to get debugging output to the console.
Playground
Try it out in the JSFiddle here. Note: That link isn't guaranteed to be up-to-date, though, depending on the release. So, if you want to make sure you have all the bells and whistles, do the following:
git clone https://github.com/kjleitz/jivescript
cd jivescript
yarn install # or npm install
yarn serve # or npm run serve
...and navigate to http://localhost:8080/demo.html, where you can play around.
Contributing
Bug reports and pull requests for this project are welcome at its GitHub page. If you choose to contribute, please be nice so I don't have to run out of bubblegum, etc.
License
This project is open source, under the terms of the MIT license.