New to Claude Skills? Learn how to install them →

posthog on GitHub

Sending Notifications

Free

Integrate real-time notifications into PostHog features.

by posthog37.6k stars on posthog/posthog
1 views
Updated Aug 11, 2026
Get this skill

Free · Opens the source repo

What Sending Notifications does

The Sending Notifications skill allows developers to implement real-time in-app notifications within PostHog applications. This skill is essential when adding notification capabilities to various features, such as alerting users about comments, approvals, or system alerts. By utilizing a simple facade API, developers can easily create notifications that enhance user engagement and streamline communication.

To use the skill, developers import the necessary functions and data structures from the facade. The primary function, create_notification, requires a NotificationData object, which includes fields such as team_id, notification_type, title, and body. This structured approach ensures that notifications are contextually relevant and delivered to the appropriate users or groups based on their roles or team membership. The skill also supports various notification types, allowing for flexibility in how alerts are communicated.

The skill is particularly useful for teams looking to improve their user experience by providing timely updates and alerts. It can be integrated into new features or existing workflows where notifications are necessary. By defining the priority of notifications, developers can control how intrusive they are, ensuring that critical alerts stand out without overwhelming users with excessive notifications.

Overall, this skill is designed for developers who are working with PostHog and need to implement a reliable notification system. Its straightforward API and customizable options make it a valuable addition to any PostHog project, enhancing both functionality and user interaction.

When to use it

Use this skill when integrating notification support into new or existing PostHog features that require user alerts or updates.

When not to use it

This skill is not suitable for applications outside of the PostHog ecosystem or for scenarios where notifications are not needed.

What you can build with it

User Mention Notifications

Notify users when they are mentioned in comments or discussions, enhancing collaboration.

Alert Notifications

Send alerts when system thresholds are breached, ensuring users are aware of critical issues.

Approval Requests

Notify users when their approval is required for changes, streamlining workflows.

How to install Sending Notifications

View source

1. Install with the skills CLI

npx skills add posthog/posthog/sending-notifications --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by posthog

Sending real-time notifications

When to use this

You're adding notification support to a PostHog feature — for example, notifying a user when they're mentioned in a comment, when an alert fires, or when an approval is requested.

The facade API

All notification creation goes through a single function. Import from the facade, not from internal modules:

from products.notifications.backend.facade.api import (
    create_notification,
    NotificationData,
    NotificationType,
    Priority,
    TargetType,
)

Build a NotificationData and call create_notification:

event = create_notification(
    NotificationData(
        team_id=team.id,
        notification_type=NotificationType.ALERT_FIRING,
        priority=Priority.CRITICAL,
        title="Event ingestion latency > 30s",
        body="Events are queuing up. Ingestion pipeline is degraded.",
        target_type=TargetType.USER,
        target_id=str(user.id),
        resource_type="dashboard",
        resource_id="42",
        source_url="/dashboard/42",
    )
)

Returns a NotificationEvent on success, or None if the feature flag is disabled, no recipients were resolved, or the team doesn't exist. Safe to call in any context.

NotificationData fields

Required:

FieldTypeDescription
team_idintTeam context — used to look up the organization and check the feature flag
notification_typeNotificationTypeDetermines the icon in the UI
titlestrNotification headline (~100 chars recommended)
bodystrLonger description shown on expand. Can be empty string
target_typeTargetTypeWho receives this: user, team, organization, or role
target_idstrID of the target (user ID, team ID, org UUID, or role UUID as string)

Optional:

FieldTypeDefaultDescription
resource_typeNotificationResourceType | NoneNoneAccess-controlled types (e.g. "dashboard") auto-filter recipients without viewer access
resource_idstr""ID of the resource for linking
source_urlstr""Relative URL path (e.g. /dashboard/42), shown as link icon in UI
priorityPriorityNORMALnormal = popover only; critical = popover + persistent toast
archivableboolFalseOpt in to a per-recipient "archive" (dismiss) action that moves the notification to the recipient's Archived tab. When False, recipients can only mark it read/unread (the default pattern)
resolverRecipientsResolver | NoneNoneCustom recipient resolver. Default handles user/team/org/role targeting

Choosing parameters

Notification type

TypeWhen to use
comment_mentionUser was @mentioned in a comment or discussion
alert_firingA monitoring alert threshold was breached
approval_requestedA change requires the user's approval
approval_resolvedAn approval the user requested has been resolved
pipeline_failureA data pipeline or batch export failed
issue_assignedAn error tracking issue was assigned to the user

Priority

Be very careful with critical. It triggers a persistent toast popup that overlays the user's screen and must be manually dismissed. This is intentionally intrusive — reserve it for genuine emergencies like outages, security alerts, or SLA breaches. Overusing critical will train users to ignore notifications entirely. When in doubt, use normal.

Target type

Targettarget_id valueRecipients
userUser IDJust that user
teamTeam IDAll members of the team's organization
organizationOrganization IDAll organization members
roleRole IDAll users with that RBAC role

Resource type and access control

When resource_type matches an access-controlled resource (dashboard, feature_flag, experiment, etc.), recipients without viewer access are automatically excluded. For notification-only types (pipeline, approval, comment), no AC filtering is applied.

Delivery pipeline

Django (create_notification)
  → Postgres (NotificationEvent row)
  → Kafka (notification_events topic, on transaction commit)
  → Go livestream service (Kafka consumer)
  → Redis SPUBLISH (sharded pub/sub, keyed by org ID)
  → SSE (/notifications endpoint)
  → Browser (popover + optional toast)

Kafka publish happens on transaction.on_commit — won't fire if the transaction rolls back.

Adding a new notification type

  1. Add enum value in products/notifications/backend/facade/enums.py
  2. Add icon mapping in frontend/src/lib/components/NotificationsMenu/notificationToasts.tsx (NOTIFICATION_TYPE_ICONS) — the single icon source, read by getNotificationIcon, which only NotificationRow calls; the side panel gets the icon by rendering that row
  3. Add a label + description entry in frontend/src/lib/components/NotificationsMenu/NotificationRow.tsx (REALTIME_NOTIFICATION_TYPE_META) — drives the per-type notification preferences UI
  4. Run python manage.py makemigrations notifications

Testing

Mock the feature flag in tests:

from unittest.mock import patch

with patch("posthoganalytics.feature_enabled", side_effect=lambda flag, *a, **kw: flag == "real-time-notifications"):
    event = create_notification(data)

Frequently asked questions about Sending Notifications

Similar skills