Skip to content

Commit b6648ef

Browse files
author
aadamgough
committed
grain trigger new requirements
1 parent c2180bf commit b6648ef

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

apps/sim/app/api/webhooks/route.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,7 @@ async function createGrainWebhookSubscription(
11971197

11981198
const requestBody: Record<string, any> = {
11991199
hook_url: notificationUrl,
1200+
hook_type: 'recording_added', // Required parameter - fires when a new recording is added
12001201
}
12011202

12021203
// Build include object based on configuration
@@ -1226,8 +1227,10 @@ async function createGrainWebhookSubscription(
12261227

12271228
const responseBody = await grainResponse.json()
12281229

1229-
if (!grainResponse.ok || responseBody.error) {
1230+
if (!grainResponse.ok || responseBody.error || responseBody.errors) {
1231+
logger.warn('[App] Grain response body:', responseBody)
12301232
const errorMessage =
1233+
responseBody.errors?.detail ||
12311234
responseBody.error?.message ||
12321235
responseBody.error ||
12331236
responseBody.message ||

apps/sim/tools/grain/create_hook.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ export const grainCreateHookTool: ToolConfig<GrainCreateHookParams, GrainCreateH
2020
visibility: 'user-or-llm',
2121
description: 'Webhook endpoint URL (must respond 2xx)',
2222
},
23+
hookType: {
24+
type: 'string',
25+
required: true,
26+
visibility: 'user-or-llm',
27+
description: 'Type of webhook: "recording_added" or "upload_status"',
28+
},
2329
filterBeforeDatetime: {
2430
type: 'string',
2531
required: false,
@@ -81,6 +87,7 @@ export const grainCreateHookTool: ToolConfig<GrainCreateHookParams, GrainCreateH
8187
body: (params) => {
8288
const body: Record<string, any> = {
8389
hook_url: params.hookUrl,
90+
hook_type: params.hookType,
8491
}
8592

8693
const filter: Record<string, any> = {}
@@ -147,6 +154,10 @@ export const grainCreateHookTool: ToolConfig<GrainCreateHookParams, GrainCreateH
147154
type: 'string',
148155
description: 'The webhook URL',
149156
},
157+
hook_type: {
158+
type: 'string',
159+
description: 'Type of hook: recording_added or upload_status',
160+
},
150161
filter: {
151162
type: 'object',
152163
description: 'Applied filters',

apps/sim/tools/grain/list_hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const grainListHooksTool: ToolConfig<GrainListHooksParams, GrainListHooks
5151
id: { type: 'string', description: 'Hook UUID' },
5252
enabled: { type: 'boolean', description: 'Whether hook is active' },
5353
hook_url: { type: 'string', description: 'Webhook URL' },
54+
hook_type: { type: 'string', description: 'Type: recording_added or upload_status' },
5455
filter: { type: 'object', description: 'Applied filters' },
5556
include: { type: 'object', description: 'Included fields' },
5657
inserted_at: { type: 'string', description: 'Creation timestamp' },

apps/sim/tools/grain/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export interface GrainHook {
9595
id: string
9696
enabled: boolean
9797
hook_url: string
98+
hook_type: 'recording_added' | 'upload_status'
9899
filter: GrainRecordingFilter
99100
include: GrainRecordingInclude
100101
inserted_at: string
@@ -192,6 +193,7 @@ export interface GrainListMeetingTypesResponse extends ToolResponse {
192193
export interface GrainCreateHookParams {
193194
apiKey: string
194195
hookUrl: string
196+
hookType: 'recording_added' | 'upload_status'
195197
filterBeforeDatetime?: string
196198
filterAfterDatetime?: string
197199
filterParticipantScope?: 'internal' | 'external'

0 commit comments

Comments
 (0)