A Slack bot that creates PostHog annotations when you @mention it in a thread.
- Someone posts a message in Slack (e.g., "Deployed checkout v2.0")
- Reply in thread and @mention the bot:
@PostHog Bot release deployment - Bot creates an annotation in PostHog with the original message + your note
- Bot replies with confirmation and link to the annotation
- Go to api.slack.com/apps → Create New App → From scratch
- Name it (e.g., "PostHog Annotations") and select your workspace
OAuth & Permissions:
- Add Bot Token Scopes:
app_mentions:read- To receive @mentionschannels:history- To read parent messages in public channelsgroups:history- To read parent messages in private channelschat:write- To reply with confirmationusers:read- To get user names for attribution
- Install to Workspace and copy the Bot User OAuth Token (
xoxb-...)
Event Subscriptions:
- Enable Events
- Subscribe to bot events:
app_mention
- Request URL: Set this after deploying (Step 4)
- Go to PostHog → Settings → Personal API Keys
- Create a new key with
annotationwrite scope - Note your Project ID from Project Settings
cp .env.example .env
# Edit .env with your valuesRequires AWS SAM CLI.
# Build
sam build
# Deploy (will prompt for parameters on first run)
sam deploy --guidedAfter deployment, you'll get an endpoint URL like:
https://xxxxxxxxxx.execute-api.ap-south-1.amazonaws.com/Prod/slack/events
- Go back to your Slack App → Event Subscriptions
- Set Request URL to your Lambda endpoint
- Slack will verify the endpoint automatically
Invite the bot to the channel(s) where you want to use it:
/invite @PostHog Annotations
Original message: "Just deployed the new payment flow to production"
└── @PostHog Bot payment system release
└── ✅ Annotation created in PostHog!
The annotation will include:
- The original message text
- Your custom note (if provided)
- Attribution (who posted the original message)
sam build # Build the application
sam deploy # Deploy to dev stage
sam deploy --config-env prod # Deploy to production
sam logs -n SlackFunction --tail # Tail Lambda logs
sam delete # Remove the stack