> ## 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.

# Send Phone Message

> SMS または Voice を多要素認証（MFA）の認証要素として使用する際に、登録およびチャレンジのプロセスで実行される Send Phone Message Actions について説明します。

`send-phone-message` トリガーは、SMS/Voice を[多要素認証 (MFA) ](/docs/ja-jp/secure/multi-factor-authentication)の認証要素として使用する際に実行されます。登録プロセスとチャレンジプロセス (`event.message_options.action`) の両方で実行され、<Tooltip tip="Universal Login: アプリケーションは、ユーザーのアイデンティティを検証するために、Auth0 の認可サーバーでホストされる Universal Login にリダイレクトします。" cta="用語集を表示" href="/docs/ja-jp/glossary?term=Universal+Login">Universal Login</Tooltip> の New experience を使用している場合は、`voice` メッセージタイプ (`event.message_options.message_type === 'voice'`) でも実行されます。メッセージの送信に[カスタムプロバイダー](/docs/ja-jp/secure/multi-factor-authentication/multi-factor-authentication-factors/configure-sms-voice-notifications-mfa#custom-phone-messaging-providers)を使用する場合、このトリガーはカスタムプロバイダーの設定に必要です。

<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="references">
  ## リファレンス
</div>

* [イベントオブジェクト](/docs/ja-jp/customize/actions/reference/send-phone-message/send-phone-message-event-object): 送信するメッセージ、およびchallenge の対象となるユーザーまたは登録するユーザーに関するコンテキスト情報を提供します。
* [API オブジェクト](/docs/ja-jp/customize/actions/reference/send-phone-message/send-phone-message-api-object): フローの動作を変更するためのメソッドを提供します。

<div id="common-use-cases">
  ## 一般的なユースケース
</div>

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

send-phone-message Actionを使用すると、カスタムSMSプロバイダー経由でMFAメッセージを送信できます。

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

/**
 * @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が正しく実行されるには、`AWS_REGION`、`AWS_ACCESS_KEY_ID`、`AWS_SECRET_ACCESS_KEY`という名前のsecretsが設定されており、`aws-sdk`の`npm` packageにdependencyがある必要があります。
</Callout>
