-
-
Save adelowo/0627d0870f1e6d2e0e0a4c84f59b554c 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 { IncomingWebhook } = require('@slack/webhook'); | |
const webhook = new IncomingWebhook(process.env.SLACK_WEBHOOK_URL); | |
module.exports.slack = async (event, context, callback) => { | |
const data = JSON.parse(event.body); | |
if (data.type === 'message.new') { | |
await webhook.send({ | |
text: 'A new message was sent', | |
}); | |
} | |
callback(null, { | |
statusCode: 201, | |
headers: { 'Content-Type': 'text/json' }, | |
body: JSON.stringify({ status: true }), | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment