Feel free to expand this little demo. Try asking for the user's name and echoing it back to him. Add keywords and responses. Add more responses for the times the user doesn't type a key word. Keep it clean and respectful, please.

Don't replace this code. Instead, ADD your code by adding to the listing on the Sample Code page.

'Global variable to hold maximum number of
'possible responses and key words:
global maxNum
 
'Set maxNum here.
'You can change it easily when you add words.
maxNum = 12
 
'Double-dimmed array to hold key words
'and responses:
dim keys$(maxNum,2)
dim randomAnswer$(maxNum)
 
'Fill key word array.
gosub [Init]
 
print "I am Little Eliza. I'd love to chat with you."
print "When you are done chatting, type 'goodbye'."
 
[again]
 
input "Please type something and press ENTER."; response$
 
answer$ = Parse$(response$)
html "<font color = red size = 4>";answer$;"</font></p> </p>"
 
if answer$ = "Goodbye. It's been nice chatting with you." then end
goto [again]
 
 
 
Function Parse$(t$)
    t$ = lower$(t$)
    Parse$ = ""
    for i = 1 to maxNum
        if instr(t$, keys$(i,1))>0 then
            Parse$ = keys$(i,2)
            exit for
        end if
    next
    if Parse$ = "" then
        num = int(rnd(0)* maxNum)
        Parse$ = randomAnswer$(num)
    end if
End Function
 
[Init]
'Notice that all key words are in lower case
'We'll use lower$() to modify user responses
'to make it easier to check for matches.
keys$(1,1) = "hello"
keys$(1,2) = "Hello. Nice to meet you."
keys$(2,1) = "love"
keys$(2,2) = "It's good to love. How does it make you feel?"
keys$(3,1) = "like"
keys$(3,2) = "I like that, too. What else do you like?"
keys$(4,1) = "hate"
keys$(4,2) = "Hate is such a negative emotion."
keys$(5,1) = "goodbye"
keys$(5,2) = "Goodbye. It's been nice chatting with you."
keys$(6,1) = "color"
keys$(6,2) = "My favorite color is blue."
keys$(7,1) = "happy"
keys$(7,2) = "I'm glad to hear that you are happy."
keys$(8,1) = "good"
keys$(8,2) = "Why is it good?"
keys$(9,1) = "bad"
keys$(9,2) = "What is so bad about it?"
keys$(10,1) = "angry"
keys$(10,2) = "Try to calm down!"
keys$(11,1) = "yes"
keys$(11,2) = "Great. Stay positive!"
keys$(12,1) = " no"
keys$(12,2) = "Learn to be less negative, please."
 
randomAnswer$(1) = "Why is it always about you? I have feelings, too!"
randomAnswer$(2) = "I don't understand. Try again."
randomAnswer$(3) = "That's fine. Now let's talk about the weather."
randomAnswer$(4) = "Have you always felt this way?"
randomAnswer$(5) = "Do you enjoy your job?"
randomAnswer$(6) = "Maybe you need a new puppy."
randomAnswer$(7) = "Do you prefer Bugs Bunny or Daffy Duck?"
randomAnswer$(8) = "Hmmm. I see. Tell me more."
randomAnswer$(9) = "Can we change the subject?"
randomAnswer$(10) = "This conversation is making me uncomfortable. Let's get a pizza."
randomAnswer$(11) = "How long has this been going on?"
randomAnswer$(12) = "Let's quit talking and write some code."
return