Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// import App, { ActionConstraints } from '../../src/App';
import { App, MessageAction } from '@slack/bolt';
const app = new App({ token: 'TOKEN', signingSecret: 'Signing Secret' });
// calling action method with incorrect an type constraint value should not work
// $ExpectError
app.action({ type: 'Something wrong' }, ({ action }) => {
return action;
});
/* Not working
// Should error because message_action doesn't have type action_id
// $ Expect Error
app.action({ type: 'message_action', action_id: 'dafasf' }, ({ action }) => {
return action;
});
*/
// Action in listner should be - MessageAction
const { App } = require('@slack/bolt');
// 環境変数の SLACK_BOT_TOKEN, SLACK_SIGNING_SECRET が設定されていることが前提
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET
});
app.use(args => {
console.log(JSON.stringify(args));
args.next();
});
const restaurants = [
{ name: '割烹よし田', url: 'https://tabelog.com/fukuoka/A4001/A400103/40000692/' },
{ name: '真', url: 'https://tabelog.com/fukuoka/A4001/A400103/40003911/' },
{ name: '新三浦 天神店', url: 'https://tabelog.com/fukuoka/A4001/A400103/40000066/' },
{ name: '利花苑 大名本店', url: 'https://tabelog.com/fukuoka/A4001/A400104/40000443/' },
{ name: '106 サウスインディアン 福岡天神店', url: 'https://tabelog.com/fukuoka/A4001/A400103/40041110/' },
];
// Enable debug logging if true
const debug: boolean = true;
// lang code mapping data
import { langcode } from './langcode';
// ----------------
// Slack Bolt App
import { App, ExpressReceiver } from '@slack/bolt';
const expressReceiver = new ExpressReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET
// Endpoints will be attached later by calling the declared methods in Bolt's App
});
export const expressApp = expressReceiver.app;
const app: App = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver: expressReceiver
});
app.event('reaction_added', async ({ event }) => {
try {
if (debug) {
console.log(event);
}
if (event.item['type'] !== 'message') {
// Skip any events apart from reactions put on messages
return;
}
const reactionName = event.reaction;
let country: string = null;
// Check the reaction name if it is a country flag
const { App } = require('@slack/bolt');
// 環境変数の SLACK_BOT_TOKEN, SLACK_SIGNING_SECRET が設定されていることが前提
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET
});
app.use(args => {
console.log(JSON.stringify(args));
args.next();
});
const restaurants = [
{ name: '割烹よし田', url: 'https://tabelog.com/fukuoka/A4001/A400103/40000692/' },
{ name: '真', url: 'https://tabelog.com/fukuoka/A4001/A400103/40003911/' },
{ name: '新三浦 天神店', url: 'https://tabelog.com/fukuoka/A4001/A400103/40000066/' },
{ name: '利花苑 大名本店', url: 'https://tabelog.com/fukuoka/A4001/A400104/40000443/' },
{ name: '106 サウスインディアン 福岡天神店', url: 'https://tabelog.com/fukuoka/A4001/A400103/40041110/' },
];
'use strict';
// ------------------------------------------------------
// Bot app
// https://slack.dev/bolt/
const { App, ExpressReceiver } = require('@slack/bolt');
const expressReceiver = new ExpressReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET
});
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver: expressReceiver
});
module.exports.expressApp = expressReceiver.app;
// ------------------------------------------------------
// If you need to use API methods that are not listed on https://api.slack.com/bot-users#methods
// you need to use user api token instead like this:
const { WebClient } = require('@slack/web-api');
app.client = new WebClient(process.env.SLACK_API_TOKEN);
// ------------------------------------------------------
// React to "app_mention" events
app.event('app_mention', ({ event, say }) => {
app.client.users.info({ user: event.user })
'use strict';
// ------------------------------------------------------
// Bot app
// https://slack.dev/bolt/
const { App, ExpressReceiver } = require('@slack/bolt');
const expressReceiver = new ExpressReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET
});
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver: expressReceiver
});
module.exports.expressApp = expressReceiver.app;
// ------------------------------------------------------
// If you need to use API methods that are not listed on https://api.slack.com/bot-users#methods
// you need to use user api token instead like this:
const { WebClient } = require('@slack/web-api');
app.client = new WebClient(process.env.SLACK_API_TOKEN);
// ------------------------------------------------------
// React to "app_mention" events
app.event('app_mention', ({ event, say }) => {
app.client.users.info({ user: event.user })
// Type definitions in TypeScript
import * as WebApi from 'seratch-slack-types/web-api';
import { Request, Response, Application } from 'express';
// ------------------------------------------------------
// Bot app
// https://slack.dev/bolt/
import { App, ExpressReceiver } from '@slack/bolt';
const expressReceiver = new ExpressReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET
// Endpoints will be attached later by calling the declared methods in Bolt's App
});
export const expressApp: Application = expressReceiver.app;
const app: App = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver: expressReceiver
});
// ------------------------------------------------------
// If you need to use API methods that are not listed on https://api.slack.com/bot-users#methods
// you need to use user api token instead like this:
import { WebClient } from '@slack/web-api';
app.client = new WebClient(process.env.SLACK_API_TOKEN);
// ------------------------------------------------------
// React to "app_mention" events
app.event('app_mention', async ({ event, say }) => {
app.client.users.info({ user: event.user })
.then((res: WebApi.UsersInfoResponse) => {
'use strict';
const config = require('./config.js');
// ------------------------------------------------------
// Bot app
// https://slack.dev/bolt/
const { App, ExpressReceiver } = require('@slack/bolt');
const expressReceiver = new ExpressReceiver({
signingSecret: config.SLACK_SIGNING_SECRET
});
const app = new App({
token: config.SLACK_BOT_TOKEN,
receiver: expressReceiver
});
const expressApp = expressReceiver.app;
// ------------------------------------------------------
// If you need to use API methods that are not listed on https://api.slack.com/bot-users#methods
// you need to use user api token instead like this:
const { WebClient } = require('@slack/web-api');
app.client = new WebClient(config.SLACK_API_TOKEN);
// ------------------------------------------------------
// React to "app_mention" events
app.event('app_mention', ({ event, say }) => {
app.client.users.info({ user: event.user })
// ------------------------------------------------------
// Type definitions in TypeScript
import * as WebApi from 'seratch-slack-types/web-api';
import { Request, Response, Application } from 'express';
// ------------------------------------------------------
// Bot app
// https://slack.dev/bolt/
import { App, ExpressReceiver } from '@slack/bolt';
const expressReceiver = new ExpressReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET
});
export const expressApp: Application = expressReceiver.app;
const app: App = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver: expressReceiver
});
// ------------------------------------------------------
// If you need to use API methods that are not listed on https://api.slack.com/bot-users#methods
// you need to use user api token instead like this:
import { WebClient } from '@slack/web-api';
app.client = new WebClient(process.env.SLACK_API_TOKEN);
// ------------------------------------------------------
// React to "app_mention" events
app.event('app_mention', async ({ event, say }) => {
app.client.users.info({ user: event.user })
.then((res: WebApi.UsersInfoResponse) => {