Skip to content

Commit

Permalink
Added AI Chatbot (subhadipbhowmik#69)
Browse files Browse the repository at this point in the history
* added AI Chatbot

* added AI_Chatbot
  • Loading branch information
eiva078 authored May 31, 2024
1 parent 1f36df9 commit a1ced14
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 2 deletions.
25 changes: 24 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"dotenv": "^16.4.5",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react-dom": "^18.0.0",
"react-helmet": "^6.1.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.3.2",
Expand Down
32 changes: 32 additions & 0 deletions src/components/Chatbot/chatbot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { useEffect } from 'react';
import { Helmet } from 'react-helmet';
import './style.css';

const Chatbot = () => {
useEffect(() => {
const script1 = document.createElement('script');
script1.src = "https://cdn.botpress.cloud/webchat/v1/inject.js";
script1.async = true;
document.body.appendChild(script1);

const script2 = document.createElement('script');
script2.src = "https://mediafiles.botpress.cloud/4e10f671-b66c-4211-a966-8d2a4b404513/webchat/config.js";
script2.defer = true;
document.body.appendChild(script2);

return () => {
document.body.removeChild(script1);
document.body.removeChild(script2);
};
}, []);

return (
<div>
<Helmet>
<link rel="stylesheet" href="style.css" />
</Helmet>
</div>
);
};

export default Chatbot;
240 changes: 240 additions & 0 deletions src/components/Chatbot/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@

/* These CSS rules sets the text direction of the paragraph (RTL or LTR) */
/* p, */
.bpw-from-bot > div,
#input-message {
direction: ltr;
}

/* This rule changes the color of the text in the input message */
#input-message {
color: #000000;
}

/* Changes the color of the new message indicator */
.bpw-new-messages-indicator {
background-color: #f5f5f5;
color: #ffffff;
}

/* Styling for the chat header container */
.bpw-header-container {
margin: 10px;
background: #00bfa6;
border-radius: 10px;
position: relative;
overflow: hidden;
border: 1px;
border-radius: 10px;
color: #ffffff;
}

.bpw-header-name{
color: #ffffff;
}

/* Styling for the typing bubble */
.bpw-typing-bubble {
background: #000000;
}

/* Styling for the chat bubble content */
.bpw-chat-bubble-content {
background-color: #f5f5f5;
border-radius: 3px;
border: 1px transparent;
}

/* Styling for the date container, header name, and header subtitle */
.bpw-date-container,
.bpw-header-name,
.bpw-header-subtitle {
color: #ffffff;
}

/* Styling for the layout of the chat bubble. Width, height, border, position and radius of the chat bubble */
.bpw-layout {
width: 400px !important;
height: 70vh;
border-radius: 10px;
right: 10px;
bottom: 5px;
border: 1px;
}
/* Responsive design rules for devices with width less than or equal to 450px */
@media(max-width:450px) {
.bpw-layout {
width: 100% !important;
height: 100%;
right: 0;
bottom: 0;
border-radius: 0;
}
}

/* Changes the fill color of the header icons to white */
.bpw-header-icon,
.bpw-header-icon svg,
.bpw-header-icon svg path {
fill: #ffffff !important;
}

/* Changes the color of the placeholder text in the input message */
#input-message::placeholder {
color: rgba(0,0,0,.30);
}

.bpw-composer textarea{
outline: none !important;
border: 1px solid black;
}
.bpw-composer textarea:focus{
outline: none !important;
border: 1px solid black;
}

/* Styling for the keyboard single choice option */
.bpw-keyboard-single-choice {
background-color: #ffffff;
border: none;
}

/* Styling for the buttons in the chat interface */
.bpw-button,
.bpw-button-alt {
background-color: #00bfa6;
color: #000000;
border-radius: 10px;
border: none;
}


/* Styling for hover effect on the buttons in the chat interface */
.bpw-button:hover,
.bpw-button-alt:hover {
background-color: #f5f5f5;
}

