Webhook-Based Integrations
New to building integrations? Start with our step-by-step contributor guide for a quick overview.
When to Use Webhooks
Choose webhook-based integrations when:- The service provides real-time webhook events
- You need instant synchronization (chat messages, notifications)
- Events are user-triggered and need immediate capture
- The service has robust webhook infrastructure
Architecture Overview
Event Flow
1. SETUP Event
When a user connects their account via OAuth:2. IDENTIFY Event
When a webhook event arrives, extract the user identifier for routing:3. PROCESS Event
Process the webhook event and create activity messages:Full Example: Slack Integration
spec.json
index.ts
create-activity.ts
Best Practices
1. Event Filtering
Only process events that are relevant to the user’s knowledge graph:2. Context Enrichment
Provide rich context by fetching related data:3. Deep Linking
Always provide sourceURL for navigation back to the original content:4. Error Handling
Handle errors gracefully without breaking the integration:5. User Identification
Properly extract user IDs for different event types:Testing Webhooks Locally
To test webhooks during development:-
Use ngrok for local tunneling:
-
Configure webhook URL in service (Slack):
- Test events by triggering actions in Slack
- Check logs for event payloads and processing
Common Event Types
Slack
message- New message postedreaction_added- Emoji reaction addedreaction_removed- Emoji reaction removedmember_joined_channel- User joined channelapp_mention- Bot was mentioned
Discord
MESSAGE_CREATE- New messageMESSAGE_REACTION_ADD- Reaction addedGUILD_MEMBER_ADD- Member joined server
Linear
Issue- Issue created/updatedComment- Comment addedIssueLabel- Label changed
