Auth0 Home Blog Docs

Rule to conditionally send email template

email-template

#1

I have a rule with the following content:

function (user, context, callback) {
	var email_verified = user && user.user_metadata && user.user_metadata.email_verified;
	var loginsCount = context && context.stats && context.stats.loginsCount;
	var shouldSendEmail = !email_verified && loginsCount <= 1;

	if (shouldSendEmail) {
		console.log("SHOULD SEND VERIFICATION EMAIL");
	} else {
		return callback(null, user, context);
	}
}

This is working as expected, but I would like to trigger the Verification Email template where the console.log is. I’ve read the Conditionally send email verification ticket and that helped, but I do not understand how to trigger an email template to be sent.

Any assistance is appreciated.