

Ask HN: Chatbots ... - RiderOfGiraffes

I've got a robot on Richard's Play By Email server that plays CoNeutron, and I've been thinking of adding a "ChatBot" on the side.  I've played with Eliza and a few others, but I was wondering if anyone here on HN has some experience, recommendations, warnings or suggestions.
======
jacquesm
I've written a couple and I had great fun with them.

One of the best attempts was a really nasty little trick, basically a human-
backed chatbot. The way it worked was like this:

You get an icq (at the time) client and proxy it through the bot, the bot goes
and makes random friends.

When someone reponds to the bots 'opening' line (Hi how are you?) you get back
a response. You now answer with two things at once, the first a regexp that
matches the response and puts in wildcards for linguistic fluff, and the
actual answer.

The bot stores both in its database, and passes the answer to the user. Who
then replies.

Meanwhile the bot continues to find new 'victims', and everytime it gets back
an answer it tries to make a match based on it's canned responses. It knows
where in the conversation it is (context), so a response will only be matched
in the right spot in a conversation.

After being the bots 'backend' for a couple of days it could keep up a
conversation for a good 20 minutes from the 'hi how are you' until it would
run out of steam, by using wildcards in a smart way it is amazing how
'relevant' an answer can be even though the match is only on one or two words.

It was some of the most fun I ever had with computers, not because it 'fooled'
the users, simply because of seeing all these patterns in language.

~~~
spicyj
Sounds pretty amazing. It sounds better, at least, than any bot that I've
seen. Is it open source? ;)

~~~
jacquesm
There is really nothing amazing about it, it just substitutes a human for any
smarts. It's just as 'amazing' as the mechanical turk playing chess :)

You could probably re-implement the basics using a webform and some ajax in a
couple of hours.

The hardest part was to figure out how to get on the ICQ network, someone was
friendly enough to write micq and it was easy enough to splice the proxy bit
in there.

The real challenge in making a chatbot is writing one that comes up with
original stuff, this one just basically regurgitated whatever it was told on
an earlier occasion.

edit: I've found the code, if you are really interested drop me an email and
I'll send it to you, warning this is _very_ ugly code, it was spliced together
in a very short time from a bunch of stuff and it should really never see the
light of day again. Frankenstein looks pretty in comparison :) It will also
almost certainly not work (if you can find the micq it wants that might help,
not sure if that is even working), fry your computer and so on...

