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);
}

I am having the same issue!

Hey everyone!

Terribly sorry for the delay! Let me troubleshoot that with the team and get back to you!

1 Like

Any news on that? It is really getting out of hands in our production environment.

Unfortunately not yet. Let me reping the team!

Hey there @developer3!

Are you using the same code snippet? We guess that the problem lies in the already signed up users or using a refresh token return callback. Have you tried deleting one of the callbacks and see what happens?

I am not quite sure what you mean. I am using universal login with auth0-spa-js.

Sorry I thought you are using some kind of third-party hook. Is the behaviour still there? I repinged our engineering team about that.

Just got a response from our engineering team and this is the expected functionality because rules are designed to execute when a user authenticates to your application. They run any time an authentication process is completed. The recommended approach for implementing this slack notification would be to create a Post User Registration hook.

2 Likes