It's working in the sense if you type "food" 5 or 6 straight times it will start with message[0] and loop accordingly. However, if I type another response then go back to it the sequence is off. Here is a real small demo I'm testing it on. Not sure where my problem is...
I guess I don't understand how to combine the two to get it to work.
I need to place this outside the below?
var num = 0;
Then something like this?
if (input.search("zfood")!= -1) {
message[0] = "Pizza!";
message[1] = "Sub sandwich.";
message[2] = "Tacos.";
message[3] = "Cheeseburger"...
I have a pattern matching chatbot where I use the following to select at random the various responses.
if (input.search("favorite food")!= -1) {
message[0] = "Pizza!";
message[1] = "Sub sandwich.";
message[2] = "Tacos.";
message[3] = "Cheeseburger";
num = [Math.floor(Math.random()*4)]...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.