> ## Documentation Index
> Fetch the complete documentation index at: https://docs-staging-docs-event-stream-action-templates.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Learn about Action's Send Phone Message flow and the send-phone-message Action trigger, which runs for the enrollment and challenge process if you have used SMS as a factor for Multi-factor Authentication (MFA).

# MFA Notifications Triggers

The Send Phone Message trigger allows you to execute code when using SMS/Voice as a factor for [Multi-factor Authentication (MFA)](/docs/secure/multi-factor-authentication). When using a [custom provider](/docs/secure/multi-factor-authentication/multi-factor-authentication-factors/configure-sms-voice-notifications-mfa#custom-phone-messaging-providers) to send the messages, this flow's `send-phone-message` trigger is required to configure your custom provider.

<Frame>
  <img src="https://mintcdn.com/docs-staging-docs-event-stream-action-templates/IrI_qkmH6rdv_iZp/docs/images/cdy7uua7fh8z/FSkVXDdknDJq1hsK08EYu/e031ec0067a5460afae8d9ed5d462288/send-phone-message-flow.png?fit=max&auto=format&n=IrI_qkmH6rdv_iZp&q=85&s=3f3b607a7648d76db478023d5e16f491" alt="Diagram of the Actions Send Phone Message Flow." width="681" height="126" data-path="docs/images/cdy7uua7fh8z/FSkVXDdknDJq1hsK08EYu/e031ec0067a5460afae8d9ed5d462288/send-phone-message-flow.png" />
</Frame>

Actions in this flow are blocking (synchronous), which means they execute as part of a trigger's process and will prevent the rest of the Auth0 pipeline from running until the Action is complete.

## Triggers

### Send Phone Message

The `send-phone-message` trigger will run for the enrollment process and the challenge process (`event.message_options.action`). It will also run for the `voice` message type when using the New experience for <Tooltip tip="Universal Login: Your application redirects to Universal Login, hosted on Auth0's Authorization Server, to verify a user's identity." cta="View Glossary" href="/docs/glossary?term=Universal+Login">Universal Login</Tooltip> (`event.message_options.message_type === 'voice'`).

#### References

* [Event object](/docs/customize/actions/explore-triggers/mfa-notifications-trigger/send-phone-message-event-object): Provides contextual information about the message to be sent and the user to be challenged or enrolled.
* [API object](/docs/customize/actions/explore-triggers/mfa-notifications-trigger/send-phone-message-api-object): Provides methods for changing the behavior of the flow.

## Common use cases

### Use a custom SMS provider

```javascript lines theme={null}
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();
};
```

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  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.
</Callout>
