Amazon Cognito sends a verification email on forgot password requests. How can I update this verification email with personalized parameters so that it contains the following parameters: (username / email).
You can employ a lambda function for custom message similar to the one below. The code for the lambda function can be entered in the lambda console and configured through the Triggers panel in your user pool.
You need to check the event.triggerSource to make sure it is the forgotPassword event and you get access to the email and username as event.request.userAttributes.email and event.userName
exports.handler = function(event, context) {
//
if(event.userPoolId === "theSpecialUserPool") {
// Identify why was this function invoked
if(event.triggerSource === "CustomMessage_ForgotPassword") {
// Ensure that your message contains event.request.codeParameter. This is the placeholder for code that will be sent
event.response.smsMessage = "You requested to reset your password " + event.request.codeParameter;
event.response.emailSubject = "You requested to reset your password " + event.request.userAttributes.email + " " + event.request.userName;
event.response.emailMessage = "Thank you for signing up. " + event.request.codeParameter + " is your verification code " + event.request.userAttributes.email + " " + event.request.userName;
}
// Create custom message for other events
}
// Customize messages for other user pools
//
// Return result to Cognito
context.done(null, event);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With