Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5ca66c3
refactor(webhooks): extract provider-specific logic into handler regi…
waleedlatif1 Apr 6, 2026
925be3d
feat(triggers): add Salesforce webhook triggers (#3982)
waleedlatif1 Apr 6, 2026
c9b45f4
feat(triggers): add HubSpot merge, restore, and generic webhook trigg…
waleedlatif1 Apr 6, 2026
62a7700
feat(integrations): add Sixtyfour AI integration (#3981)
waleedlatif1 Apr 6, 2026
796384a
feat(triggers): add Resend webhook triggers with auto-registration (#…
waleedlatif1 Apr 6, 2026
62ea0f1
feat(triggers): add Gong webhook triggers for call events (#3984)
waleedlatif1 Apr 6, 2026
590f376
feat(triggers): add Intercom webhook triggers (#3990)
waleedlatif1 Apr 6, 2026
7ea0693
feat(triggers): add Greenhouse webhook triggers (#3985)
waleedlatif1 Apr 6, 2026
21e5b5c
feat(triggers): add Notion webhook triggers (#3989)
waleedlatif1 Apr 6, 2026
c18f023
feat(analytics): add Google Tag Manager and Google Analytics for host…
waleedlatif1 Apr 6, 2026
8b1d749
feat(triggers): add Vercel webhook triggers with automatic registrati…
waleedlatif1 Apr 6, 2026
cd5cee3
feat(landing): add PostHog tracking for CTA clicks, demo requests, an…
waleedlatif1 Apr 6, 2026
18a7868
feat(triggers): add Zoom webhook triggers (#3992)
waleedlatif1 Apr 6, 2026
5ea63f1
feat(triggers): add Linear v2 triggers with automatic webhook registr…
waleedlatif1 Apr 6, 2026
7e0794c
fix(signup): show multiple signup errors at once (#3987)
TheodoreSpeaks Apr 6, 2026
58571fe
fix(hitl): fix stream endpoint, pause persistence, and resume page (#…
waleedlatif1 Apr 6, 2026
2164cef
fix(mothership): fix url keeping markdown hash on resource switch (#3…
TheodoreSpeaks Apr 7, 2026
8c8c627
feat(block): Conditionally hide impersonateUser field from block, add…
TheodoreSpeaks Apr 7, 2026
25b4a3f
feat(posthog): Add posthog log for signup failed (#3998)
TheodoreSpeaks Apr 7, 2026
df2c47a
fix(copilot): fix copilot running workflow stuck on 10mb error (#3999)
TheodoreSpeaks Apr 7, 2026
8df3f20
fix(blocks): allow tool expansion in disabled mode, improve child dep…
waleedlatif1 Apr 7, 2026
5eb494d
fix(secrets): secrets/integrations component code cleanup (#4003)
icecrasher321 Apr 7, 2026
606477e
feat(home): add folders to resource menu (#4000)
waleedlatif1 Apr 7, 2026
cc8c9e8
feat(home): add double-enter to send top queued message (#4005)
waleedlatif1 Apr 7, 2026
c52834b
fix(subflows): make edges inside subflows directly clickable (#3969)
waleedlatif1 Apr 7, 2026
609ba61
fix(sockets): joining currently deleted workflow (#4004)
icecrasher321 Apr 7, 2026
89ae738
feat(folders): soft-delete folders and show in Recently Deleted (#4001)
waleedlatif1 Apr 7, 2026
64c6cd9
fix(webhooks): harden audited provider triggers (#3997)
waleedlatif1 Apr 7, 2026
8e11c32
fix(resource-menu): consistent height between 1 result and no results…
waleedlatif1 Apr 7, 2026
1e00a06
fix(home): simplify enter-to-send queued message to single press (#4008)
waleedlatif1 Apr 7, 2026
7793583
fix(secrets): restore unsaved-changes guard for settings tab navigati…
waleedlatif1 Apr 7, 2026
68df732
refactor(triggers): consolidate v2 Linear triggers into same files as…
waleedlatif1 Apr 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(triggers): add Notion webhook triggers (#3989)
* feat(triggers): add Notion webhook triggers for all event types

Add 9 Notion webhook triggers covering the full event lifecycle:
- Page events: created, properties updated, content updated, deleted
- Database events: created, schema updated, deleted
- Comment events: created
- Generic webhook trigger (all events)

Implements provider handler with HMAC SHA-256 signature verification,
event filtering via matchEvent, and structured input formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(triggers): resolve type field collision in Notion trigger outputs

Rename nested `type` fields to `entity_type`/`parent_type` to avoid
collision with processOutputField's leaf node detection which checks
`'type' in field`. Remove spread of author outputs into `authors`
array which was overwriting `type: 'array'`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(triggers): clarify Notion webhook signing secret vs verification_token

Update placeholder and description to distinguish the signing secret
(used for HMAC-SHA256 signature verification) from the verification_token
(one-time challenge echoed during initial setup).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(webhooks): use createHmacVerifier for Notion provider handler

Replace inline verifyAuth boilerplate with createHmacVerifier utility,
consistent with Linear, Ashby, Cal.com, Circleback, Confluence, and
Fireflies providers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
  • Loading branch information
waleedlatif1 and claude authored Apr 6, 2026
commit 21e5b5c594c2c96bb03ec09944dc2e7ffaaa6715
50 changes: 48 additions & 2 deletions apps/sim/app/(landing)/integrations/data/integrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -8180,8 +8180,54 @@
"docsUrl": "https://docs.sim.ai/tools/notion",
"operations": [],
"operationCount": 0,
"triggers": [],
"triggerCount": 0,
"triggers": [
{
"id": "notion_page_created",
"name": "Notion Page Created",
"description": "Trigger workflow when a new page is created in Notion"
},
{
"id": "notion_page_properties_updated",
"name": "Notion Page Properties Updated",
"description": "Trigger workflow when page properties are modified in Notion"
},
{
"id": "notion_page_content_updated",
"name": "Notion Page Content Updated",
"description": "Trigger workflow when page content is changed in Notion"
},
{
"id": "notion_page_deleted",
"name": "Notion Page Deleted",
"description": "Trigger workflow when a page is deleted in Notion"
},
{
"id": "notion_database_created",
"name": "Notion Database Created",
"description": "Trigger workflow when a new database is created in Notion"
},
{
"id": "notion_database_schema_updated",
"name": "Notion Database Schema Updated",
"description": "Trigger workflow when a database schema is modified in Notion"
},
{
"id": "notion_database_deleted",
"name": "Notion Database Deleted",
"description": "Trigger workflow when a database is deleted in Notion"
},
{
"id": "notion_comment_created",
"name": "Notion Comment Created",
"description": "Trigger workflow when a comment or suggested edit is added in Notion"
},
{
"id": "notion_webhook",
"name": "Notion Webhook (All Events)",
"description": "Trigger workflow on any Notion webhook event"
}
],
"triggerCount": 9,
"authType": "oauth",
"category": "tools",
"integrationType": "documents",
Expand Down
30 changes: 29 additions & 1 deletion apps/sim/blocks/blocks/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { BlockConfig } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { createVersionedToolSelector } from '@/blocks/utils'
import type { NotionResponse } from '@/tools/notion/types'
import { getTrigger } from '@/triggers'

// Legacy block - hidden from toolbar
export const NotionBlock: BlockConfig<NotionResponse> = {
Expand Down Expand Up @@ -436,7 +437,34 @@ export const NotionV2Block: BlockConfig<any> = {
bgColor: '#181C1E',
icon: NotionIcon,
hideFromToolbar: false,
subBlocks: NotionBlock.subBlocks,
subBlocks: [
...NotionBlock.subBlocks,

// Trigger subBlocks
...getTrigger('notion_page_created').subBlocks,
...getTrigger('notion_page_properties_updated').subBlocks,
...getTrigger('notion_page_content_updated').subBlocks,
...getTrigger('notion_page_deleted').subBlocks,
...getTrigger('notion_database_created').subBlocks,
...getTrigger('notion_database_schema_updated').subBlocks,
...getTrigger('notion_database_deleted').subBlocks,
...getTrigger('notion_comment_created').subBlocks,
...getTrigger('notion_webhook').subBlocks,
],
triggers: {
enabled: true,
available: [
'notion_page_created',
'notion_page_properties_updated',
'notion_page_content_updated',
'notion_page_deleted',
'notion_database_created',
'notion_database_schema_updated',
'notion_database_deleted',
'notion_comment_created',
'notion_webhook',
],
},
tools: {
access: [
'notion_read_v2',
Expand Down
100 changes: 100 additions & 0 deletions apps/sim/lib/webhooks/providers/notion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import crypto from 'crypto'
import { createLogger } from '@sim/logger'
import { NextResponse } from 'next/server'
import { safeCompare } from '@/lib/core/security/encryption'
import type {
EventMatchContext,
FormatInputContext,
FormatInputResult,
WebhookProviderHandler,
} from '@/lib/webhooks/providers/types'
import { createHmacVerifier } from '@/lib/webhooks/providers/utils'

const logger = createLogger('WebhookProvider:Notion')

/**
* Validates a Notion webhook signature using HMAC SHA-256.
* Notion sends X-Notion-Signature as "sha256=<hex>".
*/
function validateNotionSignature(secret: string, signature: string, body: string): boolean {
try {
if (!secret || !signature || !body) {
logger.warn('Notion signature validation missing required fields', {
hasSecret: !!secret,
hasSignature: !!signature,
hasBody: !!body,
})
return false
}

const providedHash = signature.startsWith('sha256=') ? signature.slice(7) : signature
const computedHash = crypto.createHmac('sha256', secret).update(body, 'utf8').digest('hex')

logger.debug('Notion signature comparison', {
computedSignature: `${computedHash.substring(0, 10)}...`,
providedSignature: `${providedHash.substring(0, 10)}...`,
computedLength: computedHash.length,
providedLength: providedHash.length,
match: computedHash === providedHash,
})

return safeCompare(computedHash, providedHash)
} catch (error) {
logger.error('Error validating Notion signature:', error)
return false
}
}

export const notionHandler: WebhookProviderHandler = {
verifyAuth: createHmacVerifier({
configKey: 'webhookSecret',
headerName: 'X-Notion-Signature',
validateFn: validateNotionSignature,
providerLabel: 'Notion',
}),

async formatInput({ body }: FormatInputContext): Promise<FormatInputResult> {
const b = body as Record<string, unknown>
return {
input: {
id: b.id,
type: b.type,
timestamp: b.timestamp,
workspace_id: b.workspace_id,
workspace_name: b.workspace_name,
subscription_id: b.subscription_id,
integration_id: b.integration_id,
attempt_number: b.attempt_number,
authors: b.authors || [],
entity: b.entity || {},
data: b.data || {},
},
}
},

async matchEvent({ webhook, workflow, body, requestId, providerConfig }: EventMatchContext) {
const triggerId = providerConfig.triggerId as string | undefined
const obj = body as Record<string, unknown>

if (triggerId && triggerId !== 'notion_webhook') {
const { isNotionPayloadMatch } = await import('@/triggers/notion/utils')
if (!isNotionPayloadMatch(triggerId, obj)) {
const eventType = obj.type as string | undefined
logger.debug(
`[${requestId}] Notion event mismatch for trigger ${triggerId}. Event: ${eventType}. Skipping execution.`,
{
webhookId: webhook.id,
workflowId: workflow.id,
triggerId,
receivedEvent: eventType,
}
)
return NextResponse.json({
message: 'Event type does not match trigger configuration. Ignoring.',
})
}
}

return true
},
}
2 changes: 2 additions & 0 deletions apps/sim/lib/webhooks/providers/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { jiraHandler } from '@/lib/webhooks/providers/jira'
import { lemlistHandler } from '@/lib/webhooks/providers/lemlist'
import { linearHandler } from '@/lib/webhooks/providers/linear'
import { microsoftTeamsHandler } from '@/lib/webhooks/providers/microsoft-teams'
import { notionHandler } from '@/lib/webhooks/providers/notion'
import { outlookHandler } from '@/lib/webhooks/providers/outlook'
import { resendHandler } from '@/lib/webhooks/providers/resend'
import { rssHandler } from '@/lib/webhooks/providers/rss'
Expand Down Expand Up @@ -64,6 +65,7 @@ const PROVIDER_HANDLERS: Record<string, WebhookProviderHandler> = {
linear: linearHandler,
resend: resendHandler,
'microsoft-teams': microsoftTeamsHandler,
notion: notionHandler,
outlook: outlookHandler,
rss: rssHandler,
slack: slackHandler,
Expand Down
38 changes: 38 additions & 0 deletions apps/sim/triggers/notion/comment_created.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { NotionIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildCommentEventOutputs,
buildNotionExtraFields,
notionSetupInstructions,
notionTriggerOptions,
} from '@/triggers/notion/utils'
import type { TriggerConfig } from '@/triggers/types'

/**
* Notion Comment Created Trigger
*/
export const notionCommentCreatedTrigger: TriggerConfig = {
id: 'notion_comment_created',
name: 'Notion Comment Created',
provider: 'notion',
description: 'Trigger workflow when a comment or suggested edit is added in Notion',
version: '1.0.0',
icon: NotionIcon,

subBlocks: buildTriggerSubBlocks({
triggerId: 'notion_comment_created',
triggerOptions: notionTriggerOptions,
setupInstructions: notionSetupInstructions('comment.created'),
extraFields: buildNotionExtraFields('notion_comment_created'),
}),

outputs: buildCommentEventOutputs(),

webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Notion-Signature': 'sha256=...',
},
},
}
38 changes: 38 additions & 0 deletions apps/sim/triggers/notion/database_created.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { NotionIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildDatabaseEventOutputs,
buildNotionExtraFields,
notionSetupInstructions,
notionTriggerOptions,
} from '@/triggers/notion/utils'
import type { TriggerConfig } from '@/triggers/types'

/**
* Notion Database Created Trigger
*/
export const notionDatabaseCreatedTrigger: TriggerConfig = {
id: 'notion_database_created',
name: 'Notion Database Created',
provider: 'notion',
description: 'Trigger workflow when a new database is created in Notion',
version: '1.0.0',
icon: NotionIcon,

subBlocks: buildTriggerSubBlocks({
triggerId: 'notion_database_created',
triggerOptions: notionTriggerOptions,
setupInstructions: notionSetupInstructions('database.created'),
extraFields: buildNotionExtraFields('notion_database_created'),
}),

outputs: buildDatabaseEventOutputs(),

webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Notion-Signature': 'sha256=...',
},
},
}
38 changes: 38 additions & 0 deletions apps/sim/triggers/notion/database_deleted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { NotionIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildDatabaseEventOutputs,
buildNotionExtraFields,
notionSetupInstructions,
notionTriggerOptions,
} from '@/triggers/notion/utils'
import type { TriggerConfig } from '@/triggers/types'

/**
* Notion Database Deleted Trigger
*/
export const notionDatabaseDeletedTrigger: TriggerConfig = {
id: 'notion_database_deleted',
name: 'Notion Database Deleted',
provider: 'notion',
description: 'Trigger workflow when a database is deleted in Notion',
version: '1.0.0',
icon: NotionIcon,

subBlocks: buildTriggerSubBlocks({
triggerId: 'notion_database_deleted',
triggerOptions: notionTriggerOptions,
setupInstructions: notionSetupInstructions('database.deleted'),
extraFields: buildNotionExtraFields('notion_database_deleted'),
}),

outputs: buildDatabaseEventOutputs(),

webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Notion-Signature': 'sha256=...',
},
},
}
40 changes: 40 additions & 0 deletions apps/sim/triggers/notion/database_schema_updated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { NotionIcon } from '@/components/icons'
import { buildTriggerSubBlocks } from '@/triggers'
import {
buildDatabaseEventOutputs,
buildNotionExtraFields,
notionSetupInstructions,
notionTriggerOptions,
} from '@/triggers/notion/utils'
import type { TriggerConfig } from '@/triggers/types'

/**
* Notion Database Schema Updated Trigger
*
* Fires when a database schema (properties/columns) is modified.
*/
export const notionDatabaseSchemaUpdatedTrigger: TriggerConfig = {
id: 'notion_database_schema_updated',
name: 'Notion Database Schema Updated',
provider: 'notion',
description: 'Trigger workflow when a database schema is modified in Notion',
version: '1.0.0',
icon: NotionIcon,

subBlocks: buildTriggerSubBlocks({
triggerId: 'notion_database_schema_updated',
triggerOptions: notionTriggerOptions,
setupInstructions: notionSetupInstructions('database.schema_updated'),
extraFields: buildNotionExtraFields('notion_database_schema_updated'),
}),

outputs: buildDatabaseEventOutputs(),

webhook: {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Notion-Signature': 'sha256=...',
},
},
}
9 changes: 9 additions & 0 deletions apps/sim/triggers/notion/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export { notionCommentCreatedTrigger } from './comment_created'
export { notionDatabaseCreatedTrigger } from './database_created'
export { notionDatabaseDeletedTrigger } from './database_deleted'
export { notionDatabaseSchemaUpdatedTrigger } from './database_schema_updated'
export { notionPageContentUpdatedTrigger } from './page_content_updated'
export { notionPageCreatedTrigger } from './page_created'
export { notionPageDeletedTrigger } from './page_deleted'
export { notionPagePropertiesUpdatedTrigger } from './page_properties_updated'
export { notionWebhookTrigger } from './webhook'
Loading
Loading