<!
DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Mini IA Chatbot</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
padding: 20px;
}
#chatbox {
width: 100%;
height: 300px;
border: 1px solid #ccc;
background: #fff;
padding: 10px;
overflow-y: scroll;
}
#userInput {
width: 100%;
padding: 10px;
margin-top: 10px;
}
</style>
</head>
<body>
<h2>Mini Chatbot IA</h2>
<div id="chatbox"></div>
<input type="text" id="userInput" placeholder="Écris quelque chose..." onkeydown="if([Link]==='Enter')
{sendMessage()}">
<script>
function sendMessage() {
const input = [Link]("userInput");
const message = [Link];
if (!message) return;
appendMessage("Vous", message);
[Link] = "";
setTimeout(() => {
const response = getBotResponse(message);
appendMessage("Bot", response);
}, 500);
}
function appendMessage(sender, text) {
const chatbox = [Link]("chatbox");
[Link] += `<p><strong>${sender}:</strong> ${text}</p>`;
[Link] = [Link];
}
function getBotResponse(input) {
input = [Link]();
if ([Link]("bonjour")) return "Bonjour à toi !";
if ([Link]("ça va")) return "Je suis une IA, donc je vais toujours bien.";
if ([Link]("ton nom")) return "Je suis un mini chatbot fait en JavaScript.";
return "Désolé, je ne comprends pas encore ça.";
}
</script>
</body>
</html>