@@ -1179,7 +1179,7 @@ async function createGrainWebhookSubscription(
11791179) : Promise < string | undefined > {
11801180 try {
11811181 const { path, providerConfig } = webhookData
1182- const { apiKey, includeHighlights, includeParticipants, includeAiSummary } =
1182+ const { apiKey, triggerId , includeHighlights, includeParticipants, includeAiSummary } =
11831183 providerConfig || { }
11841184
11851185 if ( ! apiKey ) {
@@ -1191,13 +1191,38 @@ async function createGrainWebhookSubscription(
11911191 )
11921192 }
11931193
1194+ const hookTypeMap : Record < string , string > = {
1195+ grain_webhook : 'recording_added' ,
1196+ grain_recording_created : 'recording_added' ,
1197+ grain_recording_updated : 'recording_added' ,
1198+ grain_highlight_created : 'recording_added' ,
1199+ grain_highlight_updated : 'recording_added' ,
1200+ grain_story_created : 'recording_added' ,
1201+ grain_upload_status : 'upload_status' ,
1202+ }
1203+
1204+ const hookType = hookTypeMap [ triggerId ] ?? 'recording_added'
1205+ if ( ! hookTypeMap [ triggerId ] ) {
1206+ logger . warn (
1207+ `[${ requestId } ] Unknown triggerId for Grain: ${ triggerId } , defaulting to recording_added` ,
1208+ {
1209+ webhookId : webhookData . id ,
1210+ }
1211+ )
1212+ }
1213+
1214+ logger . info ( `[${ requestId } ] Creating Grain webhook with hook_type: ${ hookType } ` , {
1215+ triggerId,
1216+ webhookId : webhookData . id ,
1217+ } )
1218+
11941219 const notificationUrl = `${ getBaseUrl ( ) } /api/webhooks/trigger/${ path } `
11951220
11961221 const grainApiUrl = 'https://api.grain.com/_/public-api/v2/hooks/create'
11971222
11981223 const requestBody : Record < string , any > = {
11991224 hook_url : notificationUrl ,
1200- hook_type : 'recording_added' ,
1225+ hook_type : hookType ,
12011226 }
12021227
12031228 // Build include object based on configuration
0 commit comments