Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
A chatbot is a software application designed to simulate human conversation, either through text or speech. It utilizes artificial intelligence (AI) and natural language processing (NLP) to understand and respond to user queries or commands in a manner that resembles human interaction.
  • Loading branch information
vivi2004 authored Jun 18, 2024
1 parent 4f370f3 commit 4a517f0
Show file tree
Hide file tree
Showing 11 changed files with 4,352 additions and 0 deletions.
11 changes: 11 additions & 0 deletions QA.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const mongoose = require('mongoose');

// Define a schema for questions and responses
const QASchema = new mongoose.Schema({
question: String,
response: String
});

const QA = mongoose.model('QA', QASchema);

module.exports = QA;
93 changes: 93 additions & 0 deletions about.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/css/main.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<title>About us - Chatbot</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f8f9fa;
}
ul {
list-style-type: none;
padding: 0;
overflow: hidden;
background-color: #333;
margin: 0;
}
ul li {
float: left;
}
ul li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-weight: bold;
font-family: 'Courier New', Courier, cursive;
}
ul li a:hover {
background-color: #111;
}
.container {
margin-top: 60px;
background-color: #ffffff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.text-center {
color: #333;
font-family: 'Courier New', Courier, cursive;
font-weight: bold;
;
}
p {
font-family: 'Courier New', Courier, cursive;
font-weight: bold;
color: #333;
}
</style>
</head>

<body>
<div>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact Us</a></li>
</ul>
</div>

<div class="container">
<h3 class="text-center">About Us</h3>
<p class="text-center">Welcome to Chatbot! We are dedicated to providing you with the best AI-driven solutions
for all your communication needs. Our chatbot technology is designed to assist, engage, and make your life
easier. With a team of experts in AI and machine learning, we strive to innovate and offer cutting-edge
services. Thank you for choosing us as your trusted partner in technology.</p>
</div>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>
<script src="/js/script.js"></script>
</body>

</html>
Binary file added chatbot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chatbot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 128 additions & 0 deletions contact.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<title>Contact Us - Chatbot</title>
<style>
body {
font-family: Arial, sans-serif;
background: url('https://img.freepik.com/free-vector/minimal-geometric-stripe-shape-background_1409-1014.jp');
background-size: cover;
color: #333;
height: 100vh;
margin: 0;
}
ul {
list-style-type: none;
padding: 0;
overflow: hidden;
background-color: #333;
}
ul li {
float: left;
}
ul li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
ul li a:hover {
background-color: #111;
}
.container {
margin-top: 60px;
text-align: center;
background-color:rgb(0, 0, 0,0.1);
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgb(0,0,0,0.1);
}
.social-media {
margin-top: 20px;
}
.social-media a {
margin: 0 10px;
text-decoration: none;
color: #555;
}
.social-media a svg {
width: 24px;
height: 24px;
transition: color 0.3s;
}
.social-media a:hover svg {
fill: #007bff;
}
<!-- .background-content{
color: white;
padding: 20px;
text-align: center;
background-color: rgb(0,0,0,0.5);
border-radius: 8px;
}
-->
footer{
text-align: center;
background-color: #333;
color: white;
padding: 10px 0;
}
</style>
</head>

<body>
<div>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact Us</a></li>
</ul>
</div>

<div class="container">
<h3 style="color: #111;">Contact Us</h3>

<div class="social-media">

<a href="https://x.com/VPurbey123" target="_blank" aria-label="Twitter">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#555">
<path
d="M22.46 6c-.77.35-1.6.58-2.47.69.88-.53 1.56-1.36 1.88-2.35-.82.49-1.73.85-2.7 1.05-.78-.84-1.89-1.36-3.12-1.36-2.37 0-4.29 1.91-4.29 4.28 0 .33.04.65.1.96C7.69 9.09 4.1 7.38 1.67 4.59c-.36.62-.57 1.34-.57 2.1 0 1.45.74 2.73 1.86 3.47-.68-.02-1.31-.21-1.86-.52v.05c0 2.02 1.44 3.7 3.35 4.08-.35.1-.72.15-1.1.15-.27 0-.53-.03-.79-.07.53 1.65 2.07 2.86 3.89 2.89-1.43 1.12-3.22 1.79-5.17 1.79-.34 0-.68-.02-1.01-.06 1.84 1.18 4.04 1.87 6.39 1.87 7.66 0 11.85-6.34 11.85-11.85l-.01-.54c.81-.59 1.51-1.34 2.07-2.19z" />
</svg>
</a>
<a href="https://www.instagram.com/vivi_52_83" target="_blank" aria-label="Instagram">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#555">
<path
d="M12 2.16c3.2 0 3.584.013 4.85.07 1.17.054 1.96.24 2.41.41.47.18.87.4 1.26.78.39.39.6.79.78 1.26.17.45.36 1.24.41 2.41.057 1.266.07 1.65.07 4.85s-.013 3.584-.07 4.85c-.054 1.17-.24 1.96-.41 2.41-.18.47-.4.87-.78 1.26-.39.39-.79.6-1.26.78-.45.17-1.24.36-2.41.41-1.266.057-1.65.07-4.85.07s-3.584-.013-4.85-.07c-1.17-.054-1.96-.24-2.41-.41-.47-.18-.87-.4-1.26-.78-.39-.39-.6-.79-.78-1.26-.17-.45-.36-1.24-.41-2.41-.057-1.266-.07-1.65-.07-4.85s.013-3.584.07-4.85c.054-1.17.24-1.96.41-2.41.18-.47.4-.87.78-1.26.39-.39.79-.6 1.26-.78.45-.17 1.24-.36 2.41-.41 1.266-.057 1.65-.07 4.85-.07m0-2.16c-3.25 0-3.67.012-4.95.07-1.28.058-2.16.26-2.92.55-.8.31-1.49.73-2.16 1.4-.67.67-1.09 1.36-1.4 2.16-.29.76-.49 1.64-.55 2.92-.057 1.28-.07 1.7-.07 4.95s.012 3.67.07 4.95c.058 1.28.26 2.16.55 2.92.31.8.73 1.49 1.4 2.16.67.67 1.36 1.09 2.16 1.4.76.29 1.64.49 2.92.55 1.28.057 1.7.07 4.95.07s3.67-.012 4.95-.07c1.28-.058 2.16-.26 2.92-.55.8-.31 1.49-.73 2.16-1.4.67-.67 1.09-1.36 1.4-2.16.29-.76.49-1.64.55-2.92.057-1.28.07-1.7.07-4.95s-.012-3.67-.07-4.95c-.058-1.28-.26-2.16-.55-2.92-.31-.8-.73-1.49-1.4-2.16-.67-.67-1.36-1.09-2.16-1.4-.76-.29-1.64-.49-2.92-.55-1.28-.057-1.7-.07-4.95-.07zm0 5.84c-3.39 0-6.15 2.76-6.15 6.15s2.76 6.15 6.15 6.15 6.15-2.76 6.15-6.15-2.76-6.15-6.15-6.15zm0 10.16c-2.2 0-3.99-1.79-3.99-3.99s1.79-3.99 3.99-3.99 3.99 1.79 3.99 3.99-1.79 3.99-3.99 3.99zm6.34-11.76c0 .79-.64 1.43-1.43 1.43s-1.43-.64-1.43-1.43.64-1.43 1.43-1.43 1.43.64 1.43 1.43z" />
</svg>
</a>
<a href="https://discord.com/channels/@me" target="_blank" aria-label="Discord">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#555">
<path
d="M20.317 4.369a19.791 19.791 0 00-4.885-1.515.074.074 0 00-.079.037c-.212.375-.447.864-.614 1.249-1.844-.276-3.68-.276-5.514 0-.173-.385-.414-.874-.629-1.249a.078.078 0 00-.078-.037c-1.697.296-3.367.821-4.885 1.515a.07.07 0 00-.032.028C.533 9.158-.319 13.642.099 18.057a.079.079 0 00.031.056c2.052 1.5 4.041 2.422 5.992 3.029a.077.077 0 00.084-.028c.462-.63.874-1.295 1.226-1.995a.076.076 0 00-.041-.103c-.652-.247-1.272-.547-1.872-.892a.077.077 0 01-.007-.133c.126-.093.252-.187.372-.287a.077.077 0 01.078-.01c3.927 1.793 8.18 1.793 12.061 0a.077.077 0 01.079.009c.12.1.246.195.372.288a.076.076 0 01-.006.133c-.6.345-1.22.645-1.872.891a.076.076 0 00-.041.104c.372.7.784 1.364 1.226 1.995a.077.077 0 00.084.028c1.951-.607 3.94-1.529 5.992-3.029a.077.077 0 00.031-.055c.5-5.068-.818-9.502-4.326-13.66a.067.067 0 00-.031-.029zm-11.31 9.64c-1.183 0-2.156-1.086-2.156-2.419 0-1.333.953-2.42 2.156-2.42 1.202 0 2.175 1.087 2.156 2.42 0 1.333-.953 2.419-2.156 2.419zm7.407 0c-1.183 0-2.156-1.086-2.156-2.419 0-1.333.953-2.42 2.156-2.42 1.202 0 2.175 1.087 2.156 2.42 0 1.333-.954 2.419-2.156 2.419z" />
</svg>
</a>
<a href="https://www.linkedin.com/in/vivek-kumar-purbey-3241a2259/" target="_blank" aria-label="LinkedIn">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#555">
<path
d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.761 0 5-2.239 5-5v-14c0-2.761-2.239-5-5-5zm-11 19h-3v-10h3v10zm-1.5-11.267c-.966 0-1.75-.784-1.75-1.75s.784-1.75 1.75-1.75 1.75.784 1.75 1.75-.784 1.75-1.75 1.75zm13.5 11.267h-3v-5.333c0-1.287-.027-2.944-1.794-2.944-1.794 0-2.068 1.4-2.068 2.844v5.433h-3v-10h2.881v1.381h.042c.401-.759 1.381-1.56 2.844-1.56 3.041 0 3.601 2.003 3.601 4.604v5.575z" />
</svg>
</a>
51 changes: 51 additions & 0 deletions index.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/css/main.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<title>Chatbot</title>
</head>

