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 <wollencarina@gmail.com>
This commit is contained in:
co-authored by
CarinaWolli
parent
7967a65ade
commit
0bae688da1
@@ -1948,7 +1948,7 @@ async function handler(
|
||||
await scheduleWorkflowReminders(
|
||||
eventType.workflows,
|
||||
smsReminderNumber || null,
|
||||
{ ...evt, ...{ metadata } },
|
||||
{ ...evt, responses, ...{ metadata } },
|
||||
evt.requiresConfirmation || false,
|
||||
rescheduleUid ? true : false,
|
||||
true
|
||||
|
||||
@@ -172,7 +172,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
timeZone: timeZone,
|
||||
location: reminder.booking.location || "",
|
||||
additionalNotes: reminder.booking.description,
|
||||
customInputs: reminder.booking.customInputs,
|
||||
responses: reminder.booking.responses,
|
||||
meetingUrl: bookingMetadataSchema.parse(reminder.booking.metadata || {})?.videoCallUrl,
|
||||
};
|
||||
const emailSubject = await customTemplate(
|
||||
|
||||
@@ -108,7 +108,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
timeZone: timeZone,
|
||||
location: reminder.booking?.location || "",
|
||||
additionalNotes: reminder.booking?.description,
|
||||
customInputs: reminder.booking?.customInputs,
|
||||
responses: reminder.booking?.responses,
|
||||
meetingUrl: bookingMetadataSchema.parse(reminder.booking?.metadata || {})?.videoCallUrl,
|
||||
};
|
||||
const customMessage = await customTemplate(
|
||||
|
||||
@@ -100,7 +100,7 @@ export const scheduleEmailReminder = async (
|
||||
timeZone: timeZone,
|
||||
location: evt.location,
|
||||
additionalNotes: evt.additionalNotes,
|
||||
customInputs: evt.customInputs,
|
||||
responses: evt.responses,
|
||||
meetingUrl: bookingMetadataSchema.parse(evt.metadata || {})?.videoCallUrl,
|
||||
};
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ export type BookingInfo = {
|
||||
title: string;
|
||||
location?: string | null;
|
||||
additionalNotes?: string | null;
|
||||
customInputs?: Prisma.JsonValue;
|
||||
responses?: Prisma.JsonValue;
|
||||
metadata?: Prisma.JsonValue;
|
||||
};
|
||||
|
||||
@@ -107,7 +107,7 @@ export const scheduleSMSReminder = async (
|
||||
timeZone: timeZone,
|
||||
location: evt.location,
|
||||
additionalNotes: evt.additionalNotes,
|
||||
customInputs: evt.customInputs,
|
||||
responses: evt.responses,
|
||||
meetingUrl: bookingMetadataSchema.parse(evt.metadata || {})?.videoCallUrl,
|
||||
};
|
||||
const customMessage = await customTemplate(message, variables, locale);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { guessEventLocationType } from "@calcom/app-store/locations";
|
||||
import { Dayjs } from "@calcom/dayjs";
|
||||
import { Prisma } from "@calcom/prisma/client";
|
||||
import type { Dayjs } from "@calcom/dayjs";
|
||||
import type { Prisma } from "@calcom/prisma/client";
|
||||
|
||||
export type VariablesType = {
|
||||
eventName?: string;
|
||||
@@ -12,7 +12,7 @@ export type VariablesType = {
|
||||
timeZone?: string;
|
||||
location?: string | null;
|
||||
additionalNotes?: string | null;
|
||||
customInputs?: Prisma.JsonValue;
|
||||
responses?: Prisma.JsonValue;
|
||||
meetingUrl?: string;
|
||||
};
|
||||
|
||||
@@ -49,17 +49,17 @@ const customTemplate = async (text: string, variables: VariablesType, locale: st
|
||||
});
|
||||
|
||||
customInputvariables?.forEach((variable) => {
|
||||
if (variables.customInputs) {
|
||||
Object.keys(variables.customInputs).forEach((customInput) => {
|
||||
if (variables.responses) {
|
||||
Object.keys(variables.responses).forEach((customInput) => {
|
||||
const formatedToVariable = customInput
|
||||
.replace(/[^a-zA-Z0-9 ]/g, "")
|
||||
.trim()
|
||||
.replaceAll(" ", "_")
|
||||
.toUpperCase();
|
||||
if (variable === formatedToVariable && variables.customInputs) {
|
||||
if (variable === formatedToVariable && variables.responses) {
|
||||
dynamicText = dynamicText.replace(
|
||||
`{${variable}}`,
|
||||
variables.customInputs[customInput as keyof typeof variables.customInputs]
|
||||
variables.responses[customInput as keyof typeof variables.responses]
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user