Skip to content

Instantly share code, notes, and snippets.

@royseto
Created November 11, 2019 02:01
Show Gist options
  • Save royseto/4c978882f17d3ee35498437a2ef5467a to your computer and use it in GitHub Desktop.
Save royseto/4c978882f17d3ee35498437a2ef5467a to your computer and use it in GitHub Desktop.
const functions = require('firebase-functions');
const { App } = require('@slack/bolt');
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET
});
// Listens to incoming messages that contain "hello"
app.message('hello', ({ message, say }) => {
// say() sends a message to the channel where the event was triggered
say({
blocks: [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": `Hey there <@${message.user}>!`
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Click Me"
},
"action_id": "button_click"
}
}
]
});
});
app.action('button_click', ({ body, ack, say }) => {
// Acknowledge the action
ack();
say(`<@${body.user.id}> clicked the button`);
});
exports.app = functions.https.onRequest(app);
{
"name": "first-bolt-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@slack/bolt": "^1.4.1",
"firebase-functions": "^3.3.0"
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment