Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions apps/sim/app/api/webhooks/trigger/[path]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ export async function POST(
if (foundWebhook.blockId) {
const blockExists = await blockExistsInDeployment(foundWorkflow.id, foundWebhook.blockId)
if (!blockExists) {
// For Grain, if block doesn't exist in deployment, treat as verification request
// Grain validates webhook URLs during creation, and the block may not be deployed yet
if (foundWebhook.provider === 'grain') {
logger.info(
`[${requestId}] Grain webhook verification - block not in deployment, returning 200 OK`
)
return NextResponse.json({ status: 'ok', message: 'Webhook endpoint verified' })
}

logger.info(
`[${requestId}] Trigger block ${foundWebhook.blockId} not found in deployment for workflow ${foundWorkflow.id}`
)
Expand Down
12 changes: 6 additions & 6 deletions apps/sim/blocks/blocks/grain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ export const GrainBlock: BlockConfig = {
value: () => 'grain_webhook',
required: true,
},
...getTrigger('grain_recording_created').subBlocks.slice(1),
...getTrigger('grain_recording_updated').subBlocks.slice(1),
...getTrigger('grain_highlight_created').subBlocks.slice(1),
...getTrigger('grain_highlight_updated').subBlocks.slice(1),
...getTrigger('grain_story_created').subBlocks.slice(1),
...getTrigger('grain_webhook').subBlocks.slice(1),
...getTrigger('grain_recording_created').subBlocks,
...getTrigger('grain_recording_updated').subBlocks,
...getTrigger('grain_highlight_created').subBlocks,
...getTrigger('grain_highlight_updated').subBlocks,
...getTrigger('grain_story_created').subBlocks,
...getTrigger('grain_webhook').subBlocks,
],
tools: {
access: [
Expand Down
8 changes: 8 additions & 0 deletions apps/sim/lib/webhooks/provider-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ function extractAirtableIdentifier(body: any): string | null {
return null
}

function extractGrainIdentifier(body: any): string | null {
if (body.type && body.data?.id) {
return `${body.type}:${body.data.id}`
}
return null
}

const PROVIDER_EXTRACTORS: Record<string, (body: any) => string | null> = {
slack: extractSlackIdentifier,
twilio: extractTwilioIdentifier,
Expand All @@ -73,6 +80,7 @@ const PROVIDER_EXTRACTORS: Record<string, (body: any) => string | null> = {
jira: extractJiraIdentifier,
'microsoft-teams': extractMicrosoftTeamsIdentifier,
airtable: extractAirtableIdentifier,
grain: extractGrainIdentifier,
}

export function extractProviderIdentifierFromBody(provider: string, body: any): string | null {
Expand Down
11 changes: 1 addition & 10 deletions apps/sim/triggers/grain/highlight_created.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildHighlightOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
import { buildHighlightOutputs, grainSetupInstructions } from './utils'

export const grainHighlightCreatedTrigger: TriggerConfig = {
id: 'grain_highlight_created',
Expand All @@ -11,15 +11,6 @@ export const grainHighlightCreatedTrigger: TriggerConfig = {
icon: GrainIcon,

subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_highlight_created',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
Expand Down
11 changes: 1 addition & 10 deletions apps/sim/triggers/grain/highlight_updated.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildHighlightOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
import { buildHighlightOutputs, grainSetupInstructions } from './utils'

export const grainHighlightUpdatedTrigger: TriggerConfig = {
id: 'grain_highlight_updated',
Expand All @@ -11,15 +11,6 @@ export const grainHighlightUpdatedTrigger: TriggerConfig = {
icon: GrainIcon,

subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_highlight_updated',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
Expand Down
11 changes: 1 addition & 10 deletions apps/sim/triggers/grain/recording_created.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildRecordingOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
import { buildRecordingOutputs, grainSetupInstructions } from './utils'

export const grainRecordingCreatedTrigger: TriggerConfig = {
id: 'grain_recording_created',
Expand All @@ -11,15 +11,6 @@ export const grainRecordingCreatedTrigger: TriggerConfig = {
icon: GrainIcon,

subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_recording_created',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
Expand Down
11 changes: 1 addition & 10 deletions apps/sim/triggers/grain/recording_updated.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildRecordingOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
import { buildRecordingOutputs, grainSetupInstructions } from './utils'

export const grainRecordingUpdatedTrigger: TriggerConfig = {
id: 'grain_recording_updated',
Expand All @@ -11,15 +11,6 @@ export const grainRecordingUpdatedTrigger: TriggerConfig = {
icon: GrainIcon,

subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_recording_updated',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
Expand Down
11 changes: 1 addition & 10 deletions apps/sim/triggers/grain/story_created.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildStoryOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
import { buildStoryOutputs, grainSetupInstructions } from './utils'

export const grainStoryCreatedTrigger: TriggerConfig = {
id: 'grain_story_created',
Expand All @@ -11,15 +11,6 @@ export const grainStoryCreatedTrigger: TriggerConfig = {
icon: GrainIcon,

subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_story_created',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
Expand Down
11 changes: 1 addition & 10 deletions apps/sim/triggers/grain/webhook.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GrainIcon } from '@/components/icons'
import type { TriggerConfig } from '@/triggers/types'
import { buildGenericOutputs, grainSetupInstructions, grainTriggerOptions } from './utils'
import { buildGenericOutputs, grainSetupInstructions } from './utils'

export const grainWebhookTrigger: TriggerConfig = {
id: 'grain_webhook',
Expand All @@ -11,15 +11,6 @@ export const grainWebhookTrigger: TriggerConfig = {
icon: GrainIcon,

subBlocks: [
{
id: 'selectedTriggerId',
title: 'Trigger Type',
type: 'dropdown',
mode: 'trigger',
options: grainTriggerOptions,
value: () => 'grain_webhook',
required: true,
},
{
id: 'apiKey',
title: 'API Key',
Expand Down