Skip to content

Example for parse server webhook to slack? #4876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jeffreyjackson opened this issue Jul 6, 2018 · 2 comments
Closed

Example for parse server webhook to slack? #4876

jeffreyjackson opened this issue Jul 6, 2018 · 2 comments

Comments

@jeffreyjackson
Copy link

Anyone have any pointers or howto on this?

@jeffreyjackson
Copy link
Author

a simple example would be fine, essentially message on afterSave would be all I need.

@JacobJT
Copy link

JacobJT commented Jul 6, 2018

slackService.js

const IncomingWebhook = require('@slack/client').IncomingWebhook;
let MY_CHANNEL_URL = <your webhook url>
let myChannelWebhook = new IncomingWebhook(MY_CHANNEL_URL);

// Set up like this so you can add helper functions to easily message different channels
exports.messageMyChannel = function(message) {
    return postSlackMessage(message, MyChannelWebhook);
}

function postSlackMessage(message, webhook) {
    return webhook.send(message, function(err, res) { /* ... */ });
}

main.js

const slackService = require('./slackService');

Parse.Cloud.afterSave('MyClass', (req) => {
    let message = 'This is the message I want to send';
    slackService.messageMyChannel(message);
});

Obvs some Slack configuring to do, but that's the basic gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants