Email challenge template
Choose the email template of the identity-confirmation email sent during an enrolment, or skip the email, with runtime.emailAccountChallenger.templateFinder.
When the tenant requires customers to confirm their identity, an enrolment does not create anything straight away: The Wallet Crew sends an email with a link, and the enrolment continues when the customer opens it. This identity-confirmation email always uses the template configured on the email account challenger. The template finder lets a tenant script choose another template for each email, based on what the enrolment carries, or decide that no email should be sent at all. This page is the reference for runtime.emailAccountChallenger.templateFinder.
The template finder only chooses the template name. Sending the email through another service is the job of the email engine; emails sent by the mail steps of a registration flow are not concerned.
Registration
The key is runtime.emailAccountChallenger.templateFinder. It only has an effect when the tenant has an email account challenger (the setting that sends the identity-confirmation email), configured in server/account.yml:
checkInSecurityMode: partial
accountChallengers:
- type: email
templateName: confirm-identitytemplateName is the default template, which the script receives and can keep. The optional identifiers list of the challenger restricts which identifiers count when the challenger checks that a customer exists.
The minimal skeleton is:
export default function (context) {
context.register('runtime.emailAccountChallenger.templateFinder', {
GetEmailTemplate: async (data, defaultTemplateName) => defaultTemplateName
});
}When it runs
The script runs each time the email account challenger is about to send its email, inside the enrolment request (POST /api/{tenantId}/customer). Whether that happens depends on checkInSecurityMode and on the caller: with full (the default), every enrolment by an unauthenticated caller receives the email; with partial, only an enrolment whose customer already exists does, after the customer providers have looked the customer up; with none and noIdentification, no identity-confirmation email is sent. An account without an email address receives no email and the script is not called.
Handlers
GetEmailTemplate
data, defaultTemplateName
a template name, null, or a promise of either
Required
data holds the values the email will be rendered from: the account as submitted and completed by the customer providers (data.email, data.firstName, identifiers under id.<key> such as data['id.crm.customerId']), plus data.authenticationToken, the token of the link that continues the enrolment. defaultTemplateName is the templateName of the challenger.
Return value
defaultTemplateName
The configured template is sent.
Another template name
That template is sent. It must be an email template of the tenant.
null or undefined
No email is sent.
When no email is sent, the enrolment request still answers that a confirmation email was sent to the customer's address, since the challenge itself took place. A front end that relies on that answer then tells the customer to check an inbox that receives nothing, so skipping the email is reserved for cases where the customer is told otherwise.
Errors and edge cases
GetEmailTemplate throws or its promise rejects: no email is sent and the enrolment request fails.
GetEmailTemplate is missing from the registered object: the challenge fails when the script is called.
No script registers the key: the configured
templateNameis used.Several files register the key: the last registered wins, and the load order of files is not defined.
Example
Customers already known to the CRM, recognized by the CRM identifier a customer provider found, receive a "welcome back" email. The others receive the configured email. The example needs checkInSecurityMode: partial, as explained in the pitfalls below.
A language variant picks the template from a language value of the account, with the default as fallback.
The prefix neostore is the platform's former name and is kept in technical identifiers such as neo.lng.
Checking the result
A test enrolment with a mailbox the team controls shows which template arrived. Trying both cases (a known and an unknown customer) confirms each branch. When no email arrives at all, the platform's monitoring shows whether the script threw, and the email provider's logs whether a send was attempted.
Common pitfalls
The template returned by the script does not exist in the tenant's email templates.
With
checkInSecurityMode: full, the customer providers have not run when the email is sent, so a test on an identifier never matches;partialmode looks the customer up first.Returning
nullby mistake (a missingreturnin one branch of anasyncfunction) silently suppresses the email.
Last updated

