Skip to content

Commit

Permalink
Update: Refactored Source Code (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangsonww committed Jun 24, 2024
1 parent 1c3d7b2 commit 1166627
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/js/chatbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ function scrollToBottom() {
chatMessages.scrollTop = chatMessages.scrollHeight;
}

function sendInstructionalMessage() {
const instructionMessage = "Hello! I am your WeatherMate Assistant. I can provide weather information for you. To get started, type 'weather in [a city's name]' to get the weather for that city. Or you can also ask me any general weather-related questions or any other queries you may have. How can I assist you today?";
const instructionElem = document.createElement("div");
instructionElem.innerText = instructionMessage;
document.querySelector(".chat-messages").appendChild(instructionElem);
}

document.addEventListener("DOMContentLoaded", () => {
sendInstructionalMessage();
scrollToBottom();
});

async function getBotResponse(message) {
const weatherInCityRegex = /weather in (.*?)(?=\n|$)/;
const weatherInCityMatch = message.match(weatherInCityRegex);
Expand Down

0 comments on commit 1166627

Please sign in to comment.