AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

RiveScript? In my web browser? Introducing RiveScript.js!
 
 

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. wink

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 wink ).

 

 
  [ # 1 ]

Good work. The 4MB download wasn’t as painful as I thought it would be. Welcome to the Javascript chatbot club. grin

 

 
  [ # 2 ]

> http://www.rivescript.com/demo/rivescript-js/

Noah, it looks beautiful!

 

 
  [ # 3 ]

Just ran a few iPad tests—Seems to work fine!

 

 
  [ # 4 ]
Noah Petherbridge - Aug 8, 2012:

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.

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!

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 wink ).

Noah,
I am using node for some of my own development work and have been exploring a full port of Skynet-AI. You can’t beat the speed of node.js.

I did some quick testing of your node implementation, it looks fast and stable. You might want to try to add flexibility to your node version by offering a couple different user interface choices:

Console only mode: have all I/O done right from the console to eliminate the need for the telnet program.

Web host mode: Set your node server up as a node chat room. There are a few node chat room examples on the web using different frameworks. Now.js, Socket.IO, etc.
https://github.com/ry/node_chat
http://spechal.com/2011/03/19/super-simple-node-js-chatroom/
http://www.adityaravishankar.com/2011/10/nowjs-node-js-tutorial-creating-multi-room-chat-server/
http://stackoverflow.com/questions/8654820/nodejs-and-socket-io-chat-rooms

 

 

 
  [ # 5 ]

Noah,
be aware that Object.keys may not be supported in all browsers. You may want to check for the existence of the function.

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys

 

 
  [ # 6 ]

Aha, thanks for the tip. I’ll add that Objects.keys-defining code linked there. smile

 

 
  [ # 7 ]
Noah Petherbridge - Aug 8, 2012:

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

Doesn’t the latest version of your converter utility resolve runaway recursion?

 

 
  [ # 8 ]

I’m not so sure it’s runaway recursion (there’s always been systems in place to prevent that, the “depth” variable that defaults at 50).. it’s that the web browsers don’t handle it very well. When the depth was left at 50, I’d sometimes get 3 or 4 different “This script is not responding” popups before it would work itself out. With the depth set to 10, sometimes I still get one popup before it ends up responding with “ERR: Deep Recursion Detected”.

The Alice AIML I originally started with had the “hello” pattern doing a redirect 50% of the time to another trigger, and that trigger did a redirect 50% of the time back to “hello”... I wouldn’t doubt there are other patterns that do this as well.

 

 
  [ # 9 ]

Alpha version testing report

Platform: IE8, Win7, 64bit… Before using the site.

NOTE: Alpha version testing report submitted ONLY in the hopes that it is helpful during very early alpha, which is now less than a week. In other words, excellent work, regardless.  No criticism intended at all.

Image Attachments
RiveScript_alphatest.jpg
 

 
  [ # 10 ]
Noah Petherbridge - Aug 8, 2012:

Hopefully with the JavaScript version, some of you will be able to set up chatbots on your own sites.

@Noah: The Alpha version testing report technically is NOT a RiveScript bug. And it was also not in response to your post above it. We happen to be posting at the same time, and you finished first. Here is my response to your last post: http://8-i.us/rsjs
I rearranged the interface for the touch screen keyboard to enjoy it on an iPad.  Thanks!

Merlin - Aug 10, 2012:

Object.keys may not be supported in all browsers

@Merlin: Thanks for the Object.keys references.  Seems to help with cross browser compatibility.

 

 
  [ # 11 ]

Glad to help. I am a big advocate for Javascript bots, it is good to see more people adopting it. It would be nice to build a development community around node.js.

 

 
  [ # 12 ]

Perhaps only indirectly addressing the loading process, I’ve introduced two
workarounds that may make research and development easier by stopping
the error popups.

The first workaround either serves Eliza to unresponsive web browsers that
run scripts slowly, or serves Alice to web browsers that run scripts at full speed.

The second workaround let’s the bot provide limited responses during the
loading process, and independently respond to report that loading is complete.

Reference: http://8-i.us/rsjs

 

 
  login or register to react