Skip to content
Snippets Groups Projects
Commit 8506627b authored by Konrad Völkel's avatar Konrad Völkel
Browse files

better feedback channel

parent 841fa33c
No related branches found
No related tags found
No related merge requests found
Pipeline #152446 passed
/** open mail client of user with prewritten message and stats */ /** feedback now opens a Google Form prefilled with our parameters */
export function submitFeedback(query, bestAnswers, feedback) { export function submitFeedback(query, bestAnswers, feedback) {
/** temporary mail adress, adjust if needed */ const url = 'https://docs.google.com/forms/d/e/1FAIpQLScv6hLxUZN42pZYkW28FL3WkXZbL_dzdGo0sE-LdeJbIzTi2g/viewform?usp=pp_url';
const feedbackAdress = 'huepfen-richtlinie.7r@icloud.com';
const timestamp = new Date().toISOString();
let subject = '';
let message = '';
const bestAnswersAsString = Object.entries(bestAnswers) const bestAnswersAsString = Object.entries(bestAnswers)
.map(([question, token]) => `> Question: ${question} \n > Answer: ${token}\n`) .map(([question, token]) => `> Question: ${question}\n> Answer: ${token}`)
.join("\n\n"); .join('\n\n');
if (feedback === 'good') {
subject = 'Positive Feedback: FAQ Search Feature';
message = `Hello,
\nI used your FAQ search feature and was pleased with the result.
\nI also have some additional suggestions: ...
\nDetails below:
\nYou asked: ${query}
\nMost fitting responses:\n\n${bestAnswersAsString}\nFeedback: ${feedback}\nTimestamp: ${timestamp}
\nKeep it up!
\nBest regards`;
} else if (feedback === 'bad') {
subject = 'Negative Feedback: FAQ Search Feature';
message = `Hello,
\nI tried used FAQ search feature, and unfortunately, I was not satisfied with this result.
\nI also have some additional suggestions: ...
\nDetails below:
\nYou asked: ${query}
\nMost fitting responses: ${bestAnswersAsString}\nFeedback: ${feedback}\nTimestamp: ${timestamp}
\nI hope this feedback lets you improve the experience.
\nBest regards`;
}
const encodedQuery = encodeURIComponent(query);
const encodedBestAnswers = encodeURIComponent(bestAnswersAsString);
const newSubject = encodeURIComponent(subject); const formFeedback = `entry.293085603=${feedback}`;
const body = encodeURIComponent(message); const formQuery = `entry.430302024=${encodedQuery}`;
const mailtoLink = `mailto:${feedbackAdress}?subject=${newSubject}&body=${body}`; const formAnswer = `entry.1738087812=${encodedBestAnswers}`;
window.location.href = mailtoLink; const newUrl = `${url}&${formFeedback}&${formQuery}&${formAnswer}`;
window.open(newUrl, '_blank');
} }
modules/ui.js 100644 → 100755
...@@ -99,14 +99,14 @@ export function drawFeedbackButtons(query, bestTokens) { ...@@ -99,14 +99,14 @@ export function drawFeedbackButtons(query, bestTokens) {
plusButton.innerHTML = '<i class="fa-solid fa-thumbs-up"></i>'; plusButton.innerHTML = '<i class="fa-solid fa-thumbs-up"></i>';
plusButton.className = 'feedback-button thumbs-up'; plusButton.className = 'feedback-button thumbs-up';
plusButton.onclick = function () { plusButton.onclick = function () {
submitFeedback(query, bestTokens, 'good'); submitFeedback(query, bestTokens, 'Yes');
}; };
const minusButton = document.createElement('button'); const minusButton = document.createElement('button');
minusButton.innerHTML = '<i class="fa-solid fa-thumbs-down"></i>'; minusButton.innerHTML = '<i class="fa-solid fa-thumbs-down"></i>';
minusButton.className = 'feedback-button thumbs-down'; minusButton.className = 'feedback-button thumbs-down';
minusButton.onclick = function () { minusButton.onclick = function () {
submitFeedback(query, bestTokens, 'bad'); submitFeedback(query, bestTokens, 'No');
}; };
feedbackContainer.appendChild(plusButton); feedbackContainer.appendChild(plusButton);
......
styles.css 100644 → 100755
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#chatbox { #chatbox {
position: sticky; position: sticky;
max-height: 900px; max-height: 1200px;
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
left: 10px; left: 10px;
padding: 10px; padding: 10px;
display: flex; display: flex;
max-height: 300px; max-height: 500px;
flex-direction: column; flex-direction: column;
overflow-x: hidden; overflow-x: hidden;
z-index: -3; z-index: -3;
...@@ -89,7 +89,8 @@ ...@@ -89,7 +89,8 @@
color: white; color: white;
margin-left: 40px; margin-left: 40px;
margin: 10px 2; margin: 10px 2;
max-width: 60%; max-width: 75%;
font-size: 18px;
word-wrap: break-word; word-wrap: break-word;
cursor: default; cursor: default;
opacity: 0; opacity: 0;
...@@ -129,6 +130,7 @@ ...@@ -129,6 +130,7 @@
margin-left: 10px; margin-left: 10px;
margin: 10px 2; margin: 10px 2;
max-width: 60%; max-width: 60%;
font-size: 17px;
word-wrap: break-word; word-wrap: break-word;
text-align: middle; text-align: middle;
z-index: 100; z-index: 100;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment