Actions Triggers: send-phone-message

Actions Triggers: send-phone-message

If you decide to use SMS as a factor for Multi-factor Authentication (MFA), you can configure how you want Auth0 to send the messages in the SMS configuration dialog.

If you select the 'Custom' SMS delivery method, you must create a Send Phone Message flow that will let you write your own code to send the message. This allows you to use whatever SMS provider you want.

Actions at this extensibility point are blocking (synchronous), which means they execute as part of the trigger's process and will prevent the rest of the Auth0 pipeline from running until the Action is complete. This trigger will run for the enrollment process and the challenge process (event.message_options.action). This will also run for the voice message type when using the New experience for the Universal Login (event.message_options.message_type === 'voice').

Reference

Event object: Provides contextual information about the message to be sent and the user to be challenged or enrolled.

Common use cases

Use a custom SMS provider

const AWS = require("aws-sdk");

/**
 * Handler that will be called during the execution of a SendPhoneMessage flow.
 *
 * @param {Event} event - Details about the user and the context in which they are logging in.
 */
exports.onExecuteSendPhoneMessage = async (event) => {
  const text = event.message_options.text;
  const recipient = event.message_options.recipient;

  const awsSNS = new AWS.SNS({
    apiVersion: "2010-03-31",
    region: event.secrets.AWS_REGION,
    credentials: new AWS.Credentials(event.secrets.AWS_ACCESS_KEY_ID, event.secrets.AWS_SECRET_ACCESS_KEY)
  });

  const params = { Message: text, PhoneNumber: recipient };

  return awsSNS
    .publish(params)
    .promise();
};

Was this helpful?

/