> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# About the Send Phone Message Trigger

> Send Phone Message Actions run during the enrollment and challenge process when SMS or Voice is used as a factor for Multi-factor Authentication (MFA).

The `send-phone-message` trigger runs when using SMS/Voice as a factor for [Multi-factor Authentication (MFA)](/docs/docs/secure/multi-factor-authentication). It runs for both the enrollment process and the challenge process (`event.message_options.action`), and for the `voice` message type when using the New experience for Universal Login (Universal Login: Your application redirects to Universal Login, hosted on Auth0's Authorization Server, to verify a user's identity.) (`event.message_options.message_type === 'voice'`). When using a [custom provider](/docs/docs/secure/multi-factor-authentication/multi-factor-authentication-factors/configure-sms-voice-notifications-mfa#custom-phone-messaging-providers) to send the messages, this trigger is required to configure your custom provider.

![Diagram of the Actions Send Phone Message Flow.](https://mintlify.s3.us-west-1.amazonaws.com/docs-dev/images/cdy7uua7fh8z/FSkVXDdknDJq1hsK08EYu/e031ec0067a5460afae8d9ed5d462288/send-phone-message-flow.png)

Actions in this flow are blocking (synchronous): they execute as part of the trigger's process and prevent the rest of the Auth0 pipeline from running until the Action completes.

## References

* [Event object](/docs/docs/customize/actions/reference/pre-user-registration/pre-user-registration-event-object): Provides contextual information about the message to be senta nd the user to be challenged or enrolled.
* [API object](/docs/docs/customize/actions/reference/pre-user-registration/pre-user-registration-api-object): Provides methods for changing the behavior of the flow.

## Common use cases

### Use a custom SMS provider

A send-phone-message Action can be used to deliver MFA messages through a custom SMS provider:

```javascript lines theme={null}
const AWS = require("aws-sdk");

/**
 * @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();
};
```

For this Action to execute properly, the Action must contain secrets named `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`, and must have a dependency on the `aws-sdk` `npm` package.
