1

I have user attributes family_name and given_name I want to use this in my verification email template like

hi {given_name} {family_name} your verification code is {####}

but the placeholder is not being replaced by the value. how can I achieve that?

Shree Rai
  • 29
  • 2
  • 5
  • https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-settings-message-templates.html - what makes you think `{given_name}` should do anything? – luk2302 Mar 15 '23 at 08:49

1 Answers1

0

I discover that AWS Cognito allows certain placeholders to be used in the verification emails. I created new lambda that gets triggers at Cognito custom-message-events and parses the provided parameter from Cognito and returns back as an event which fixed my issue. below is the sample code for that.

const forgot_password = async(event) => {
    let email = event.request.usernameParameter;
    let code = event.request.codeParameter;
    let username = event.request.userAttributes.username;
    event.response = {
        emailSubject: "Forgot password",
        emailMessage: "" + code + ""+username
    }
    return event
}

exports.handler = async(event) => {
    switch (event.triggerSource) {
        case "CustomMessage_ForgotPassword": 
            return forgot_password(event)
        default:
            return event

    }
};
blackgreen
  • 34,072
  • 23
  • 111
  • 129
Shree Rai
  • 29
  • 2
  • 5