Fixes additional inputs as variables in custom workflow templates (#7840)
* fix additonal inputs as dynamic text variables * pass responses in same format --------- Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
1 parent
7967a65ade
commit
0bae688da1
6 files changed
+13
-13
No files matched your search
@@ -1948,7 +1948,7 @@ async function handler(
|
|||||||
await scheduleWorkflowReminders(
|
await scheduleWorkflowReminders(
|
||||||
eventType.workflows,
|
eventType.workflows,
|
||||||
smsReminderNumber || null,
|
smsReminderNumber || null,
|
||||||
{ ...evt, ...{ metadata } },
|
{ ...evt, responses, ...{ metadata } },
|
||||||
evt.requiresConfirmation || false,
|
evt.requiresConfirmation || false,
|
||||||
rescheduleUid ? true : false,
|
rescheduleUid ? true : false,
|
||||||
true
|
true
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
timeZone: timeZone,
|
timeZone: timeZone,
|
||||||
location: reminder.booking.location || "",
|
location: reminder.booking.location || "",
|
||||||
additionalNotes: reminder.booking.description,
|
additionalNotes: reminder.booking.description,
|
||||||
customInputs: reminder.booking.customInputs,
|
responses: reminder.booking.responses,
|
||||||
meetingUrl: bookingMetadataSchema.parse(reminder.booking.metadata || {})?.videoCallUrl,
|
meetingUrl: bookingMetadataSchema.parse(reminder.booking.metadata || {})?.videoCallUrl,
|
||||||
};
|
};
|
||||||
const emailSubject = await customTemplate(
|
const emailSubject = await customTemplate(
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
timeZone: timeZone,
|
timeZone: timeZone,
|
||||||
location: reminder.booking?.location || "",
|
location: reminder.booking?.location || "",
|
||||||
additionalNotes: reminder.booking?.description,
|
additionalNotes: reminder.booking?.description,
|
||||||
customInputs: reminder.booking?.customInputs,
|
responses: reminder.booking?.responses,
|
||||||
meetingUrl: bookingMetadataSchema.parse(reminder.booking?.metadata || {})?.videoCallUrl,
|
meetingUrl: bookingMetadataSchema.parse(reminder.booking?.metadata || {})?.videoCallUrl,
|
||||||
};
|
};
|
||||||
const customMessage = await customTemplate(
|
const customMessage = await customTemplate(
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ export const scheduleEmailReminder = async (
|
|||||||
timeZone: timeZone,
|
timeZone: timeZone,
|
||||||
location: evt.location,
|
location: evt.location,
|
||||||
additionalNotes: evt.additionalNotes,
|
additionalNotes: evt.additionalNotes,
|
||||||
customInputs: evt.customInputs,
|
responses: evt.responses,
|
||||||
meetingUrl: bookingMetadataSchema.parse(evt.metadata || {})?.videoCallUrl,
|
meetingUrl: bookingMetadataSchema.parse(evt.metadata || {})?.videoCallUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export type BookingInfo = {
|
|||||||
title: string;
|
title: string;
|
||||||
location?: string | null;
|
location?: string | null;
|
||||||
additionalNotes?: string | null;
|
additionalNotes?: string | null;
|
||||||
customInputs?: Prisma.JsonValue;
|
responses?: Prisma.JsonValue;
|
||||||
metadata?: Prisma.JsonValue;
|
metadata?: Prisma.JsonValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ export const scheduleSMSReminder = async (
|
|||||||
timeZone: timeZone,
|
timeZone: timeZone,
|
||||||
location: evt.location,
|
location: evt.location,
|
||||||
additionalNotes: evt.additionalNotes,
|
additionalNotes: evt.additionalNotes,
|
||||||
customInputs: evt.customInputs,
|
responses: evt.responses,
|
||||||
meetingUrl: bookingMetadataSchema.parse(evt.metadata || {})?.videoCallUrl,
|
meetingUrl: bookingMetadataSchema.parse(evt.metadata || {})?.videoCallUrl,
|
||||||
};
|
};
|
||||||
const customMessage = await customTemplate(message, variables, locale);
|
const customMessage = await customTemplate(message, variables, locale);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { guessEventLocationType } from "@calcom/app-store/locations";
|
import { guessEventLocationType } from "@calcom/app-store/locations";
|
||||||
import { Dayjs } from "@calcom/dayjs";
|
import type { Dayjs } from "@calcom/dayjs";
|
||||||
import { Prisma } from "@calcom/prisma/client";
|
import type { Prisma } from "@calcom/prisma/client";
|
||||||
|
|
||||||
export type VariablesType = {
|
export type VariablesType = {
|
||||||
eventName?: string;
|
eventName?: string;
|
||||||
@@ -12,7 +12,7 @@ export type VariablesType = {
|
|||||||
timeZone?: string;
|
timeZone?: string;
|
||||||
location?: string | null;
|
location?: string | null;
|
||||||
additionalNotes?: string | null;
|
additionalNotes?: string | null;
|
||||||
customInputs?: Prisma.JsonValue;
|
responses?: Prisma.JsonValue;
|
||||||
meetingUrl?: string;
|
meetingUrl?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,17 +49,17 @@ const customTemplate = async (text: string, variables: VariablesType, locale: st
|
|||||||
});
|
});
|
||||||
|
|
||||||
customInputvariables?.forEach((variable) => {
|
customInputvariables?.forEach((variable) => {
|
||||||
if (variables.customInputs) {
|
if (variables.responses) {
|
||||||
Object.keys(variables.customInputs).forEach((customInput) => {
|
Object.keys(variables.responses).forEach((customInput) => {
|
||||||
const formatedToVariable = customInput
|
const formatedToVariable = customInput
|
||||||
.replace(/[^a-zA-Z0-9 ]/g, "")
|
.replace(/[^a-zA-Z0-9 ]/g, "")
|
||||||
.trim()
|
.trim()
|
||||||
.replaceAll(" ", "_")
|
.replaceAll(" ", "_")
|
||||||
.toUpperCase();
|
.toUpperCase();
|
||||||
if (variable === formatedToVariable && variables.customInputs) {
|
if (variable === formatedToVariable && variables.responses) {
|
||||||
dynamicText = dynamicText.replace(
|
dynamicText = dynamicText.replace(
|
||||||
`{${variable}}`,
|
`{${variable}}`,
|
||||||
variables.customInputs[customInput as keyof typeof variables.customInputs]
|
variables.responses[customInput as keyof typeof variables.responses]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user