Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions src/lib/tools/workflow-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const SHARED_PROMPTS = {
If you need to include personalization, you can use liquid to include dynamic content in the email and the subject line.
The following variables are always available to use in liquid:

- \`recipient.id\`: The ID of the recipient.
- \`recipient.id\`: The ID of the recipient.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, my editor deleted a bunch of whitespace

- \`recipient.name\`: The name of the recipient.
- \`recipient.email\`: The email of the recipient.
- \`recipient.phone_number\`: The phone number of the recipient.
Expand All @@ -62,8 +62,8 @@ const SHARED_PROMPTS = {
<example>
# Hello, {{ recipient.name }}

This is a dynamic message:
This is a dynamic message:

> {{ data.message }}
</example>

Expand All @@ -77,6 +77,20 @@ const SHARED_PROMPTS = {
`,
};

const contentTypes = z.enum([
"markdown",
"html",
"image",
"button_set",
"divider",
"partial",
]);

// TODO: Add full schema for all block types, but we need to do that without expressing it as a union type.
const contentBlockSchema = z.object({
type: contentTypes,
});
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a comprehensive schema for content blocks, but it demonstrates that the mcp server starts working once some schema is provided.


const createEmailStepInWorkflow = KnockTool({
method: "create_email_step_in_workflow",
name: "Create email step in workflow",
Expand All @@ -87,7 +101,7 @@ const createEmailStepInWorkflow = KnockTool({

## Blocks

The content of the email is supplied as an array of "blocks". The simplest block is a "markdown" block, which supports content in a markdown format. That should always be your default block type.
The content of the email is supplied as an array of "blocks". The simplest block is a "markdown" block, which supports content in a markdown format. That should always be your default block type.

The following block types are supported:

Expand Down Expand Up @@ -133,7 +147,7 @@ const createEmailStepInWorkflow = KnockTool({
}
</example>

### HTML
### HTML

The \`html\` block supports raw HTML content. This should be used sparingly, and only when you need to include custom HTML content that markdown doesn't support. When using the \`html\` block, you must supply a \`content\` key. HTML content can include liquid personalization.

Expand Down Expand Up @@ -184,7 +198,7 @@ const createEmailStepInWorkflow = KnockTool({
.string()
.describe("(string): The key of the workflow to add the step to."),
blocks: z
.array(z.any())
.array(contentBlockSchema)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the key fix .array(z.any()) does not work

.describe("(array): The blocks for the email step."),
subject: z.string().describe("(string): The subject of the email step."),
}),
Expand Down Expand Up @@ -227,8 +241,8 @@ const createSmsStepInWorkflow = KnockTool({
method: "create_sms_step_in_workflow",
name: "Create sms step in workflow",
description: `
Creates an SMS step in a workflow. Use this tool when you're asked to create an SMS notification and you need to specify the content of the SMS.
Creates an SMS step in a workflow. Use this tool when you're asked to create an SMS notification and you need to specify the content of the SMS.

${SHARED_PROMPTS.workflow}

${SHARED_PROMPTS.liquid}
Expand Down Expand Up @@ -328,7 +342,7 @@ const createInAppFeedStepInWorkflow = KnockTool({
method: "create_in_app_feed_step_in_workflow",
name: "Create in app feed step in workflow",
description: `
Creates an in app feed step in a workflow. Use this tool when you're asked to create an in app feed notification and you need to specify the content of the in app feed notification.
Creates an in app feed step in a workflow. Use this tool when you're asked to create an in app feed notification and you need to specify the content of the in app feed notification.

${SHARED_PROMPTS.workflow}

Expand Down Expand Up @@ -435,7 +449,7 @@ const createDelayStepInWorkflow = KnockTool({
Creates a delay step in a workflow. Use this tool when you're asked to add a delay to the workflow that pauses, or waits for a period of time before continuing.

${SHARED_PROMPTS.workflow}

Delays are specified in "unit" and "value" pairs. The only valid units are "seconds", "minutes", "hours", and "days".

<example>
Expand Down