Skip to content

Commit 7efbfd3

Browse files
improvement(slack-trigger): reorder app type, gate account to sim mode, add channel-id input
1 parent 5a36f48 commit 7efbfd3

4 files changed

Lines changed: 37 additions & 15 deletions

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,13 @@ async function handleSlackAppWebhook(request: NextRequest): Promise<NextResponse
145145
}
146146

147147
// Channel filter applies only to channel-scoped events, never to DMs.
148+
// Channels can come from the picker (channelFilter) or manual IDs
149+
// (manualChannelFilter) — the basic/advanced sides of one canonical field.
148150
if (eventKey && SLACK_CHANNEL_SCOPED_EVENTS.has(eventKey)) {
149-
const selectedChannels = normalizeSelection(providerConfig.channelFilter)
151+
const selectedChannels = [
152+
...normalizeSelection(providerConfig.channelFilter),
153+
...normalizeSelection(providerConfig.manualChannelFilter),
154+
]
150155
if (
151156
selectedChannels.length > 0 &&
152157
(!eventChannel || !selectedChannels.includes(eventChannel))

apps/sim/triggers/slack/oauth.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ export const slackOAuthTrigger: TriggerConfig = {
3131
required: true,
3232
mode: 'trigger',
3333
},
34+
{
35+
id: 'appType',
36+
title: 'App Type',
37+
type: 'dropdown',
38+
options: [
39+
{ label: 'Sim', id: 'sim' },
40+
{ label: 'Custom', id: 'custom' },
41+
],
42+
value: () => 'sim',
43+
description: 'Use the official Sim Slack app, or your own custom Slack app.',
44+
mode: 'trigger',
45+
},
3446
{
3547
id: 'triggerCredentials',
3648
title: 'Slack Account',
@@ -39,8 +51,9 @@ export const slackOAuthTrigger: TriggerConfig = {
3951
serviceId: 'slack',
4052
requiredScopes: getScopesForService('slack'),
4153
placeholder: 'Select Slack account',
42-
required: true,
54+
required: { field: 'appType', value: 'sim' },
4355
mode: 'trigger',
56+
condition: { field: 'appType', value: 'sim' },
4457
},
4558
{
4659
id: 'channelFilter',
@@ -52,22 +65,20 @@ export const slackOAuthTrigger: TriggerConfig = {
5265
selectorKey: 'slack.channels',
5366
placeholder: 'Any channel the bot is in',
5467
description:
55-
'Restrict channel, mention, and reaction events to specific channels. Leave empty to trigger on any channel the Sim bot has been added to. Does not apply to direct messages.',
68+
'Restrict channel, mention, and reaction events to specific channels. Leave empty to trigger on any channel the bot has been added to. Does not apply to direct messages.',
5669
dependsOn: ['triggerCredentials'],
5770
required: false,
5871
mode: 'trigger',
5972
},
6073
{
61-
id: 'appType',
62-
title: 'App Type',
63-
type: 'dropdown',
64-
options: [
65-
{ label: 'Sim', id: 'sim' },
66-
{ label: 'Custom', id: 'custom' },
67-
],
68-
value: () => 'sim',
69-
description: 'Use the official Sim Slack app, or your own custom Slack app.',
70-
mode: 'trigger',
74+
id: 'manualChannelFilter',
75+
title: 'Channel IDs',
76+
type: 'short-input',
77+
canonicalParamId: 'channelFilter',
78+
placeholder: 'C0123456789, C0987654321',
79+
description: 'Comma-separated channel IDs to restrict to. Set IDs directly here.',
80+
required: false,
81+
mode: 'trigger-advanced',
7182
},
7283
{
7384
id: 'webhookUrlDisplay',
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
ALTER TABLE "webhook" ALTER COLUMN "path" DROP NOT NULL;--> statement-breakpoint
22
ALTER TABLE "webhook" ADD COLUMN "routing_key" text;--> statement-breakpoint
3-
CREATE INDEX "webhook_routing_key_active_idx" ON "webhook" USING btree ("routing_key","provider") WHERE "webhook"."archived_at" IS NULL AND "webhook"."routing_key" IS NOT NULL;
3+
COMMIT;--> statement-breakpoint
4+
SET lock_timeout = 0;--> statement-breakpoint
5+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "webhook_routing_key_active_idx" ON "webhook" USING btree ("routing_key","provider") WHERE "webhook"."archived_at" IS NULL AND "webhook"."routing_key" IS NOT NULL;

scripts/check-api-validation-contracts.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const QUERY_HOOKS_DIR = path.join(ROOT, 'apps/sim/hooks/queries')
99
const SELECTOR_HOOKS_DIR = path.join(ROOT, 'apps/sim/hooks/selectors')
1010

1111
const BASELINE = {
12-
totalRoutes: 873,
12+
totalRoutes: 874,
1313
zodRoutes: 873,
1414
nonZodRoutes: 0,
1515
} as const
@@ -70,6 +70,10 @@ const INDIRECT_ZOD_ROUTES = new Set([
7070
'apps/sim/app/api/knowledge/connectors/sync/route.ts',
7171
'apps/sim/app/api/webhooks/outbox/process/route.ts',
7272
'apps/sim/app/api/webhooks/cleanup/idempotency/route.ts',
73+
// Shared Slack app event ingest. The body is an opaque, HMAC-verified Slack
74+
// event envelope (varies per event type) read via parseWebhookBody; there is
75+
// no client contract to bind — authenticity is enforced by signature.
76+
'apps/sim/app/api/webhooks/slack/route.ts',
7377
'apps/sim/app/api/resume/poll/route.ts',
7478
// MCP routes that take only auth context (no client-supplied params/query/body).
7579
'apps/sim/app/api/mcp/discover/route.ts',

0 commit comments

Comments
 (0)