Skip to content
This giveaway is sponsored by Proozy. All opinions are my own.
I have a lot of people to buy gifts for and athletic and leisurewear is always a popular gift idea. Everyone loves lounging around in comfortable leggings, sweatpants, and tops.
At
Proozy you can find all these items at a very low price! Every day they have daily deals that are very cheap and many items include free shipping!
// Basic chatbot initialization
const chatbot = {
init() {
this.createChatWidget();
this.addEventListeners();
},
// Creates the chatbot UI
createChatWidget() {
const chatWidget = document.createElement('div');
chatWidget.id = 'chat-widget';
chatWidget.style.position = 'fixed';
chatWidget.style.bottom = '20px';
chatWidget.style.right = '20px';
chatWidget.style.width = '300px';
chatWidget.style.height = '400px';
chatWidget.style.border = '1px solid #ccc';
chatWidget.style.borderRadius = '10px';
chatWidget.style.overflow = 'hidden';
chatWidget.style.boxShadow = '0 4px 8px rgba(0,0,0,0.2)';
chatWidget.style.backgroundColor = '#fff';
chatWidget.innerHTML = `
Send
`;
document.body.appendChild(chatWidget);
},
// Handles chatbot logic
addEventListeners() {
const sendBtn = document.getElementById('send-btn');
const userInput = document.getElementById('user-input');
const chatBody = document.getElementById('chat-body');
sendBtn.addEventListener('click', () => {
const userText = userInput.value.trim();
if (userText) {
this.addMessage(userText, 'user');
this.respond(userText);
userInput.value = '';
}
});
userInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
sendBtn.click();
}
});
},
// Adds a message to the chat body
addMessage(text, sender) {
const chatBody = document.getElementById('chat-body');
const message = document.createElement('div');
message.textContent = text;
message.style.margin = '10px 0';
message.style.padding = '10px';
message.style.borderRadius = '8px';
message.style.maxWidth = '80%';
if (sender === 'user') {
message.style.backgroundColor = '#e0f7fa';
message.style.alignSelf = 'flex-end';
} else {
message.style.backgroundColor = '#f1f8e9';
message.style.alignSelf = 'flex-start';
}
chatBody.appendChild(message);
chatBody.scrollTop = chatBody.scrollHeight;
},
// Chatbot response logic
respond(userText) {
const lowerText = userText.toLowerCase();
let response = "";
if (lowerText.includes("enter giveaway")) {
response = "Easy! Just click the 'Enter' button on the giveaway page and follow the steps. Good luck! 🍀";
} else if (lowerText.includes("rules")) {
response = "All rules are listed on the giveaway page, but in short: no spam, no bots, and be awesome!";
} else if (lowerText.includes("email")) {
response = "Sure! Enter your email below, and we’ll keep you posted on upcoming giveaways!";
this.captureLead();
} else {
response = "Hmm, I’m not sure about that one. Try asking something about giveaways or rules!";
}
this.addMessage(response, 'bot');
},
// Capture user email
captureLead() {
const chatBody = document.getElementById('chat-body');
const emailInput = document.createElement('input');
emailInput.type = 'email';
emailInput.placeholder = 'Enter your email';
emailInput.style.margin = '10px 0';
emailInput.style.padding = '8px';
emailInput.style.width = '90%';
emailInput.style.border = '1px solid #ccc';
emailInput.style.borderRadius = '5px';
const submitBtn = document.createElement('button');
submitBtn.textContent = 'Submit';
submitBtn.style.margin = '10px';
submitBtn.style.padding = '8px 10px';
submitBtn.style.backgroundColor = '#4CAF50';
submitBtn.style.color = 'white';
submitBtn.style.border = 'none';
submitBtn.style.borderRadius = '5px';
chatBody.appendChild(emailInput);
chatBody.appendChild(submitBtn);
submitBtn.addEventListener('click', () => {
const email = emailInput.value.trim();
if (email) {
this.addMessage(`Thanks! We’ll notify you at ${email}.`, 'bot');
emailInput.remove();
submitBtn.remove();
} else {
this.addMessage("Please enter a valid email.", 'bot');
}
});
}
};
// Initialize the chatbot
window.onload = () => chatbot.init();
i love the designs, simple but cute