<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Slack風チャットボット</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
.chat-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.chat-window {
width: 400px;
background-color: #f4f4f4;
border: 1px solid #ddd;
border-radius: 5px;
padding: 20px;
}
.chat-messages {
height: 300px;
overflow-y: auto;
border-bottom: 1px solid #ddd;
margin-bottom: 10px;
}
#message-input {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="chat-container">
<div class="chat-window">
<div class="chat-messages" id="chat-messages">
<!-- チャットメッセージが表示される部分 -->
</div>
<input type="text" id="message-input" placeholder="メッセージを入力してください...">
<button onclick="sendMessage()">送信</button>
</div>
</div>
<script>
function sendMessage() {
var messageInput = document.getElementById('message-input');
var message = messageInput.value.trim();
if (message !== '') {
var chatMessages = document.getElementById('chat-messages');
var messageElement = document.createElement('div');
messageElement.textContent = message;
chatMessages.appendChild(messageElement);
messageInput.value = '';
// メッセージをバックエンドに送信
fetch('/send_message', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ message: message })
});
}
}
</script>
</body>
</html>