fix: WhatsApp workflows are not working (#21421)

* fix: whatsapp template

* update

* fixes for sending whatsapp messages

* add message service id when scheduling

* add timezone to startTime variable

---------

Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
Anik Dhabal BabuandCarinaWolli authored and GitHub committed 2025-05-21 08:12:12 +00:00
1 parent 25246ef8ff
commit 3e8f0b125d
7 files changed
+172 -31

No files matched your search

@@ -12,6 +12,10 @@ import { getWhatsappTemplateFunction, isAttendeeAction } from "../lib/actionHelp
import type { PartialWorkflowReminder } from "../lib/getWorkflowReminders";
import { select } from "../lib/getWorkflowReminders";
import { scheduleSmsOrFallbackEmail } from "../lib/reminders/messageDispatcher";
import {
getContentSidForTemplate,
getContentVariablesForTemplate,
} from "../lib/reminders/templates/whatsapp/ContentSidMapping";
export async function handler(req: NextRequest) {
const apiKey = req.headers.get("authorization") || req.nextUrl.searchParams.get("apiKey");
@@ -74,13 +78,29 @@ export async function handler(req: NextRequest) {
? reminder.booking?.attendees[0].timeZone
: reminder.booking?.user?.timeZone;
const startTime = reminder.booking?.startTime.toISOString();
const locale = reminder.booking.user?.locale || "en";
const timeFormat = getTimeFormatStringFromUserTimeFormat(reminder.booking.user?.timeFormat);
const templateFunction = getWhatsappTemplateFunction(reminder.workflowStep.template);
const contentSid = getContentSidForTemplate(reminder.workflowStep.template);
const contentVariables = getContentVariablesForTemplate({
name: userName,
attendeeName: attendeeName || "",
eventName: reminder.booking?.eventType?.title,
eventDate: dayjs(startTime).tz(timeZone).locale(locale).format("YYYY MMM D"),
startTime: dayjs(startTime)
.tz(timeZone)
.locale(locale)
.format(timeFormat || "h:mma"),
timeZone,
});
const message = templateFunction(
false,
reminder.booking.user?.locale || "en",
reminder.workflowStep.action,
getTimeFormatStringFromUserTimeFormat(reminder.booking.user?.timeFormat),
reminder.booking?.startTime.toISOString() || "",
timeFormat,
startTime || "",
reminder.booking?.eventType?.title || "",
timeZone || "",
attendeeName || "",
@@ -98,6 +118,8 @@ export async function handler(req: NextRequest) {
userId,
teamId,
isWhatsapp: true,
contentSid,
contentVariables,
},
fallbackData:
reminder.workflowStep.action && isAttendeeAction(reminder.workflowStep.action)