【Cognito】Cognito Custom Message Trigger is not working when I use the link verification type

If you are using cognito, we can customize sign up message using Custom Message Trigger.

According to documentation, you can customize your sign up email using this source code.

exports.handler = (event, context, callback) => {
//
if(event.userPoolId === "theSpecialUserPool") {
// Identify why was this function invoked
if(event.triggerSource === "CustomMessage_SignUp") {
// Ensure that your message contains event.request.codeParameter. This is the placeholder for code that will be sent
event.response.smsMessage = "Welcome to the service. Your confirmation code is " + event.request.codeParameter;
event.response.emailSubject = "Welcome to the service";
event.response.emailMessage = "Thank you for signing up. " + event.request.codeParameter + " is your verification code";
}
// Create custom message for other events
}
// Customize messages for other user pools
// Return to Amazon Cognito
callback(null, event);
};

As you can see, this code is for customization of Code verification type.

Although you are using Link verification type, it’s triggered when user sign up to your service. (You can check that into the Cloudwatch log group). But real email sent to user is not changed.

Your event.response.emailMessage contents are incorrect. That’s why email sent to user is not changed.

The value {####} is set into event.request.codeParameter, but you need to use the value like {##Verify Email##} to customize email for Link verify type.

If you change event.response.emailMessage like this, Custom Message Trigger will be working.

event.response.emailMessage = "Thank you for signing up. Please click {##this link##} to verify your email address.";

Korean, live in Japan. The programmer. I love to learn something new things. I’m publishing my toy projects using GitHub. Visit https://www.jangwook.net.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Construindo uma aplicação simples com Elixir e Phoenix.

“Angular2 — The Complete Guide” readalong: Part Two, Data Binding

Theming Angular with CSS Variables

Making a calculator with Node.js

How to implement ANT Design with React

Effective Javascript Model Design

Javascript Closures

How to Integrate Admin Panel Template to Laravel v8

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jangwook Kim

Jangwook Kim

Korean, live in Japan. The programmer. I love to learn something new things. I’m publishing my toy projects using GitHub. Visit https://www.jangwook.net.

More from Medium

The One Where I got Acquainted with AE Scripting

Localization basics: What are t9n, l10n, i18n, g11n? New secret language?

Sunday Project — Pushing ‘Symfony Translation status — Turkish Translation’ to 100%

[Jira-Part 1] Create a first issue in Jira