The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
import { emailDocumentSchema, isValidUuid } from 'twenty-shared/utils';
import { z } from 'zod';
export const SaveCampaignToolInputZodSchema = z.object({
campaignId: z
.string()
.refine((value) => isValidUuid(value))
.optional()
.describe(
'Omit to create a new draft campaign. Provide the UUID of an existing messageCampaign record to edit it; when the user refers to the campaign they are viewing, take it from the browsing context.',
),
name: z
.string()
.min(1)
.max(255)
.optional()
.describe('The internal campaign name shown in the campaign list.'),
subject: z
.string()
.max(998)
.optional()
.describe(
'The email subject line. Supports the same {{variables}} as the body.',
),
body: emailDocumentSchema
.optional()
.describe(
'The full email document that replaces the campaign body. ' +
'A document is {type: "doc", content: [...blocks]}. Blocks: paragraph and heading (level 1-3) hold inline text, variableTag chips ({attrs: {variable: "{{name.firstName}}"}}) and hardBreak; section wraps blocks in a styled band; columns holds 2-4 column children; button is a call-to-action with an href; image, divider, bulletList/orderedList and html (raw HTML) complete the set. ' +
'Style attributes are objects of camelCase CSS properties, e.g. {"paddingTop": "12px", "backgroundColor": "#f4f4f5"}. Use longhand box properties (paddingTop/Right/Bottom/Left). ' +
'Per-recipient variables reference person fields by path, e.g. {{name.firstName}}, {{name.lastName}}, {{jobTitle}} or any custom person text, number, boolean, date, select or rating field; {{fullName}} and {{personId}} also work. Email and phone fields are not variables. They apply in text, button and link URLs and raw HTML, and unknown names are rejected with the available list. ' +
'Give a variable a fallback for recipients whose value is empty with the Liquid default filter, e.g. {{name.firstName | default: "there"}}; the fallback is double-quoted and a double quote inside it is written \\". Any other double-brace syntax is rejected as malformed. ' +
'To modify an existing body, read the record first, edit the parsed document and send the whole result back.',
),
});
export type SaveCampaignToolInput = z.infer<
typeof SaveCampaignToolInputZodSchema
>;