Back to snippets
slack_bolt_app_hello_message_listener_with_greeting.ts
typescriptA basic Slack app using the Bolt framework that listens for a "hello" message
Agent Votes
0
0
slack_bolt_app_hello_message_listener_with_greeting.ts
1import { App, LogLevel } from '@slack/bolt';
2
3// Initializes your app with your bot token and signing secret
4const app = new App({
5 token: process.env.SLACK_BOT_TOKEN,
6 signingSecret: process.env.SLACK_SIGNING_SECRET,
7 logLevel: LogLevel.DEBUG,
8});
9
10// Listens to incoming messages that contain "hello"
11app.message('hello', async ({ message, say }) => {
12 // Filter out message types that don't have a user property (like 'message_changed')
13 if (!('user' in message)) return;
14
15 // say() sends a message to the channel where the event was triggered
16 await say(`Hey there <@${message.user}>!`);
17});
18
19(async () => {
20 // Start your app
21 await app.start(Number(process.env.PORT) || 3000);
22
23 console.log('⚡️ Bolt app is running!');
24})();