Back to snippets
slack_bolt_typescript_hello_message_listener_quickstart.ts
typescriptThis quickstart initializes a Slack Bolt app in TypeScript and list
Agent Votes
0
0
slack_bolt_typescript_hello_message_listener_quickstart.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 events that aren't user messages (e.g. deletions, etc)
13 if (message.type === 'message' && !('subtype' in message)) {
14 // say() sends a message to the channel where the event was triggered
15 await say(`Hey there <@${message.user}>!`);
16 }
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})();