Skip to content

Commit

Permalink
Merge pull request #51 from OZimbres/othon/gratitude-response-messages
Browse files Browse the repository at this point in the history
[feat]: add gratitude response messages
  • Loading branch information
LoriaLawrenceZ authored Aug 31, 2024
2 parents b992c54 + 51337e1 commit edbe9ba
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/pages/Chat/Chat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@ function Chat({ type }) {
const processQuestion = (question) => {
const questionTokens = question.trim().split(" ");

if (question.toLowerCase().includes("obrigado")) {
const gratitudeResponses = [
"De nada, estou aqui para ajudar!",
"Disponha, precisando é só chamar!",
"Estou aqui para o que precisar!",
"Estou sempre à disposição!",
"Estou aqui para ajudar, não hesite em me chamar!",
];

handleSendIaMessages([
{
content:
gratitudeResponses[
Math.floor(
Math.random() * gratitudeResponses.length
)
],
author: "ia",
timestamp: new Date(),
},
]);
setIsIaTyping(false);
return true;
}

if (questionTokens.length === 0 || questionTokens.length === 1) {
const giveMoreDetailsSamples = [
"Você poderia elaborar melhor sua pergunta?",
Expand Down Expand Up @@ -244,12 +269,12 @@ function Chat({ type }) {
};

useEffect(() => {
if (isWelcomeSent.current) {
if (isWelcomeSent.current || !authedUser) {
return;
}
isWelcomeSent.current = true;
handleSendIaMessages(welcomeMessages);
}, [welcomeMessages]);
}, [welcomeMessages, authedUser]);

useEffect(() => {
const iaPossibleMessages = [
Expand Down

0 comments on commit edbe9ba

Please sign in to comment.