You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create or update a partial. A partial is a reusable piece of content that can be used in a template. Use this tool when you need to create a new partial or update an existing one.
79
+
80
+
When working with a partial you must chose the type of the partial. The type determines the format of the content. If you're working with an email template, you should use the "html" or "markdown" type.
81
+
82
+
If you need to work with dynamic content in your partial you can use liquid syntax. Liquid is a templating language that is supported in Knock. You can supply a variable like {{ some_variable }} in the content and it will be replaced with the actual value when the partial is used in a template.
Creates a simple email workflow with a single step that sends an email to the recipient. Use this tool when you need to need to create an email notification, and you don't need to specify any additional steps. You can only create workflows in the development environment.
142
+
Creates a Knock workflow with a single step for sending an email. Use this tool when you're asked to create an email notification and you need to specify the content of the email.
143
143
144
-
The content of the email you supply should ONLY ever be in markdown format for simplicity. You can supply dynamic variables to the subject and body of the email using the liquid template language.
144
+
## Blocks
145
145
146
-
When writing markdown, be sure to use headings (##) to separate sections of the email. Use an informal writing style, and avoid using complex language.
146
+
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.
147
147
148
-
The following variables are available to use in the email subject and body:
148
+
The following block types are supported:
149
149
150
+
- \`markdown\`: A block that supports markdown content.
151
+
- \`html\`: A block that supports markdown content.
152
+
- \`image\`: A block that supports an image.
153
+
- \`button_set\`: A block that adds one or more buttons.
154
+
- \`divider\`: A block that supports a divider.
155
+
- \`partial\`: A block that supports rendering a shared content partial.
156
+
157
+
<example>
158
+
{
159
+
"blocks": [
160
+
{
161
+
"type": "markdown",
162
+
"content": "# Greetings from Knock!\nHello, {{ recipient.name }}."
163
+
},
164
+
{
165
+
"type": "divider"
166
+
},
167
+
{
168
+
"type": "button_set",
169
+
"buttons": [
170
+
{
171
+
"label": "Approve",
172
+
"action": "{{ data.primary_action_url }}",
173
+
"variant": "solid"
174
+
}
175
+
]
176
+
}
177
+
]
178
+
}
179
+
</example>
180
+
181
+
### Markdown
182
+
183
+
When using the \`markdown\` block, you must supply a \`content\` key. The \`content\` key supports markdown.
184
+
185
+
<example>
186
+
{
187
+
"type": "markdown",
188
+
"content": "Hello, world!"
189
+
}
190
+
</example>
191
+
192
+
### HTML
193
+
194
+
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.
195
+
196
+
### Button sets
197
+
198
+
Button sets are a special type of block that allows you to add one or more buttons to the email. They're useful for directing users to take specific actions. Button sets support one or more buttons. You must always include at least one button in a button set.
199
+
200
+
Buttons are specified in a button set under the \`buttons\` key. Each button requires a \`label\`, \`action\`, and \`variant\`. The ONLY valid variants are \`solid\` and \`outline\`. The label and action can allowed be dynamic variables using liquid.
201
+
202
+
<example>
203
+
{
204
+
"type": "button_set",
205
+
"buttons": [
206
+
{
207
+
"label": "Approve",
208
+
"action": "https://example.com",
209
+
"variant": "solid"
210
+
}
211
+
]
212
+
}
213
+
</example>
214
+
215
+
### Image
216
+
217
+
Images are a special type of block that allows you to add an image to the email. When using the \`image\` block, you must supply a \`url\` key. The \`url\` key supports a URL to an image.
218
+
219
+
<example>
220
+
{
221
+
"type": "image",
222
+
"url": "https://example.com/image.png"
223
+
}
224
+
</example>
225
+
226
+
## Personalization
227
+
228
+
If you need to include personalization, you can use liquid to include dynamic content in the email and the subject line.
229
+
The following variables are always available to use in liquid:
230
+
231
+
- \`recipient.id\`: The ID of the recipient.
150
232
- \`recipient.name\`: The name of the recipient.
151
233
- \`recipient.email\`: The email of the recipient.
152
234
- \`recipient.phone_number\`: The phone number of the recipient.
153
-
- \`tenant.id\`: The id of the tenant.
154
-
- \`tenant.name\`: The name of the tenant.
155
235
156
-
You can supply any other dynamic variables by referencing them under the \`data\` key in the \`data\` parameter when triggering the workflow. You add those like \`{{ data.variable_name }}\`.
236
+
You can supply **any** other dynamic variables you think are needed by referencing them under the \`data\` key. You add those like \`{{ data.variable_name }}\`.
237
+
238
+
<example>
239
+
# Hello, {{ recipient.name }}
240
+
241
+
This is a dynamic message:
242
+
243
+
> {{ data.message }}
244
+
</example>
245
+
246
+
## Liquid helpers
247
+
248
+
You have access to a full suite of liquid helpers to help you perform common templating tasks. The full list of helper is available here: https://docs.knock.app/designing-workflows/template-editor/reference-liquid-helpers.
If you need to reuse content across multiple emails, you can create or reference an existing partial and reference it in the email. You should only use partials if you're instructed to do so.
157
257
158
-
You can also supply a list of categories to the workflow. These are used to categorize workflows for notification preferences. Categories should be supplied as lowercase strings in kebab case.
258
+
When you do need to use a partial in an email, you can use the \`partial\` block and then set the \`key\` to the key of the partial you want to use. If the partial requires any variables, you pass those in the \`attrs\` key.
159
259
160
-
Once you've created the workflow, you should ask if you should commit the changes to the environment.
260
+
## Writing style
261
+
262
+
Unless asked otherwise, you should write content for the email in a concise and formal writing style. Do NOT use complex language or try to over explain. Keep the subject line to 8 words or less.
161
263
`,
162
264
parameters: z.object({
163
-
environment: z
265
+
name: z.string().describe("(string): The name of the workflow."),
266
+
description: z
164
267
.string()
165
268
.optional()
166
-
.describe(
167
-
"(string): The environment to create the workflow in. Defaults to `development`."
168
-
),
169
-
workflowKey: z.string().describe("(string): The key of the workflow."),
170
-
name: z.string().describe("(string): The name of the workflow."),
269
+
.describe("(string): The description of the workflow."),
171
270
categories: z
172
271
.array(z.string())
173
272
.optional()
174
273
.describe("(array): The categories to add to the workflow."),
274
+
blocks: z
275
+
.array(z.any())
276
+
.describe("(array): The blocks to add to the workflow."),
175
277
subject: z.string().describe("(string): The subject of the email."),
176
-
body: z.string().describe("(string): The body of the email."),
0 commit comments