Customizing user invitation messages on a per user basis

0

Fellow AWS devs,

I have a question about modifying the invitation emails sent out by Cognito after creating users with the adminCreateUser method.
For the email verification messages I managed to adjust the mails using a custom lambda method that is checking for event.triggerSource === "CustomMessage_ForgotPassword" . I set this lambda to be triggered under triggers in the Cognito console under Custom message entry.

When adminCreateUser is called for a new user, I do see the same lambda method being trigger, just this time with event.triggerSource === "CustomMessage_AdminCreateUser" .
But when I adjust the text with

   event.response.emailMessage = htmlBody;

, the email received is still the static text setup in the cognito console, not the modified one. Modifying the response.emailMessage for the verification mails works though.

Whats the trick getting user-invitation emails modified?

PS: the static email text in the cognito console is unfortunately not enough, as I have different clients using the same cognito pool and want to modify the emails on a per-client basis.

Edited by: Bersaelor on Apr 29, 2020 3:59 PM

질문됨 4년 전807회 조회
1개 답변
0

I figured it out myself:

Since I hadn't adjusted the file with the html body being loaded, the event.response.emailMessage = htmlBody was being set with the verification email text in both cases.

And the verification email text didn't contain a {username} placeholder. Once I had this placeholder in a proper user-welcome email the modified email was sent out instead of the static one in the cognito console. So, all solved.

답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