Skip to content

Instantly share code, notes, and snippets.

@adelowo

adelowo/slack.js Secret

Last active January 21, 2020 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adelowo/0627d0870f1e6d2e0e0a4c84f59b554c to your computer and use it in GitHub Desktop.
Save adelowo/0627d0870f1e6d2e0e0a4c84f59b554c to your computer and use it in GitHub Desktop.
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