Hey everyone!
I’ve just finished a JavaScript implementation of my RiveScript AI language! It’s literally only a few hours old after putting the last finishing touches on it, so it can still be considered alpha quality, but it works! I even got Alice running on it, and to my surprise she actually runs really well, responding instantly to most questions (on Firefox 14.0 on Linux x64).
You can get the source code on github: https://github.com/kirsle/rivescript-js—for the impatient, a direct link to RiveScript.js: https://raw.github.com/kirsle/rivescript-js/master/bin/RiveScript.js
This JavaScript module can be used both in a web browser (using ajax to load RiveScript documents), or from Node.JS or other compatible JavaScript engines. There are examples for both of these on github.
Want a demo?
This is the “safe” demo, which loads the standard RiveScript brain that ships with all the RiveScript modules: http://www.rivescript.com/demo/rivescript-js/
Here is an Alice demo: http://www.rivescript.com/demo/rivescript-js/alice.html—you can see how Alice performs on your computer at this link, but beware that your browser might freeze if you ask Alice certain things, because the AIML that she’s based from has a lot of recursive loops that take a while to resolve (this gives me an idea for a future patch for all the RiveScript libs though—prevent infinite loops by making sure the same trigger isn’t visited twice).
On my system Alice takes a few seconds to initialize (she’s got a 4 MB RiveScript document that needs to load), but after that she replies instantly, except for the times she gets caught in a deep loop.
Hopefully with the JavaScript version, some of you will be able to set up chatbots on your own sites. Since the JS all runs client side, you don’t even need any special server software to get a bot up and running!
As always, let me know if you find any bugs. There are sure to be some because this is a new library and hasn’t been extensively pounded on yet. But so far I’m impressed that it runs Alice even better than the Perl library does (but this is probably mostly thanks to my web browser ).