I am trying to customize the message sent to the user pre-verification by using the custom message trigger, I verified that the data returned from the lambda is valid and the modifications are as I want them to be, however it seems that those changes are not taking any effect as I get the standard verification details to my email
I failed to find any solutions in aws docs, anyone had the same issue ?
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
// Handler will handle our request comming from the API gateway
func Handler(event events.CognitoEventUserPoolsCustomMessage) (events.CognitoEventUserPoolsCustomMessage, error) {
if event.TriggerSource == "CustomMessage_SignUp" {
event.Response.EmailMessage = "Welcome to myapp, please click the following link to verify your email, this is a custom message"
event.Response.EmailMessage = fmt.Sprintf(`Please click the link below to verify your email address. https://apigateway.myapp.com/auth/validate?client_id=%s&user_name=%s&confirmation_code=%s`, event.CallerContext.ClientID, event.UserName, event.Request.CodeParameter)
}
return event, nil
}
func main() {
lambda.Start(Handler)
}
Since the default email is very plain, is quite common to have to provide a custom implementation. In order to customize the default email messages provided by cognito is by creating a Custom message lambda trigger. Let's implement the entry point of our Custom Message trigger function:
Amazon Cognito can invoke a Lambda trigger at multiple events: post-registration, resending a verification code, recovering a forgotten password, or verifying a user attribute. The response includes messages for both SMS and email. The message must include the code parameter "####".
Custom message – When a user's email or phone number is changed, this trigger sends a verification code automatically to the user. Cannot be used for other attributes. Custom message – This trigger sends a verification code to the user when they manually request it for a new email or phone number.
Message Customization on Cognito 1 Ways to configure message customization 2 AWS Console. In AWS Console, when can navigate to AWS Cognito User Pool and select the user pool you want to edit and navigate to the "Message Customization" tab. 3 AWS CLI. ... 4 Custom message via Lambda function trigger. ...
It seems that in the cognito panel under message customizations verification type code needs to be checked (not link), after I did that the trigger does change the message
It works also for verification link, but you have to use the code parameter as {##Verify email##}
and not {####}
in your User Pool - Message customization settings. And then also use {##Verify email##}
keyword in your html template.
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