managing-subscriptions

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Managing subscriptions

管理订阅

This skill guides you through managing PostHog subscriptions. Subscriptions deliver scheduled snapshots of insights or dashboards via email, Slack, or webhook.
本技能将引导您管理PostHog订阅。 订阅会按计划通过邮件、Slack或Webhook发送洞察或仪表板的快照。

When to use this skill

使用场景

Use this skill when the user:
  • Wants to "track", "follow", "subscribe to", or "get updates" about an insight or dashboard
  • Asks for "daily updates", "weekly reports", or "send me this every morning"
  • Wants to know what subscriptions they have
  • Asks to stop, pause, or unsubscribe from something
  • Wants to change who receives an update or how often
当用户有以下需求时,使用本技能:
  • 想要“追踪”“关注”“订阅”或“获取”某一洞察或仪表板的更新
  • 要求“每日更新”“每周报告”或“每天早上给我发送这个”
  • 想了解自己有哪些订阅
  • 请求停止、暂停或取消订阅
  • 想要更改接收更新的人员或频率

Subscriptions vs alerts

订阅与告警的区别

Subscriptions and alerts serve different purposes:
  • Subscriptions deliver a snapshot on a fixed schedule (daily, weekly, etc.) regardless of the data
  • Alerts fire only when a condition is met (threshold crossed, anomaly detected)
If the user says "notify me when this drops below 100", use alerts. If the user says "send me this every morning", use subscriptions.
订阅和告警的用途不同:
  • 订阅:无论数据如何,都会按固定时间表(每日、每周等)发送快照
  • 告警:仅在满足特定条件时触发(如阈值突破、检测到异常)
如果用户说“当数值低于100时通知我”,请使用告警功能。 如果用户说“每天早上给我发送这个”,请使用订阅功能。

Workflow

工作流程

Listing existing subscriptions

查看现有订阅

Before creating a new subscription, check if one already exists.
Use
subscriptions-list
with optional filters:
  • Filter by insight: pass the
    insight
    query parameter with the insight ID
  • Filter by dashboard: pass the
    dashboard
    query parameter with the dashboard ID
  • Filter by channel: pass
    target_type
    as
    email
    ,
    slack
    , or
    webhook
创建新订阅前,请先检查是否已存在相关订阅。
使用
subscriptions-list
接口,并可添加可选筛选条件:
  • 按洞察筛选:传入
    insight
    查询参数,值为洞察ID
  • 按仪表板筛选:传入
    dashboard
    查询参数,值为仪表板ID
  • 按渠道筛选:传入
    target_type
    参数,值为
    email
    slack
    webhook

Creating a subscription

创建订阅

Step 1: Ask the user how they want to receive it

步骤1:询问用户接收方式

Always ask the user whether they want email or Slack delivery before creating a subscription. Do not assume a channel — ask explicitly:
Would you like to receive this via email or Slack?
If the user says Slack, you must verify the integration is available (see step 2). If the user doesn't have a preference, suggest email as the simplest option.
创建订阅前,务必询问用户希望通过邮件还是Slack接收。 不要默认渠道——明确询问:
您希望通过邮件还是Slack接收订阅内容?
如果用户选择Slack,必须验证集成是否可用(见步骤2)。 如果用户没有偏好,建议选择邮件作为最简单的选项。

Step 2: Verify channel availability

步骤2:验证渠道可用性

Email requires no setup — it works out of the box. You just need the user's email address. Get it from the user context or from
org-members-list
.
Slack requires a connected Slack integration. Before creating a Slack subscription:
  1. Call
    integrations-list
    and look for an integration where
    kind
    is
    "slack"
  2. If a Slack integration exists, note its
    id
    — you'll need it as
    integration_id
  3. If no Slack integration exists, tell the user:
    Slack isn't connected to this project yet. You can set it up in Project settings > Integrations. In the meantime, would you like to receive this via email instead?
Slack setup requires an OAuth flow in the browser — it cannot be done via MCP.
Webhook requires the user to provide a URL. Verify it looks like a valid URL before submitting.
邮件无需设置——开箱即用。您只需获取用户的邮箱地址。 可从用户上下文或
org-members-list
接口获取。
Slack需要已连接的Slack集成。创建Slack订阅前:
  1. 调用
    integrations-list
    接口,查找
    kind
    "slack"
    的集成
  2. 如果存在Slack集成,记录其
    id
    ——创建时需将其作为
    integration_id
    参数传入
  3. 如果没有Slack集成,请告知用户:
    当前项目尚未连接Slack。您可以在项目设置 > 集成中完成设置。 在此期间,是否改为通过邮件接收订阅内容?
Slack设置需要在浏览器中完成OAuth流程——无法通过MCP操作。
Webhook需要用户提供URL。提交前请验证其格式是否为有效URL。

Step 3: Identify the target

步骤3:确定目标对象

Get the insight ID or dashboard ID. If the user provides a URL like
/project/2/insights/pKxzopBG
, fetch the insight first with
insight-get
to get the numeric ID.
获取洞察ID或仪表板ID。如果用户提供类似
/project/2/insights/pKxzopBG
的URL, 先调用
insight-get
接口获取该洞察的数字ID。

Step 4: Determine delivery settings from the user's request

步骤4:根据用户请求确定发送设置

