Post User Registration Hook

Hi all,
I tried to edit a Post User Registration hook to send an email from my SMTP custom provider (SendinBlue).

The code below:
const SibApiV3Sdk = require(“sib-api-v3-sdk”);

const defaultClient = SibApiV3Sdk.ApiClient.instance;
const apiKey = defaultClient.authentications["api-key"];
apiKey.apiKey =
  "blablabla";
const api = new SibApiV3Sdk.TransactionalEmailsApi();

module.exports = function (user, context, cb) {
  let sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail();

  sendSmtpEmail = {
    to: [
      {
        email: user.email,
        name: user.name,
      },
    ],
    templateId: 1,
    params: {
      name: user.name,
      surname: user.username,
    },
  };

  api.sendTransacEmail(sendSmtpEmail).then(
    function (data) {
      console.log({ message: "API called successfully.", data });
    },
    function (error) {
      console.log({ message: error });
    }
  );

  cb();
};

If I run this code with the simulator it works but if I register a new user it doesn’t work.

Anybody can help me?

Thanks!!!

Hi @diceccostefano87,

Welcome to the Community!

Please elaborate on “it doesn’t work”. Is it throwing errors? Is it not running? Have you tried the debug console?

Are you using a social user by chance?

Hi @dan.woda ,
thank you! It doesn’t work it means the hook is never triggered after registration of a new user, but in the debug console I don’t have any error and it works correctly, the response is “API called successfully” and the status code 200.

Thank you for your time!

@diceccostefano87,

Are you using a database user? Social user perhaps?

@dan.woda what do you mean with database user? anyway I don’t connect any database with auth0

What connection are you using?

@dan.woda connection? I don’t understand, I’m using auth0 in a React application (SPA)

What is the source of your user data?

Marking this resolved after two weeks of inactivity.