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
}
};