1
0

【AWS】Cognitoのカスタムメッセージ Lambda トリガーでメール本文が変わらない問題

Posted at

カスタムメッセージとは

以下は Cognito の Lambda トリガーでカスタマイズしたメール:

image.png

カスタムメッセージ Lambda トリガーでメール件名・本文のカスタマイズを行うことができる。

image.png

発生事象

メール件名は変更できたが、メール本文は変わらなかった。

カスタムメッセージ Lambda トリガーを使用するときの注意点

注意点1

  • メールアドレス検証メッセージは「Code」を選択していること

image.png

注意点2

  • レスポンスに event.request.codeParameter を含めること

emailMessage
ユーザーに送信するカスタム E メールメッセージ。emailMessage パラメータで HTML 書式を使用できます。リクエストで受信される codeParameter 値を変数 {####} として含める必要があります。

下記ドキュメントの カスタムメッセージレスポンスパラメータ 参照。

イベントとレスポンス

  • Lambda 関数が受け取るイベント
{
  version: '1',
  region: 'your-region',
  userPoolId: 'your-user-pool-id',
  userName: 'user-name',
  callerContext: {
    awsSdkVersion: 'aws-sdk-js-3.614.0',
    clientId: 'your-user-pool-client-id'
  },
  triggerSource: 'CustomMessage_SignUp',
  request: {
    userAttributes: {
      sub: 'user-sub-value',
      email_verified: 'false',
      'cognito:user_status': 'UNCONFIRMED',
      email: 'your@email.address'
    },
    codeParameter: '{####}', // この値を event.response.emailMessage に含める必要がある
    linkParameter: '{##Click Here##}',
    usernameParameter: null
  },
  response: { smsMessage: null, emailMessage: null, emailSubject: null }
}

サンプルコードは以下参照:

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0