Using custom email provider action for localisation

Hi, I actually gave some feedback for the current template functionality: More consistent localization behavior for all email templates in the Universal Login experience

In our project we ended up using the templates and liquid in that traditional way. Using the custom email provider in the way I described in this post felt a bit too hacky.

Though I think you could have a OTP email template:

{
  "code": "{{ code }}"
}

And then in the onExecuteCustomEmailProvider action pseudo code example:

exports.onExecuteCustomEmailProvider = async (event, api) => {
   const selectedLocale = deductLanguage(event.locale)
   const code = JSON.parse(event.text).code
   const template = getTemplate(event.notification.message_type)
   const emailContent = renderTemplate(template, { code, selectedLocale })
   // send the email with e.g. sendgrid api
}

The getTemplate and renderTemplate functionality would be defined in the action code but left out of this pseudo code example.

Note I did not check if that json syntax is allowed as email template…