Here’s a flowchart of blocks which you can help you in the direction.
Basically the program is listening for keywords in the string. Based on a keyword you can make the “bot” to find a matching “question” in your library and then make it react to that “question”. If not found it would say: “What da …?”
So… the bot knows what’s been asked. The bot knows what to say back. The bot knows what kind of answers to expect for that question (if there should be one). Repeat, repeat and repeat for any inputted “question”. This will chain a series of other questions and/or responses. And voila, that’s your “chat”.
But the thing is that you’d have to insert all the keywords and combinations of keywords to create a (db) collection of pre-defined “questions” which you can answer. And keep in mind that people will make typos. So you should check word by word for a keyword match (as also seen in the flowchart) and then search for the question. Oh, and don’t forget the other hundreds of exceptions which can occur.
I’m no expert on “AI” chatbots or any kind, but this is what I can come up with seeing that flowchart and your ‘not-live-working-demo-example’. Hope it gives you an idea. And please if someone knows better, please do share your knowledge!