Skip to content

Commit 072a2e0

Browse files
feat: filter out system messages in slack new-message trigger
1 parent ba27866 commit 072a2e0

3 files changed

Lines changed: 10 additions & 15 deletions

File tree

packages/pieces/community/common-ai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@activepieces/common-ai",
3-
"version": "0.2.2",
3+
"version": "0.1.0",
44
"type": "commonjs",
55
"dependencies": {
66
"tslib": "^2.3.0",

packages/pieces/community/slack/src/lib/triggers/new-message.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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
};

packages/server/worker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
"@ai-sdk/openai": "2.0.12",
2525
"ai": "5.0.12",
2626
"zod": "3.25.76",
27-
"@activepieces/common-ai": "0.2.2"
27+
"@activepieces/common-ai": "0.1.0"
2828
}
2929
}

0 commit comments

Comments
 (0)