samedi 31 juillet 2021

JS Question: How do I make my level 0 flow to level 1 in my chat prompt

I'm working on a message chat flow diagram where you input answers and it'll give you a reply working through the chart. However, I can't get my first level to connect with my second level. I can type in "name" and it will return correctly, but when I type in yes to answer then Do you like ice cream question. I get an undefined reply. Any help is greatly appreciated.

let level = 0;
let path;

const getReply = (userInput) => {
if (level === 0) {
level = 1;
if (userInput === "name") {
path = "name";
return "Hello, name. Do you have like ice cream?";
}
}


if (level === 1) {
level = 2;
if (path === "yes") {
if (userInput === "yes") {
  return "Great, what flavour do you like?";
 }
 }

Aucun commentaire:

Enregistrer un commentaire