Add NPM Packages and Store Secrets with Auth0 Actions

InstructorWill Johnson

Share this video with your friends

Send Tweet

Add the slack-notify npm package from the Actions editor to send a Slack message when a new user registers for your application.

Create a Post User Registration action.

Go to api.slack.com create a new app, active Incoming Webhooks, and get your Slack Webhook URL.

Your webhook URL contains a secret. Don't share it online, including public Git repositories.

In the Action editor store the Slack Webhook URL as a secret and add the slack-notify npm package.

In the Actions editor enter the follow code:

const initSlackNotify = require('slack-notify')

exports.onExecutePostUserRegistration = async (event) => {
  const slack = initSlackNotify(event.secrets.SLACK_WEBHOOK_URL);
  const message = `New User: ${event.user.email}`

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

Before deploying test out the Action by click the Test icon. Once test is successful click deploy.

Then click Add to flow and drag the Action into the Post User Registration flow.