designing-email-templates
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDesigning email templates
设计邮件模板
Use this skill when creating or editing email templates for PostHog workflows — broadcast campaigns and workflow actions send the rendered template.
function_email当你为PostHog工作流创建或编辑邮件模板时使用此技能——广播活动和工作流操作会发送渲染后的模板。
function_emailHow authoring works
创作机制
You author the design JSON () and save it with . The server renders the sent email from your design with the same renderer PostHog's visual editor uses, so the template opens as editable blocks for humans and sends exactly what the design describes. Schema and a working example in references/unlayer-design-json.md.
content.email.designworkflows-create-email-templateWhen talking to the user, call it the template's design — the design document format is an internal implementation detail. Always share the template's edit link in your reply after creating or updating, so the user can open it in PostHog directly.
_posthogUrlRead references/design-guidelines.md before composing — it covers committing to a design direction, typography, color, and the patterns that make an email look designed rather than generated. For one fragment the block editor can't express, use an -type content block inside the design.
html你需要编写设计JSON()并通过保存。服务器会使用与PostHog可视化编辑器相同的渲染器,根据你的设计渲染待发送邮件,因此模板会以可编辑区块的形式供人工编辑,且发送内容与设计完全一致。相关Schema和可用示例请查看references/unlayer-design-json.md。
content.email.designworkflows-create-email-template与用户沟通时,将其称为模板的设计——设计文档格式属于内部实现细节。创建或更新模板后,务必在回复中分享模板的编辑链接,方便用户直接在PostHog中打开。
_posthogUrl编写设计前请阅读references/design-guidelines.md——其中涵盖了设计方向确定、排版、色彩,以及让邮件看起来更具设计感而非自动生成的模式。对于区块编辑器无法实现的内容片段,可在设计中使用类型的内容区块。
htmlPersonalization with Liquid
使用Liquid实现个性化
Email content uses Liquid templating. Liquid tags pass through the renderer as plain text, so use them anywhere — block text, subject, links:
liquid
Hi {{ person.properties.first_name | default: 'there' }},Marketing emails must include an unsubscribe link — render it with the built-in variables:
html
<a href="{{ unsubscribe_url }}">Unsubscribe</a>( is also available for one-click list-unsubscribe flows.)
{{ unsubscribe_url_one_click }}邮件内容采用Liquid模板语法。Liquid标签会以纯文本形式通过渲染器,因此可在任意位置使用——包括区块文本、主题、链接:
liquid
Hi {{ person.properties.first_name | default: 'there' }},营销邮件必须包含退订链接——使用内置变量渲染:
html
<a href="{{ unsubscribe_url }}">Unsubscribe</a>(也适用于一键退订流程。)
{{ unsubscribe_url_one_click }}Creating a template
创建模板
Call with:
workflows-create-email-templatejson
{
"name": "Welcome email",
"description": "Sent to new signups on day 0",
"type": "email",
"content": {
"templating": "liquid",
"email": {
"subject": "Welcome to {{ person.properties.company | default: 'our product' }}",
"design": { "counters": { "u_row": 1 }, "schemaVersion": 16, "body": { "rows": ["…"] } },
"text": "Plain-text fallback of the same message"
}
}
}- is required for email templates.
subject - Always provide — it's the fallback for clients that block rich content and improves deliverability.
text - The tool result returns an edit link into the PostHog library.
- After creating (or updating), call — it renders an inline preview so the user sees the result.
workflows-show-email-template
调用时传入以下参数:
workflows-create-email-templatejson
{
"name": "Welcome email",
"description": "Sent to new signups on day 0",
"type": "email",
"content": {
"templating": "liquid",
"email": {
"subject": "Welcome to {{ person.properties.company | default: 'our product' }}",
"design": { "counters": { "u_row": 1 }, "schemaVersion": 16, "body": { "rows": ["…"] } },
"text": "Plain-text fallback of the same message"
}
}
}- 是邮件模板的必填项。
subject - 务必提供内容——这是针对屏蔽富内容客户端的降级方案,同时可提升邮件送达率。
text - 工具返回结果会包含PostHog库的编辑链接。
- 创建(或更新)后,调用——它会生成内嵌预览,方便用户查看结果。
workflows-show-email-template
Payload mechanics
负载机制
Pass the design directly in the tool call — no scratch files, no pre-validation subprocesses, no payload preview rounds. Liquid tags (, ), apostrophes, single quotes, and emoji are ordinary characters inside JSON strings; only standard JSON escaping applies. Never rewrite content to avoid them — converting Liquid's single quotes to double quotes inside markup attributes breaks the markup. If the tool call is rejected as malformed, fix the JSON escaping and resend the same content unchanged.
{{ }}{% %}直接在工具调用中传入设计内容——无需临时文件、预验证子流程或负载预览环节。Liquid标签(, )、撇号、单引号和表情符号在JSON字符串中均为普通字符;仅需遵循标准JSON转义规则。切勿为了规避这些字符而重写内容——将标记属性内Liquid的单引号转换为双引号会破坏标记结构。若工具调用因格式错误被拒绝,只需修复JSON转义问题,重新发送原内容即可。
{{ }}{% %}Editing a template (read–modify–write)
编辑模板(读取-修改-写入)
content- — always fetch fresh; the returned
workflows-get-email-templateis the current source of truth.design - Modify the (keep subject/text alongside it).
design - — send the complete
workflows-update-email-templateback. The server re-renders the sent email from the edited design.content - — render the updated template so the user sees the change; its response carries the final rendered html, so read it before describing the result.
workflows-show-email-template
更新时会整体替换,而非合并——且自你上次查看后,人工可能已在PostHog可视化编辑器中修改过设计:
content- ——始终获取最新版本;返回的
workflows-get-email-template是当前的可信数据源。design - 修改(同时保留主题/文本内容)。
design - ——将完整的
workflows-update-email-template回传。服务器会根据编辑后的设计重新渲染待发送邮件。content - ——渲染更新后的模板供用户查看变更;其响应会包含最终渲染的HTML,因此在描述结果前请先阅读该内容。
workflows-show-email-template
Using templates
使用模板
- List what exists with (metadata only; fetch one for its content).
workflows-list-email-templates - When the user asks to see a template, call — it renders an inline preview.
workflows-show-email-template - Reference a template from a workflow's action, or start a broadcast from it in the PostHog UI.
function_email - Templates are soft-deleted by setting via
deleted: true.workflows-update-email-template
- 通过列出所有模板(仅返回元数据;需单独获取模板内容)。
workflows-list-email-templates - 当用户要求查看模板时,调用——它会生成内嵌预览。
workflows-show-email-template - 在工作流的操作中引用模板,或在PostHog UI中基于模板启动广播。
function_email - 通过设置
workflows-update-email-template可实现模板软删除。deleted: true