Here is a small sample of what you could do with it (an attempt at getting
people to visit camarades.com:

(I used a different domain to be able to track who actually visited the site),
this the 'ruleset' after a couple of sessions.

    
    
       color off                                                                                                                                                                 
       # info 12089101                                                                                                                                                           
       rand 1                                                                                                                                                                    
       awaittarget 60 servertimeout                                                                                                                                              
       msg $target/Hi There !, I'm Jacques\nDo you like webcams ?                                                                                                                
       await 300 abort                                                                                                                                                           
       !sleep 10                                                                                                                                                                 
       match explainfree  (free free? cost?)                                                                                                                                     
       match explainrand  how find                                                                                                                                               
       match languageno   no do speak                                                                                                                                            
       match apologise    (remove | fuck | go away)                                                                                                                              
       match apologise    fuck                                                                                                                                                   
       match apologise    go away                                                                                                                                                
                                                                                                                                                                                 
       macro affirmative  (cool | yes | yeah | yeh | yep | yup | da | si | sure | I do | very | like much)                                                                       
       match payload      $affirmative                                                                                                                                           
       match explain      need                                                                                                                                                   
       match explaincam   what                                                                                                                                                   
       match maybe        (dont know | maybe | could be)                                                                                                                         
       match pity         (no | nope)                                                                                                                                            
       match pity         nope                                                                                                                                                   
       match explain      don't have                                                                                                                                             
       q                                                                                                                                                                         
       explainfree:                                                                                                                                                              
       msg $target/Sure it's free !                                                                                                                                              
       await 300 abort                                                                                                                                                           
       !sleep 10                                                                                                                                                                 
       match languageno  no do speak                                                                                                                                             
       match apologise  remove                                                                                                                                                   
       match apologise  fuck                                                                                                                                                     
       match apologise  go away                                                                                                                                                  
       match payload    $affirmative                                                                                                                                             
       match explain    need                                                                                                                                                     
       match explaincam what                                                                                                                                                     
       match maybe      dont know                                                                                                                                                
       match maybe      maybe                                                                                                                                                    
       match maybe      could be                                                                                                                                                 
       match pity       no                                                                                                                                                       
       match pity       nope                                                                                                                                                     
       q                                                                                                                                                                         
       apologise:                                                                                                                                                                
       msg $target/Ok, sorry to disturb you, goodbye !                                                                                                                           
       !sleep 10                                                                                                                                                                 
       q                                                                                                                                                                         
       explainrand:                                                                                                                                                              
       msg $target/I found you through Linux/micq random people finder. So do you like cams ?                                                                                    
       await 300 abort                                                                                                                                                           
       !sleep 10                                                                                                                                                                 
       match apologise  remove                                                                                                                                                   
       match apologise  fuck                                                                                                                                                     
       match apologise  go away                                                                                                                                                  
       match payload    cool                                                                                                                                                     
       match payload    yes                                                                                                                                                      
       match payload    yea                                                                                                                                                      
       match payload    yeah                                                                                                                                                     
       match payload    yeh                                                                                                                                                      
       match payload    yep                                                                                                                                                      
       match payload    sure                                                                                                                                                     
       match payload    I do                                                                                                                                                     
       match payload    very                                                                                                                                                     
       match payload    like much                                                                                                                                                
       match explain    need                                                                                                                                                     
       match maybe      dont know                                                                                                                                                
       match maybe      maybe                                                                                                                                                    
       match maybe      could be                                                                                                                                                 
       match pity       no                                                                                                                                                       
       match pity       nope                                                                                                                                                     
       q                                                                                                                                                                         
       explaincam:                                                                                                                                                               
       msg $target/A webcam is a camera connected to the internet                                                                                                                
       await 300 abort                                                                                                                                                           
       match apologise  remove                                                                                                                                                   
       match apologise  fuck                                                                                                                                                     
       match apologise  go away                                                                                                                                                  
       match payload    cool                                                                                                                                                     
       match payload    yes                                                                                                                                                      
       match payload    yea                                                                                                                                                      
       match payload    yeah                                                                                                                                                     
       match payload    yeh                                                                                                                                                      
       match payload    yep                                                                                                                                                      
       match payload    sure                                                                                                                                                     
       match payload    I do                                                                                                                                                     
       match payload    very                                                                                                                                                     
       match payload    like much                                                                                                                                                
       match explain    need                                                                                                                                                     
       match maybe      dont know                                                                                                                                                
       match maybe      maybe                                                                                                                                                    
       match maybe      could be                                                                                                                                                 
       match pity       no                                                                                                                                                       
       match pity       nope                                                                                                                                                     
       q                                                                                                                                                                         
       apologise:                                                                                                                                                                
       msg $target/Ok, sorry to disturb you, goodbye !                                                                                                                           
       !sleep 10                                                                                                                                                                 
       q                                                                                                                                                                         
       payload:                                                                                                                                                                  
       url $target http://www.camerades.com/ Great !\nYou can see me *live*\non www.camerades.com\nEnjoy !\nThere are 100's of live cameras there and free software too !        
       !sleep 10                                                                                                                                                                 
       abort:                                                                                                                                                                    
       q
       maybe:
       msg $target/Hm, if you want to try check out www.camerades.com\nEnjoy !\nThere are 100's of live cameras there
       !sleep 10
       abort:
       q
       pity:
       url $target http://www.camerades.com/ That's a pity, You can see\nme *live* on www.camerades.com\nThere are 100's of live cameras there\nAnyway, sorry to disturb you...\nGoodbye
       await 180 abort
       match describe what see
       match explain what
       match explain need
       !sleep 10
       abort:
       q
       languageno:
       msg $target/No, I don't.\nThat's a pity, You can see\nme *live* on www.camerades.com\nThere are 100's of live cameras there\nAnyway, sorry to disturb you...\nGoodbye
       await 300 abort
       match describe what see
       match explain what
       match explain need
       !sleep 10
       abort:
       q
       explain:
       msg $target/You don't need any software, or camera just a browser is enough.\n
       !sleep 10
       q
       describe:
       msg $target/Lot's of people and out door views from all over the world\n
       !sleep 10
       q
       servertimeout:
       !echo no response !
       q

------
viraptor
I had a bit of fun with chatbots. If you want OS and easy way, you have 3
choices really:

\- AIML engine

\- MegaHAL engine

\- proper parsers (most of them are written in lisp-like languages for some
reason)

Now it really depends on what you want to do - only waste someone else's time?
MegaHAL will do just fine. You can feed it conversations all the time and it
will learn to interact in some environment rather quickly.

If you want some basic scripting, you should look at AIML-based soft. You can
write your scripts and basic expression reduction in XML. There's a
"javascript" tag in the specification, but noone really supports it. I map it
to python functions in my bot and it works quite well. You will never parse
more exotic sentences though - just basics. And your bot will not learn
automatically.

If you want to use it for something really useful, look at the
<http://www.generation5.org/> articles. You'll find a lot of code that's easy
to port to your favourite language there. Serious language parsers connected
to something like word-net are the only way to go if you want good quality.
And you need to create a lot of stuff yourself - afaik there are no standard
response libraries like alice, because the parse format is not really
standardised.

------
paraschopra
I had made one very silly bot called SPEAK. It used simple matching algorithms
to learn. I wondered who would use it, but people actually used it for real.

<http://paraschopra.com/software/>

------
intellectronica
A.L.I.C.E [ <http://alicebot.blogspot.com/> ] is a 'brute-force' chatbot model
that has been developed for many years. It has several free software
implementations and is very easy to work with.

~~~
RiderOfGiraffes
A.L.I.C.E. now has a "Fake Kirk" personality, so I thought I'd try it. Here's
the "conversation" we had:

    
    
      Lieutenant: What's our mission, captain?
      Fake Kirk:  Our five year mission: to seek out
                  new worlds and new civilizations.
                  To go boldly where no man has gone before.
      Lieutenant: Did you not originally split the infinitive?
      Fake Kirk:  No. We beamed it out into open space,
                  Lieutenant. Widest possible dispersion.
      Lieutenant: But didn't that kill it completely?
      Fake Kirk:  How?
      Lieutenant: By ensuring it could never come back.
      Fake Kirk:  Explain.
      Lieutenant: On widest possible dispersion you could
                  never re-integrate the original confinement
                  beam.
      Fake Kirk:  To read minds?
      Lieutenant: Oh dear.
      Fake Kirk:  Lieutenant.
      Lieutenant: Yes captain?
      Fake Kirk:  Lieutenant, get the doctor up here on
                  the double. How bad is it?
      Lieutenant: It's not at all bad - just a flesh wound.
      Fake Kirk:  Oh, yes, it is. It's exactly the same.
                  Only this one works.
    
    

I'm afraid this just screams "Eliza!" at me ...

------
sli
MegaHAL is open source and a lot of fun to play with. Be ready to feed it a
lot of text, though.

~~~
flashingpumpkin
I second that. It's a lot of fun to tinker with. I've once fed it 20k+ posts
from an online game I was playing, basically the whole usergenerated story and
put it online in the game's IRC channel. And as it is, the users indulged in
nostalgia every now and then, which triggered the bot to happily tell about
old times. :)

