Hello everyone in this blog I am going to show you how you can create a HTML bot . It is a very simple project let's start making it.
I have already prepaired a code you just need to paste it into notepad.
<html>
<head>
<title>HTML Bot</title>
<script>
know = {
"Hello" : "            Hi sir!",
"hello" : "            Hi sir!",
"HELLO" : "            Hi sir!",
"Who are you?" : "            I am a Bot",
"who are you?" : "            I am a Bot",
"How are you?" : "            I am fine",
"how are you?" : "            I am fine",
"How old are you?" : "            I am infinity in age",
"Who is your developer?" : "            Shlok Dungrani",
};
function talk() {
var user = document.getElementById("userBox").value;
document.getElementById("userBox").value= "";
document.getElementById("chatLog").innerHTML += user+"<br>";
if (user in know) {
document.getElementById("chatLog").innerHTML += know[user] + "<br>";
} else
{
document.getElementById("chatLog").innerHTML += "I didn't understand sir.. <br>";
}
}
</script>
</head>
<body style="background-color:cyan;">
<p id="chatLog">Chat Bot of Shlok Dungrani<br> </p>
<input id="userBox" type="text" onkeydown="if(event.keyCode == 13) {talk()}">
</body>
</html>
Now the chat bot is ready to be used.
The output I got is shown in this image
You guys can also check this blog of Mr.Unity Buddy where he makes a chatbot using python.
You guys can also check this blog of Victoria Lo in which she shows A Self-Care Slack Bot for Postman API Hackathon.
You can also create your bot like this add adding custom messages and etc.
If you want to support me then please like my blog and subscribe to my newsletter so you get notified when I post a new blog