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

> SMS を多要素認証 (MFA) の要素として使用している場合に、登録およびチャレンジのプロセスで実行される、Action の Send Phone Message フローと send-phone-message Action トリガーについて説明します。

# MFA 通知トリガー

Send Phone Message トリガーを使用すると、[多要素認証 (MFA)](/ja/docs/secure/multi-factor-authentication) の要素として SMS/音声を使用する際にコードを実行できます。メッセージの送信に[カスタムプロバイダー](/ja/docs/secure/multi-factor-authentication/multi-factor-authentication-factors/configure-sms-voice-notifications-mfa#custom-phone-messaging-providers)を使用する場合は、このフローの `send-phone-message` トリガーを使用してカスタムプロバイダーを設定する必要があります。

<Frame>
  <img src="https://mintcdn.com/translations/mMSz-RNYLuOm2GmQ/docs/images/cdy7uua7fh8z/FSkVXDdknDJq1hsK08EYu/e031ec0067a5460afae8d9ed5d462288/send-phone-message-flow.png?fit=max&auto=format&n=mMSz-RNYLuOm2GmQ&q=85&s=dddba13e310904c49aaa484c77b34b11" alt="Actions の Send Phone Message フローの図" width="681" height="126" data-path="docs/images/cdy7uua7fh8z/FSkVXDdknDJq1hsK08EYu/e031ec0067a5460afae8d9ed5d462288/send-phone-message-flow.png" />
</Frame>

このフローの Actions はブロッキング (同期) です。つまり、トリガーのプロセスの一部として実行され、Action が完了するまで Auth0 パイプラインの残りの処理は実行されません。

<div id="triggers">
  ## トリガー
</div>

<div id="send-phone-message">
  ### Send Phone Message
</div>

`send-phone-message` トリガーは、登録プロセスとチャレンジプロセスの両方 (`event.message_options.action`) で実行されます。また、<Tooltip tip="Universal Login: アプリケーションは、ユーザーの本人確認を行うために、Auth0 の認可サーバーでホストされる Universal Login にリダイレクトされます。" cta="用語集を見る" href="/ja/docs/glossary?term=Universal+Login">Universal Login</Tooltip> の New experience を使用している場合は、`voice` メッセージタイプ (`event.message_options.message_type === 'voice'`) でも実行されます。

<div id="references">
  #### 参考資料
</div>

* [Event object](/ja/docs/customize/actions/explore-triggers/mfa-notifications-trigger/send-phone-message-event-object): 送信するメッセージと、チャレンジまたは登録の対象となるユーザーに関するコンテキスト情報を提供します。
* [API object](/ja/docs/customize/actions/explore-triggers/mfa-notifications-trigger/send-phone-message-api-object): フローの動作を変更するためのメソッドを提供します。

<div id="common-use-cases">
  ## 一般的な利用例
</div>

<div id="use-a-custom-sms-provider">
  ### カスタム SMS プロバイダーを使用する
</div>

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

/**
 * SendPhoneMessage フローの実行中に呼び出されるハンドラー。
 *
 * @param {Event} event - ユーザーおよびログイン時のコンテキストに関する詳細情報。
 */
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">
  この Action を正しく実行するには、Action に `AWS_REGION`、`AWS_ACCESS_KEY_ID`、`AWS_SECRET_ACCESS_KEY` という名前のシークレットが含まれており、`aws-sdk` NPM パッケージへの依存関係が設定されている必要があります。
</Callout>
