Auth0 Home Blog Docs

Notification on new User signup

Hello,

Trying to figure out how to get notified when I have new users sign up. I would like to get an email when a new user signup has occurred, ideally after they have verified their email. Is this done through a hook or other mechanism?

Hmm it seems like we don’t have this one exactly but I found out in our rules -> webhooks templates one called Slack Notification on User Signup so I guess you will be able to maybe modify that and get email instead. Here’s the code snippet for it:

function (user, context, callback) {
  // 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 = '#some_channel';

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

You can go to the editor via: https://manage.auth0.com/#/ -> Rules > Creat Rule -> Webhooks -> Slack Notification On User Signup

Thanks! Do you know the code to add to only send it after the email address is verified?

it’s doable for sure! Let me play a bit with it and get back to you with the code snippet soon!

So , you can try user.email_verified in rule to check if email is verified or not

if(user.email_verified) { 
/// do someting } else { 
//}

Combining it with the above notification functionality

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.