posthog-webhooks-events
Implement PostHog webhook destinations, Action-triggered notifications, and event querying via the Events API and HogQL. Trigger: "posthog webhook", "posthog events API", "posthog actions", "posthog notifications", "posthog event query", "posthog HogQL".
Best use case
posthog-webhooks-events is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Implement PostHog webhook destinations, Action-triggered notifications, and event querying via the Events API and HogQL. Trigger: "posthog webhook", "posthog events API", "posthog actions", "posthog notifications", "posthog event query", "posthog HogQL".
Teams using posthog-webhooks-events should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/posthog-webhooks-events/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How posthog-webhooks-events Compares
| Feature / Agent | posthog-webhooks-events | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Implement PostHog webhook destinations, Action-triggered notifications, and event querying via the Events API and HogQL. Trigger: "posthog webhook", "posthog events API", "posthog actions", "posthog notifications", "posthog event query", "posthog HogQL".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# PostHog Webhooks & Events
## Overview
PostHog sends webhooks via its CDP (Customer Data Platform) Destinations feature. You configure a Destination that fires when matching events are captured, sending an HTTP POST to your endpoint. This skill covers webhook destination setup, receiving and processing webhook payloads, querying events via the API, and using HogQL for custom event analysis.
## Prerequisites
- PostHog project with personal API key (`phx_...`)
- HTTPS endpoint to receive webhooks
- Events being captured in PostHog
## Instructions
### Step 1: Create a Webhook Destination via API
```bash
set -euo pipefail
# Create a webhook destination that fires on specific events
curl -X POST "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID/pipeline_destinations/" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Signup Notifications",
"description": "Send webhook when user signs up",
"config": {
"url": "https://your-app.com/webhooks/posthog",
"method": "POST",
"headers": {
"X-Webhook-Secret": "your-webhook-secret"
},
"body": {
"event": "{event}",
"distinct_id": "{distinct_id}",
"person": "{person}",
"properties": "{properties}",
"timestamp": "{timestamp}"
}
},
"filters": {
"events": [
{"id": "user_signed_up", "type": "events"},
{"id": "subscription_started", "type": "events"}
]
}
}'
```
### Step 2: Receive and Process Webhooks
```typescript
// api/webhooks/posthog.ts
import { NextResponse } from 'next/server';
import crypto from 'crypto';
const WEBHOOK_SECRET = process.env.POSTHOG_WEBHOOK_SECRET!;
// Verify webhook authenticity
function verifySignature(payload: string, signature: string): boolean {
const expected = crypto.createHmac('sha256', WEBHOOK_SECRET)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}
interface PostHogWebhookPayload {
event: string;
distinct_id: string;
properties: Record<string, any>;
person: {
properties: Record<string, any>;
};
timestamp: string;
}
export async function POST(request: Request) {
const body = await request.text();
const signature = request.headers.get('x-webhook-secret') || '';
// Verify webhook is from PostHog
if (WEBHOOK_SECRET && signature !== WEBHOOK_SECRET) {
return NextResponse.json({ error: 'Invalid signature' }, { status: 401 });
}
const payload: PostHogWebhookPayload = JSON.parse(body);
// Route to handlers based on event type
switch (payload.event) {
case 'user_signed_up':
await onUserSignup(payload);
break;
case 'subscription_started':
await onSubscriptionStarted(payload);
break;
case 'subscription_canceled':
await onSubscriptionCanceled(payload);
break;
default:
console.log(`Unhandled PostHog event: ${payload.event}`);
}
return NextResponse.json({ received: true });
}
async function onUserSignup(payload: PostHogWebhookPayload) {
const { distinct_id, properties, person } = payload;
console.log(`New signup: ${distinct_id}`);
// Sync to CRM
await fetch('https://api.hubspot.com/contacts/v1/contact/', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.HUBSPOT_KEY}` },
body: JSON.stringify({
properties: [
{ property: 'email', value: person.properties.email },
{ property: 'posthog_id', value: distinct_id },
],
}),
});
// Notify Slack
await fetch(process.env.SLACK_WEBHOOK_URL!, {
method: 'POST',
body: JSON.stringify({
text: `New signup: ${person.properties.email || distinct_id} (${properties.source || 'unknown'})`,
}),
});
}
async function onSubscriptionStarted(payload: PostHogWebhookPayload) {
console.log(`New subscription: ${payload.distinct_id}, plan: ${payload.properties.plan}`);
}
async function onSubscriptionCanceled(payload: PostHogWebhookPayload) {
console.log(`Cancellation: ${payload.distinct_id}`);
}
```
### Step 3: Query Events via the API
```bash
set -euo pipefail
# List recent events by type
curl "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID/events/?event=user_signed_up&limit=10&orderBy=-timestamp" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" | \
jq '.results[] | {
distinct_id,
event,
timestamp,
properties: (.properties | {source, plan, referrer: ."$referrer"})
}'
# Get events for a specific person
curl "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID/events/?distinct_id=user-123&limit=20" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" | \
jq '.results[] | {event, timestamp}'
```
### Step 4: Query Events with HogQL
```typescript
// Complex event analysis with HogQL (PostHog's SQL dialect)
async function queryPostHog(hogql: string) {
const response = await fetch(
`https://app.posthog.com/api/projects/${process.env.POSTHOG_PROJECT_ID}/query/`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.POSTHOG_PERSONAL_API_KEY}`,
},
body: JSON.stringify({
query: { kind: 'HogQLQuery', query: hogql },
}),
}
);
return response.json();
}
// Example: Signup funnel analysis
const funnelData = await queryPostHog(`
SELECT
properties.$referrer AS referrer,
count() AS signups,
uniq(distinct_id) AS unique_users
FROM events
WHERE event = 'user_signed_up'
AND timestamp > now() - interval 30 day
GROUP BY referrer
ORDER BY signups DESC
LIMIT 20
`);
// Example: Feature adoption by plan
const adoptionData = await queryPostHog(`
SELECT
person.properties.plan AS plan,
properties.feature_name AS feature,
count() AS usage_count,
uniq(distinct_id) AS unique_users
FROM events
WHERE event = 'feature_used'
AND timestamp > now() - interval 7 day
GROUP BY plan, feature
ORDER BY usage_count DESC
LIMIT 50
`);
```
### Step 5: Set Up Slack Webhook Destination (UI)
PostHog has built-in Slack integration via Data Pipelines > Destinations:
1. Go to Data Pipelines > Destinations > New Destination
2. Select "Slack" or "Webhook"
3. Configure event filters (which events trigger the notification)
4. Set the webhook URL and message template
5. Test with a sample event
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| Webhook not firing | No matching destination filter | Check event name matches filter exactly |
| Duplicate webhooks | Event matches multiple destinations | Narrow destination filters |
| Webhook timeout | Handler too slow | Acknowledge with 200 immediately, process async |
| HogQL query timeout | Unfiltered table scan | Add `timestamp >` filter and `LIMIT` |
| 429 on events API | Too many queries | Cache results, reduce polling frequency |
## Output
- Webhook destination configured for specific events
- Express/Next.js webhook handler with event routing
- Event queries via REST API and HogQL
- Slack/CRM integration on user lifecycle events
## Resources
- [PostHog CDP Destinations](https://posthog.com/docs/cdp/destinations)
- [PostHog Webhook Destination](https://posthog.com/docs/cdp/destinations/webhook)
- [PostHog Events API](https://posthog.com/docs/api/events)
- [HogQL Documentation](https://posthog.com/docs/sql)
## Next Steps
For deployment setup, see `posthog-deploy-integration`.Related Skills
workhuman-webhooks-events
Workhuman webhooks events for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman webhooks events".
wispr-webhooks-events
Wispr Flow webhooks events for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr webhooks events".
windsurf-webhooks-events
Build Windsurf extensions and integrate with VS Code extension API events. Use when building custom Windsurf extensions, tracking editor events, or integrating Windsurf with external tools via extension development. Trigger with phrases like "windsurf extension", "windsurf events", "windsurf plugin", "build windsurf extension", "windsurf API".
webflow-webhooks-events
Implement Webflow webhook registration, signature verification, and event handling for form_submission, site_publish, ecomm_new_order, page_created, and more. Use when setting up webhook endpoints, implementing event-driven workflows, or handling Webflow notifications. Trigger with phrases like "webflow webhook", "webflow events", "webflow webhook signature", "handle webflow events", "webflow notifications".
vercel-webhooks-events
Implement Vercel webhook handling with signature verification and event processing. Use when setting up webhook endpoints, processing deployment events, or building integrations that react to Vercel deployment lifecycle. Trigger with phrases like "vercel webhook", "vercel events", "vercel deployment.ready", "handle vercel events", "vercel webhook signature".
veeva-webhooks-events
Veeva Vault webhooks events for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva webhooks events".
vastai-webhooks-events
Build event-driven workflows around Vast.ai instance lifecycle events. Use when monitoring instance status changes, implementing auto-recovery, or building event-driven GPU orchestration. Trigger with phrases like "vastai events", "vastai instance monitoring", "vastai status changes", "vastai lifecycle events".
twinmind-webhooks-events
Handle TwinMind meeting events including transcription completion, action item extraction, and calendar sync notifications. Use when implementing webhooks events, or managing TwinMind meeting AI operations. Trigger with phrases like "twinmind webhooks events", "twinmind webhooks events".
together-webhooks-events
Together AI webhooks events for inference, fine-tuning, and model deployment. Use when working with Together AI's OpenAI-compatible API. Trigger: "together webhooks events".
techsmith-webhooks-events
TechSmith webhooks events for Snagit COM API and Camtasia automation. Use when working with TechSmith screen capture and video editing automation. Trigger: "techsmith webhooks events".
supabase-webhooks-events
Implement Supabase database webhooks, pg_net async HTTP, LISTEN/NOTIFY, and Edge Function event handlers with signature verification. Use when setting up database webhooks for INSERT/UPDATE/DELETE events, sending HTTP requests from PostgreSQL triggers, handling Realtime postgres_changes as an event source, or building event-driven architectures. Trigger with phrases like "supabase webhook", "database events", "pg_net trigger", "supabase LISTEN NOTIFY", "webhook signature verify", "supabase event-driven", "supabase_functions.http_request".
stackblitz-webhooks-events
WebContainer lifecycle events: server-ready, port changes, error handling. Use when working with WebContainers or StackBlitz SDK. Trigger: "webcontainer events".