- INPUT STIMULUS
- MATCH STIMULUS AND RESPONSE
- IF MATCH THEN OUTPUT RESPONSE ELSE OUTPUT RANDOM
Example:
- INPUT HELLO
- MATCH HELLO AND GREETINGS
- IF MATCH HELLO THEN OUTPUT GREETINGS
ELSE OUTPUT PLEASE GO ON
<html>
<body>
<button onclick="AI()">Chatbot</button>
<p id="output"></p>
<script>
function AI() {
var stimulus = "I say hello as stimulus.";
var response = stimulus.match(/\bHELLO\b/gi);
if(response){
document.getElementById("output").innerHTML = "Greetings";
}
else
{
document.getElementById("output").innerHTML = "Please go on ";
}
}
</script>
</body>
</html>
Start simple. Learn about computer input, match, and output. Keep improving.