HTML、CSS、Java scriptを使って疑似AIチャットボットをつくることができます。
今回はメモ帳で簡単に編集できるコードをご紹介。
「ITによる自動化とはどういうものか」を体感していただけるのではないでしょうか。
チャットボットをつくってみよう
手順は簡単。
- 下記のコードをコピーして「メモ帳」にペーストします。
- メモ帳のファイル名を「index.html」にします。※拡張子に注意
- ファイルをクリックして疑似AIチャットボットを立ち上げます。
これだけです。

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DXチャットボット</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
<style>
:root {
--primary-color: #6a89cc;
--secondary-color: #f1f2f6;
--text-color: #2f3542;
--user-bubble-bg: #e1efff;
--ai-bubble-bg: #ffffff;
--shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
body {
font-family: 'Roboto', sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
color: var(--text-color);
}
.chat-container {
width: 90%;
max-width: 500px;
background-color: var(--secondary-color);
border-radius: 20px;
box-shadow: var(--shadow);
overflow: hidden;
display: flex;
flex-direction: column;
min-height: 600px;
}
.chat-header {
background: var(--primary-color);
padding: 20px;
text-align: center;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.chat-header h2 {
margin: 0;
font-weight: 500;
}
.chat-messages {
flex-grow: 1;
padding: 20px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 15px;
scroll-behavior: smooth;
}
.message {
max-width: 80%;
padding: 12px 18px;
border-radius: 20px;
line-height: 1.5;
word-wrap: break-word;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.user-message {
background-color: var(--user-bubble-bg);
color: var(--text-color);
align-self: flex-end;
border-bottom-right-radius: 5px;
}
.ai-message {
background-color: var(--ai-bubble-bg);
color: var(--text-color);
align-self: flex-start;
border-bottom-left-radius: 5px;
}
.chat-input {
display: flex;
padding: 20px;
border-top: 1px solid #dfe6e9;
background-color: white;
}
.chat-input input {
flex-grow: 1;
border: none;
padding: 10px 15px;
border-radius: 20px;
background-color: #f5f6fa;
outline: none;
transition: background-color 0.3s ease;
}
.chat-input input:focus {
background-color: #ffffff;
box-shadow: 0 0 0 2px var(--primary-color);
}
.chat-input button {
background-color: var(--primary-color);
color: white;
border: none;
padding: 10px 20px;
border-radius: 20px;
margin-left: 5px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.1s ease;
}
.chat-input button:hover {
background-color: #5374b3;
}
.chat-input button:active {
transform: scale(0.98);
}
</style>
</head>
<body>
<div class="chat-container">
<div class="chat-header">
<h2>DXアシスタント</h2>
</div>
<div class="chat-messages" id="chat-messages">
</div>
<form class="chat-input" id="chat-form">
<input type="text" id="user-input" placeholder="質問を入力..." required>
<button type="submit">送信</button>
</form>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const chatForm = document.getElementById('chat-form');
const userInput = document.getElementById('user-input');
const chatMessages = document.getElementById('chat-messages');
// 初回メッセージ
displayMessage('こんにちは!DXに関する質問があれば、お気軽にご入力ください。', 'ai');
chatForm.addEventListener('submit', (e) => {
e.preventDefault();
const userMessage = userInput.value.trim();
if (userMessage === '') return;
displayMessage(userMessage, 'user');
userInput.value = '';
setTimeout(() => {
const botResponse = getBotResponse(userMessage);
displayMessage(botResponse, 'ai');
}, 500);
});
function displayMessage(text, sender) {
const messageElement = document.createElement('div');
messageElement.classList.add('message', `${sender}-message`);
messageElement.textContent = text;
chatMessages.appendChild(messageElement);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
function getBotResponse(input) {
const lowerInput = input.toLowerCase();
// 展示会に関するQ&A
const exhibitionKeywords = [
'展示会', '来場', '出展', '参加', '入場', '費用', '料金', '小間', 'ブース',
'アクセス', '行き方', '場所', '会場', '出展者', '出展企業', '日程', '時間',
'申し込み', 'セミナー', 'イベント', '招待状', 'チケット', '入場料', '事前登録',
'出展料', '価格', '見積もり', '支払い', '費用', '効果', 'メリット', 'roi'
];
if (exhibitionKeywords.some(keyword => lowerInput.includes(keyword))) {
return '展示会に関するご質問は、DXPO公式ページにてご確認ください。詳細な情報が掲載されております。';
}
// DX情報メディアに関するQ&A
const contentKeywords = [
'記事', 'コンテンツ', '情報', '探す', '検索', '知りたい', '調べたい', 'どこ',
'サービス', 'メディア', 'ニュースレター', 'メールマガジン', '会員', '記事', 'コラム'
];
if (contentKeywords.some(keyword => lowerInput.includes(keyword))) {
return 'DXに関する情報をお探しですね。サイト上部の検索窓より、キーワードを入力して記事を検索いただけます。その他の質問は公式サイトお問合せよりご確認ください。';
}
// DXの定義や関連ワードに関するQ&A
const dxDefinitionKeywords = [
'dx', 'デジタルトランスフォーメーション', '意味', '定義', 'とは', 'どういうこと',
'it化', 'デジタル化', '違い', '比較', '相違点', '何', '概念'
];
if (dxDefinitionKeywords.some(keyword => lowerInput.includes(keyword))) {
return 'DXとは、企業がデータやデジタル技術を活用し、ビジネスモデルや組織を変革していくことを指します。より詳しい情報は、サイト内検索で「DXとは」と入力してご覧ください。';
}
// DXの具体的な技術に関するQ&A
const technologyKeywords = [
'ai', '人工知能', 'クラウド', '活用', '導入', '事例', 'セキュリティ', '対策',
'iot', 'ビッグデータ', 'sso', 'RPA', 'チャットボット', 'saas', 'crm', 'erp'
];
if (technologyKeywords.some(keyword => lowerInput.includes(keyword))) {
return 'AIやクラウドに関する記事をお探しですね。サイト内検索で「AI」や「クラウド」といったキーワードで検索してみてください。';
}
// 汎用的な挨拶・応答
if (lowerInput.match(/^(こんにちは|こんにちわ|こんばんわ|おはよう|始めまして)/)) {
return 'こんにちは!何かお困りですか?';
} else if (lowerInput.match(/^(ありがとう|ありがとうございます|助かった|感謝)/)) {
return 'どういたしまして!お役に立てて嬉しいです。';
} else if (lowerInput.match(/^(さようなら|またね|バイバイ|おわり|終了)/)) {
return 'はい、またのご利用をお待ちしております!';
} else {
return '申し訳ありません、その質問にはお答えできません。他の質問をお願いします。';
}
}
});
</script>
</body>
</html>
編集するには
ファイルを右クリック「メモ帳で編集する」でファイルを開きます。
編集したい質問のキーワードや回答結果を編集することで、質問に該当する回答結果を返すことができます。

まとめ
「同じ質問で説明に時間がかかる」「よくある質問を間違えなく伝えたい」こんなお悩みがある方は是非Q&Aの自動化を疑似AIチャットボットを作成して体験してみてはいかがでしょうか。
DXは単なるツールの導入ではなく、組織全体の意識改革、社員教育、そして広範なデジタルツールの導入を伴う取り組みです。まずはこの手軽な体験を通じて、DXに欠かすことのできない「自動化」の可能性を感じてみてください。
その小さな一歩が、やがて企業の文化を変革する大きな流れにつながるはずです。

ネオス(株)
高性能RAG・AIエージェントOfficeBot
高品質・低価格・簡単運用!社内資料×生成AI チャットボット
最先端のAI技術を搭載し、業界最高水準の性能の生成AIチャットボット(RAG)です。 それでいて、低価格・簡単運用! 運用がこれまで以上に楽になるAIエージェント機能も搭載!

北日本コンピューターサービス(株)
AI搭載FAQシステム ふれあいコンシェルジュ
問い合わせ対応負担を軽減!シンプル・カンタンFAQシステム
「同じような問い合わせが何度も来る…」「問い合わせが多くて他の作業が進まない…」こんなお悩みはありませんか?よくある質問はAIにまかせて、社内問い合わせを削減しましょう!