/* Styling for the chat container, including color, scrollbar width and color, and border */
.bpw-chat-container {
background-color: #ffffff;
scrollbar-width: thin;
scrollbar-color: #f5f5f5 #ffffff;
border: none;
}

/* Styling for the chat bubble content when it's from the bot */
.bpw-from-bot .bpw-chat-bubble .bpw-chat-bubble-content {
background-color: #f5f5f5;
color: #000000;
}

/* Styling for the chat bubble content when it's from the user */
.bpw-from-user .bpw-chat-bubble .bpw-chat-bubble-content {
background-color: #00bfa6;
color: #ffffff;
}

/* Styling for the composer section of the chat interface */
.bpw-composer {
background-color: #ffffff;
border-top: none;
}


/* Styling for the scrollbar in the chat container */
.bpw-chat-container::-webkit-scrollbar,
.bpw-chat-container::-moz-scrollbar {
width: 10px;
background-color: #ffffff;
border: none;
}

/* Styling for the avatar of the bot */
.bpw-bot-avatar img,
.bpw-bot-avatar svg {
background: #000000;
border: 3px solid #ffffff;
}

/* Styling for the general scrollbar in the web page */
::-webkit-scrollbar {
width: 0.5rem;
}

/* Styling for the track of the general scrollbar and the chat container scrollbar */
::-webkit-scrollbar-track,
.bpw-chat-container::-webkit-scrollbar-track,
.bpw-chat-container::-moz-scrollbar-track {
background-color: transparent;
}

/* Styling for the thumb of the general scrollbar and the chat container scrollbar */
::-webkit-scrollbar-thumb,
.bpw-chat-container::-webkit-scrollbar-thumb,
.bpw-chat-container::-moz-scrollbar-thumb {
background-color: #ffffff;
border-radius: 1rem;
border: 0.5rem solid transparent;
}

/* Styling for the floating button icon in the chat interface */
.bpw-floating-button i svg path {
fill: #00bfa6;
}



/* Styling for the 'powered by' section of the chat interface */
.bpw-powered {
text-align: center;
padding: 10px;
color: #000000;
background: #ffffff;
font-size: 14px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}

/* Styling for the hyperlinks in the 'powered by' section of the chat interface */
.bpw-powered a {
color: #000000;
text-decoration: underline;
}

/* Styling for hover effect on the hyperlinks in the 'powered by' section of the chat interface */
.bpw-powered a:hover {
text-decoration: underline;
}

.bpw-send-button{
background: #00bfa6;
}
.bpw-send-button:hover{
background-color: #000;
}

/* Change Bot Widget Icon */

.bpw-widget-btn{
border-radius: 50%;
background:#00bfa6;
}

.bpw-floating-button::before {
background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='white' class='w-6 h-6'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M8.625 12a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H8.25m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0H12m4.125 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm0 0h-.375M21 12c0 4.556-4.03 8.25-9 8.25a9.764 9.764 0 01-2.555-.337A5.972 5.972 0 015.41 20.97a5.969 5.969 0 01-.474-.065 4.48 4.48 0 00.978-2.025c.09-.457-.133-.901-.467-1.226C3.93 16.178 3 14.189 3 12c0-4.556 4.03-8.25 9-8.25s9 3.694 9 8.25z' /%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: center;
background-size: contain;
height:undefinedpx !important;
width:undefinedpx !important;
}

.bpw-floating-button {
box-shadow: none !important;
}

.bpw-floating-button:hover {
background-color: #00bfa6;
box-shadow: none !important;
}
2 changes: 2 additions & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Link from "@docusaurus/Link";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import Layout from "@theme/Layout";
import HomepageFeatures from "@site/src/components/HomepageFeatures";
import Chatbot from "../components/Chatbot/chatbot";
import Heading from "@theme/Heading";
import styles from "./index.module.css";

Expand Down Expand Up @@ -37,6 +38,7 @@ export default function Home() {
<HomepageHeader />
<main>
<HomepageFeatures />
<Chatbot />
</main>
</Layout>
);
Expand Down

0 comments on commit a1ced14

Please sign in to comment.