* add event end time as variable
* add timezone as new variable
* add first version of template prefill
* set template body when template is updated
* set reminder template body and subject when creating workflow
* set email subject when changes templates
* save emailBody and emailsubject for all templates + fix duplicate template text
* add more flexibility for templates
* remove console.log
* fix {ORAGANIZER} and {ATTENDEE} variable
* make sure to always send reminder body and not default template
* fix import
* remove email body text and match variables in templates
* handle translations of formatted variables
* fix email reminder template
* add cancel and reschedule link as variable
* add cancel and reschedule link for scheduled emails/sms
* make sure empty empty body and subject are set for reminder template
* add info message for testing workflow
* fix typo
* add sms template
* add migration to remove reminderBody and emailSubject
* add branding
* code clean up
* add hide branding everywhere
* fix sms reminder template
* set sms reminder template if sms body is empty
* fix custom inputs variables everywhere
* fix variable translations + other small fixes
* fix some type errors
* fix more type errors
* fix everything missing around cron job scheduling
* make sure to always use custom template for sms messages
* fix type error
* code clean up
* rename link to url
* Add debug logs
* Update handleNewBooking.ts
* Add debug logs
* removed unneded responses
* fix booking questions + UI improvements
* remove html email body when changing to sms action
* code clean up + comments
* code clean up
* code clean up
* remove comment
* more clear info message for timezone variable
---------
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: alannnc <alannnc@gmail.com>
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { WorkflowActions } from "@prisma/client";
|
|
|
|
import dayjs from "@calcom/dayjs";
|
|
import { APP_NAME } from "@calcom/lib/constants";
|
|
|
|
const emailReminderTemplate = (
|
|
isEditingMode: boolean,
|
|
action?: WorkflowActions,
|
|
startTime?: string,
|
|
endTime?: string,
|
|
eventName?: string,
|
|
timeZone?: string,
|
|
otherPerson?: string,
|
|
name?: string,
|
|
isBrandingDisabled?: boolean
|
|
) => {
|
|
let eventDate = "";
|
|
|
|
if (isEditingMode) {
|
|
endTime = "{EVENT_END_TIME}";
|
|
eventName = "{EVENT_NAME}";
|
|
timeZone = "{TIMEZONE}";
|
|
otherPerson = action === WorkflowActions.EMAIL_ATTENDEE ? "{ORGANIZER}" : "{ATTENDEE}";
|
|
name = action === WorkflowActions.EMAIL_ATTENDEE ? "{ATTENDEE}" : "{ORGANIZER}";
|
|
eventDate = "{EVENT_DATE_ddd, MMM D, YYYY H:mmA}";
|
|
} else {
|
|
eventDate = dayjs(startTime).tz(timeZone).format("ddd, MMM D, YYYY H:mmA");
|
|
|
|
endTime = dayjs(endTime).tz(timeZone).format("H:mmA");
|
|
}
|
|
const emailSubject = `Reminder: ${eventName} - ${eventDate}`;
|
|
|
|
const introHtml = `<body>Hi${
|
|
name ? " " + name : ""
|
|
},<br><br>This is a reminder about your upcoming event.<br><br>`;
|
|
|
|
const eventHtml = `<div><strong class="editor-text-bold">Event:</strong></div>${eventName}<br><br>`;
|
|
|
|
const dateTimeHtml = `<div><strong class="editor-text-bold">Date & Time:</strong></div>${eventDate} - ${endTime} (${timeZone})<br><br>`;
|
|
|
|
const attendeeHtml = `<div><strong class="editor-text-bold">Attendees:</strong></div>You & ${otherPerson}<br><br>`;
|
|
|
|
const branding = !isBrandingDisabled && !isEditingMode ? `<br><br>_<br><br>Scheduling by ${APP_NAME}` : "";
|
|
|
|
const endingHtml = `This reminder was triggered by a Workflow in Cal.${branding}</body>`;
|
|
|
|
const emailBody = introHtml + eventHtml + dateTimeHtml + attendeeHtml + endingHtml;
|
|
|
|
return { emailSubject, emailBody };
|
|
};
|
|
|
|
export default emailReminderTemplate;
|