From 44fcd1382e8922eed5becfe9405447592041904e Mon Sep 17 00:00:00 2001 From: Tom Wise <79859203+tomwisecodes@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:24:14 +0000 Subject: [PATCH] feat: update emails to use html --- packages/api/src/router/exports.ts | 60 ++++++++++--------- packages/core/src/utils/sendEmail.ts | 18 ++++-- .../sendEmailRequestingMoreGenerations.ts | 4 +- .../src/utils/sendJudgementFeedbackEmail.ts | 26 ++++---- .../core/src/utils/sendQuizFeedbackEmail.ts | 30 +++++----- packages/core/src/utils/stripHtml.ts | 3 + 6 files changed, 77 insertions(+), 64 deletions(-) create mode 100644 packages/core/src/utils/stripHtml.ts diff --git a/packages/api/src/router/exports.ts b/packages/api/src/router/exports.ts index e81f44cc1..e83b9bf0d 100644 --- a/packages/api/src/router/exports.ts +++ b/packages/api/src/router/exports.ts @@ -724,23 +724,23 @@ export const exportsRouter = router({ to: userEmail, name: "Oak National Academy", subject: "Download your lesson made with Aila: " + lessonTitle, - body: ` -Hi ${userFirstName}, - -These are the lesson resources that you created with Aila. -You can use the following links to copy the lesson resources to your Google Drive. - -Lesson plan: ${`${lessonPlanLink.split("/edit")[0]}/copy`} -Slides: ${`${slidesLink.split("/edit")[0]}/copy`} -Worksheet: ${`${worksheetLink.split("/edit")[0]}/copy`} -Starter quiz: ${`${starterQuizLink.split("/edit")[0]}/copy`} -Exit quiz: ${`${exitQuizLink.split("/edit")[0]}/copy`} -Additional materials: ${`${additionalMaterialsLink.split("/edit")[0]}/copy`} - -We hope the lesson goes well for you and your class. If you have any feedback for us, please let us know. You can simply reply to this email. - -Aila, -Oak National Academy`, + htmlBody: `
Hi ${userFirstName},
+ +These are the lesson resources that you created with Aila.
+ You can use the following links to copy the lesson resources to your Google Drive.
We hope the lesson goes well for you and your class. If you have any feedback for us, please let us know. You can simply reply to this email.
+ +Aila
+ Oak National Academy
Hi ${userFirstName},
+ +We made the lesson: ${lessonTitle}
+ +You can use the following link to copy the lesson resources ${title.toLowerCase()} to your Google Drive: + ${`${link.split("/edit")[0]}/copy`} +
+ +We hope the lesson goes well for you and your class. If you have any feedback for us, please let us know. You can simply reply to this email.
+ +Best regards,
+ Aila,
+ Oak National Academy
${body}`, + TextBody: stripHtml(htmlBody), + HtmlBody: `${htmlBody}`, MessageStream: "outbound", }); diff --git a/packages/core/src/utils/sendEmailRequestingMoreGenerations.ts b/packages/core/src/utils/sendEmailRequestingMoreGenerations.ts index 03a3ada3d..25325dc67 100644 --- a/packages/core/src/utils/sendEmailRequestingMoreGenerations.ts +++ b/packages/core/src/utils/sendEmailRequestingMoreGenerations.ts @@ -12,13 +12,13 @@ export const sendEmailRequestingMoreGenerations = async (input: { userEmail: string; }) => { const emailContent = ` - User ${input.userEmail} has requested more generations for app ${input.appSlug}. +
User ${input.userEmail} has requested more generations for app ${input.appSlug}.
`; return sendEmail({ from: "ai.feedback@thenational.academy", to: NEXT_PUBLIC_GLEAP_FEEDBACK_EMAIL_ADDR, subject: "Feedback: generation flagged", - body: emailContent, + htmlBody: emailContent, }); }; diff --git a/packages/core/src/utils/sendJudgementFeedbackEmail.ts b/packages/core/src/utils/sendJudgementFeedbackEmail.ts index a562adee3..35f5017c5 100644 --- a/packages/core/src/utils/sendJudgementFeedbackEmail.ts +++ b/packages/core/src/utils/sendJudgementFeedbackEmail.ts @@ -22,27 +22,27 @@ export const sendJudgementFeedbackEmail = async (input: { const { user, feedback, flaggedItem } = input; const inputDataAsString = JSON.stringify(input); - const emailContent = ` - User ${user.email} has clicked on the flag button on a comparative judgement. - Please check the database for more information: + const emailContent = `
+ User ${user.email} has clicked on the flag button on a comparative judgement.
+ Please check the database for more information:
+
+
-
+ ${flaggedItem}
+ Feedback: ${feedback.typedFeedback}
+ Inappropriate content: ${feedback.contentIsInappropriate}
+ Factually incorrect content: ${feedback.contentIsFactuallyIncorrect}
+ Not helpful content: ${feedback.contentIsNotHelpful}
+ Full data of the time of the flag:
- ${flaggedItem}
- Feedback: ${feedback.typedFeedback}
- Inappropriate content: ${feedback.contentIsInappropriate}
- Factually incorrect content: ${feedback.contentIsFactuallyIncorrect}
- Not helpful content: ${feedback.contentIsNotHelpful}
- Full data of the time of the flag:
-
- ${inputDataAsString}
+ ${inputDataAsString}
+ User ${user.email} has clicked on the flag button.
+
+ Flagged content type: ${flaggedItem.type}
+ Flagged content: ${flaggedItem.value}
+ Generation ID: ${flaggedItem.lastGenerationId}
+ Feedback: ${feedback.typedFeedback}
+ Inappropriate content: ${feedback.contentIsInappropriate}
+ Factually incorrect content: ${feedback.contentIsFactuallyIncorrect}
+ Not helpful content: ${feedback.contentIsNotHelpful}
+ Generation response: ${generationResponse}
+ Full data of the time of the flag:
+
+ ${inputDataAsString}