Created
June 6, 2020 18:10
-
-
Save sweetyclem/51c5cb47b559e965dc139b30e5a1ef7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createEventAdapter } = require('@slack/events-api') | |
const slackSigningSecret = process.env.SLACK_SIGNING_SECRET | |
const slackEvents = createEventAdapter(slackSigningSecret) | |
function listenForEvents(app) { | |
app.use('/events', slackEvents.requestListener()) | |
} | |
slackEvents.on('app_mention', (event) => { | |
console.log(`Received an app_mention event from user ${event.user} in channel ${event.channel}`) | |
}) | |
// All errors in listeners are caught here. If this weren't caught, the program would terminate. | |
slackEvents.on('error', (error) => { | |
console.log(`error: ${error}`) | |
}) | |
module.exports.listenForEvents = listenForEvents |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment