Skip to content

Instantly share code, notes, and snippets.

@sweetyclem
Created June 6, 2020 20:14
Show Gist options
  • Save sweetyclem/94566c0bbc65214a792c67f31277d2af to your computer and use it in GitHub Desktop.
Save sweetyclem/94566c0bbc65214a792c67f31277d2af to your computer and use it in GitHub Desktop.
const bodyParser = require('body-parser');
const subjects = require('./elements/subjects.json')
module.exports.listenForCommands = async function (app) {
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
app.post('/commands', (req, res) => {
const { token, user_id, channel_id } = req.body
console.log(`Received a slash command from user ${user_id} in channel ${channel_id}`)
if (token !== process.env.SLACK_VERIF_TOKEN) {
console.log('Invalid token')
return
}
res.status(200).send({ attachments: [subjects] }
)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment