Skip to main content

Documentation Index

Fetch the complete documentation index at: https://auth-test.auth0-mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

1

Prerequisites

2

Set up a custom phone message provider

From Dashboard > Branding > Phone Provider, under Phone Provider, choose Custom.Under Provider Configuration, add the following code sample to allow the Twilio API to send phone messages to a user’s phone number:
/**
* Handler to be executed while sending a phone notification
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {CustomPhoneProviderAPI} api - Methods and utilities to help change the behavior of sending a phone notification.
*/
exports.onExecuteCustomPhoneProvider = async (event, api) => {
 const { TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_VERIFY_SID } = event.secrets;

  const client = require('twilio')(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN);

  // map auth0 voice value to call
  const messageType = event.notification.delivery_method === 'voice' ? 'call' : 'sms';

  const { recipient, code } = event.notification;

  // add this to fix " 1333444999  "
  // "333 444 5555"
  const sanitizedNumber = recipient.replace(/\s/g, '').trim();

  await client.verify.v2.services(TWILIO_VERIFY_SID)
    .verifications.create({
      to: sanitizedNumber,
      channel: messageType,
      customCode: code
    })

};
3

Add secrets

Select the Key icon to open the Secrets menu. Add the following values from your Twilio Verify service setup:
  • TWILIO_ACCOUNT_SID
  • TWILIO_AUTH_TOKEN
  • TWILIO_VERIFY_SID
4

Load Twilio helper library

Select the Dependency icon, then choose Add Dependency. In the Add Dependency window that opens, enter the following values:
  • Name: twilio
  • Version: latest
Select Create and Auth0 searches for the Twilio helper library and loads the latest version.
5

Deploy and test

Select Save to save and deploy the Action.To test the custom phone provider configuration before using it in a production environment, select Send Test Message.