<body>
<div>
<ul>
<li><a href="/"> Home </a></li>
<li><a href="/about"> About</a></li>
<li><a href="/contact "> Contact us </a></li>
</ul>
</div>

<div class="container" style="margin-top: 60px;">
<h3 class="text-center">Chatbot App</h3>
<div class="media" style="height: 100px; background-color: whitesmoke;">
<img src="/img/chatbot.png" style="float: left;" class="rounded-circle float-left img-thumbnail"
width="75px" alt="...">
<div class="media-body" style="float: left;"></div>
<h5 style="margin: 10px;">Chatbot</h5>
<span style="margin-left: 10px; color: rgb(32,199,32)">online</span>
</div>
</div>

<div id="chatContainer" class="container border overflow-auto" style="height: 300px;width:100%; " ></div>

<div class="input-group">
<input id="textbox" type="text" class="form-control" />
<div class="input-group-append">
<button id="sendBtn" type="button" class="btn btn-primary">Send</button>
</div>
</div>

<button class="toggle-button" onclick="toggleDarkMode()">Dark Mode</button>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>

<script src="/js/script.js"></script>
</body>

</html>
66 changes: 66 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
var express = require('express');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
var ejs = require('ejs');

var app = express();

app.use(express.static('public'));
app.use(bodyParser.json());
app.set('view engine', 'ejs');

// Connect to MongoDB
mongoose.connect('mongodb://localhost:27017/chatbot', {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => console.log('MongoDB connected'))
.catch(err => console.log(err));

// Define a schema
const MessageSchema = new mongoose.Schema({
userMessage: String,
chatbotResponse: String,
timestamp: { type: Date, default: Date.now }
});

const Message = mongoose.model('Message', MessageSchema);

// Routes
app.get('/', function (req, res) {
res.render('pages/index');
});

app.get('/about', function (req, res) {
res.render('pages/about');
});

app.get('/contact', function (req, res) {
res.render('pages/contact');
});

// Route to save messages
app.post('/messages', async (req, res) => {
const { userMessage, chatbotResponse } = req.body;
const message = new Message({ userMessage, chatbotResponse });
await message.save();
res.send(message);
});

// Route to get chatbot response
app.post('/get-response', async (req, res) => {
const { userMessage } = req.body;
const message = await Message.findOne({ userMessage: new RegExp(`^${userMessage}$`, 'i') });

if (message) {
res.send({ chatbotResponse: message.chatbotResponse });
} else {
res.send({ chatbotResponse: "I didn't understand that." });
}
});

const port = 8080;
app.listen(port, () => {
console.log(`Server is live on port ${port}!`);
}).on('error', (err) => {
console.error(`Failed to start server: ${err}`);
});
Loading

0 comments on commit 4a517f0

Please sign in to comment.