Auth0 Home Blog Docs

Slack notification rule is triggering more than once

Hi,

I have a rule to inform me whenever a new user signs up to our system, however it seems that this rule is triggered more than once, sometimes even 10 or more times.
In the attached image you can see that the rule was triggered 4 times in a row, and after about ~40 minutes it was triggered twice.

Here is the rule itself:

function slackNotificationOnUserSignup(user, context, callback) {
  console.log(context);
  // short-circuit if the user signed up already or is using a refresh token
  if (context.stats.loginsCount > 1 || context.protocol === 'oauth2-refresh-token') {
    return callback(null, user, context);
  }

  // get your slack's hook url from: https://slack.com/services/10525858050
  const SLACK_HOOK = configuration.SLACK_HOOK_URL;

  const slack = require('slack-notify')(SLACK_HOOK);
  const message = 'New User: ' + (user.name || user.email) + ' (' + user.email + ')';
  const channel = '#user_signup';

  slack.success({
    text: message,
    channel: channel
  });

  // don’t wait for the Slack API call to finish, return right away (the request will continue on the sandbox)`
  callback(null, user, context);
}