@@ -25,20 +25,14 @@ export const newMessageTrigger = createTrigger({
2525 } ) ,
2626 matchWholeWord : Property . Checkbox ( {
2727 displayName : 'Match Whole Word Only' ,
28- description : 'If enabled, only matches the keyword as a complete word (e.g. "test" won\'t match "testing"). Leave empty if no keyword. ' ,
28+ description : 'If enabled, only matches the keyword as a complete word (e.g. "test" won\'t match "testing").' ,
2929 required : false ,
3030 defaultValue : false ,
3131 } ) ,
3232 } ,
3333
3434 type : TriggerStrategy . APP_WEBHOOK ,
35- sampleData : {
36- text : 'Hello world!' ,
37- channel : 'C1234567890' ,
38- user : 'U1234567890' ,
39- channel_type : 'channel' ,
40- ts : '1234567890.123456'
41- } ,
35+ sampleData : undefined ,
4236 onEnable : async ( context ) => {
4337 // Older OAuth2 has team_id, newer has team.id
4438 const teamId = context . auth . data [ 'team_id' ] ?? context . auth . data [ 'team' ] [ 'id' ] ;
@@ -55,6 +49,11 @@ export const newMessageTrigger = createTrigger({
5549 const payloadBody = context . payload . body as PayloadBody ;
5650 const { ignoreBots, keyword, includeThreads, matchWholeWord} = context . propsValue ;
5751
52+ // ignore system messages (joins, leaves, file shares, etc.)
53+ if ( payloadBody . event . subtype ) {
54+ return [ ] ;
55+ }
56+
5857 if ( ignoreBots && payloadBody . event . bot_id ) {
5958 return [ ] ;
6059 }
@@ -65,11 +64,6 @@ export const newMessageTrigger = createTrigger({
6564 }
6665 }
6766
68- // if text is not provided, return
69- if ( ! payloadBody . event . text || ! payloadBody . event . text . trim ( ) ) {
70- return [ ] ;
71- }
72-
7367 // if keyword is provided, check if the message contains the keyword
7468 if ( keyword && keyword . trim ( ) ) {
7569 if ( ! payloadBody . event . text ) {
@@ -105,5 +99,6 @@ type PayloadBody = {
10599 channel_type :string ;
106100 bot_id ?: string ;
107101 thread_ts ?: string ;
102+ subtype ?: string ;
108103 } ;
109104} ;
0 commit comments