I've been using the following in a pattern matching chatbot. A person types in an input box and the chatbot responds in an output box.
If someone types "yes" the bot responds with the following except on message 4 where I ask a question. Once that question is asked it will no longer trigger which is what I want. I don't want that question to be asked over and over. This all worked until recently. I can't figure out why it no longer works. Thanks!
Code:var yes_q4_asked="false"; if (input.search("yes")!= -1) { message[0] = "ok, yes it is."; message[1] = "yes, I suppose so."; message[2] = "ok, I understand."; message[3] = "ok, I guess so."; message[4] = "yeah, I reckon so. Say what color are your eyes?"; message[5] = "yes, I thought as much."; num = [Math.floor(Math.random()*6)] if ((num==4) && (yes_q4_asked=="false")) { yes_q4_asked=="true"; document.result.result.value = message[num]; return true; } while (num==4) { num = [Math.floor(Math.random()*6)] } document.result.result.value = message[num]; return true;}



Reply With Quote

Bookmarks