User saysParameters
"every day" / "daily" / "every morning"
frequency: "daily"
"every week" / "weekly"
frequency: "weekly"
"every Monday"
frequency: "weekly"
,
byweekday: ["monday"]
"every month" / "monthly"
frequency: "monthly"
"twice a week"
frequency: "weekly"
,
interval: 1
,
byweekday: ["monday", "thursday"]
用户表述参数设置
"每天" / "每日" / "每天早上"
frequency: "daily"
"每周" / "每周一次"
frequency: "weekly"
"每周一"
frequency: "weekly"
,
byweekday: ["monday"]
"每月" / "每月一次"
frequency: "monthly"
"每周两次"
frequency: "weekly"
,
interval: 1
,
byweekday: ["monday", "thursday"]

Step 5: Create with
subscriptions-create

步骤5:调用
subscriptions-create
接口创建订阅

For an insight subscription via email:
json
{
  "insight": 12345,
  "target_type": "email",
  "target_value": "user@example.com",
  "frequency": "daily",
  "start_date": "2025-01-01T09:00:00Z"
}
For a dashboard subscription (requires selecting which insights to include, max 6):
json
{
  "dashboard": 67,
  "dashboard_export_insights": [101, 102, 103],
  "target_type": "email",
  "target_value": "user@example.com",
  "frequency": "weekly",
  "byweekday": ["monday"],
  "start_date": "2025-01-01T09:00:00Z"
}
For Slack delivery, include the
integration_id
from step 2:
json
{
  "insight": 12345,
  "target_type": "slack",
  "target_value": "#general",
  "integration_id": 789,
  "frequency": "daily",
  "start_date": "2025-01-01T09:00:00Z"
}
通过邮件发送的洞察订阅示例:
json
{
  "insight": 12345,
  "target_type": "email",
  "target_value": "user@example.com",
  "frequency": "daily",
  "start_date": "2025-01-01T09:00:00Z"
}
仪表板订阅示例(需选择要包含的洞察,最多6个):
json
{
  "dashboard": 67,
  "dashboard_export_insights": [101, 102, 103],
  "target_type": "email",
  "target_value": "user@example.com",
  "frequency": "weekly",
  "byweekday": ["monday"],
  "start_date": "2025-01-01T09:00:00Z"
}
Slack发送的订阅示例,需包含步骤2中的
integration_id
json
{
  "insight": 12345,
  "target_type": "slack",
  "target_value": "#general",
  "integration_id": 789,
  "frequency": "daily",
  "start_date": "2025-01-01T09:00:00Z"
}

Updating a subscription

更新订阅

Use
subscriptions-partial-update
with the subscription ID. Common updates:
  • Change frequency:
    {"frequency": "weekly", "byweekday": ["monday"]}
  • Add recipients: Update
    target_value
    with the full comma-separated list
  • Change channel: Update
    target_type
    and
    target_value
    together
使用
subscriptions-partial-update
接口,传入订阅ID。常见更新操作:
  • 更改频率
    {"frequency": "weekly", "byweekday": ["monday"]}
  • 添加收件人:更新
    target_value
    为完整的逗号分隔列表
  • 更改渠道:同时更新
    target_type
    target_value

Deactivating a subscription

停用订阅

Subscriptions are soft-deleted. Use
subscriptions-partial-update
:
json
{
  "id": 456,
  "deleted": true
}
订阅采用软删除方式。使用
subscriptions-partial-update
接口:
json
{
  "id": 456,
  "deleted": true
}

Defaults

默认设置

When the user doesn't specify details:
  • Frequency:
    "daily"
  • Channel: email to the current user
  • Start date: now (ISO 8601)
  • Title: auto-generated from the insight/dashboard name if not specified
当用户未指定细节时:
  • 频率
    "daily"
  • 渠道:发送到当前用户的邮箱
  • 开始日期:当前时间(ISO 8601格式)
  • 标题:如果未指定,则自动从洞察/仪表板名称生成

Error handling

错误处理

  • Duplicate check: If a subscription already exists for the same insight/dashboard and channel, inform the user and offer to update it rather than creating a duplicate
  • Slack not connected: If a Slack subscription is requested but no Slack integration exists, explain that Slack must be connected in Project settings > Integrations first, then offer email as an alternative. Do not attempt to create the subscription — it will fail with a validation error
  • Slack integration wrong team: The Slack integration must belong to the same PostHog team. If
    integrations-list
    returns Slack integrations but creation still fails, the integration may be misconfigured
  • Dashboard insights: Dashboard subscriptions require at least 1 and at most 6 insights selected via
    dashboard_export_insights
    . If the user doesn't specify which insights, fetch the dashboard with
    dashboard-get
    and select the first 6 insights from its tiles
  • 重复检查:如果同一洞察/仪表板和渠道已存在订阅,请告知用户并提供更新选项,而非创建重复订阅
  • Slack未连接:如果用户请求Slack订阅但未连接Slack集成,请说明需先在项目设置 > 集成中连接Slack,然后提供邮件作为替代方案。请勿尝试创建订阅——否则会触发验证错误
  • Slack集成团队错误:Slack集成必须属于当前PostHog团队。如果
    integrations-list
    返回Slack集成但创建仍失败,可能是集成配置有误
  • 仪表板洞察数量:仪表板订阅需通过
    dashboard_export_insights
    选择至少1个、最多6个洞察。如果用户未指定选择哪些洞察,请调用
    dashboard-get
    接口获取仪表板信息,并从其组件中选择前6个洞察