# Using custom email provider action for localisation

**URL:** <https://community.auth0.com/t/using-custom-email-provider-action-for-localisation/147774>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [September 23, 2024, 6:48am UTC](https://community.auth0.com/t/using-custom-email-provider-action-for-localisation/147774 "2024-09-23T06:48:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhautala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mhautala/32/33331_2.png) [@mhautala](https://community.auth0.com/u/mhautala)\
**Post date:** [September 23, 2024, 6:48am UTC](https://community.auth0.com/t/using-custom-email-provider-action-for-localisation/147774/1 "2024-09-23T06:48:56Z")

</div>

Common approach for email template localisations seems to be quite akward if else liquid syntax in the templates:

[https://community.auth0.com/t/customizing-a-single-email-template-for-multiple-languages/139040](https://community.auth0.com/t/customizing-a-single-email-template-for-multiple-languages/139040)

Is there some reason the custom email provider could not be used for localisations?’

You could have for example a passwordless otp template in Auth0 email connection:

```auto
{% raw %}
{{ otpHeader }}
{% endraw %}
{{ code }}

```

Then in the custom provider action you would render the event.html content again with the dictionary and using the event.locale for deducting the selected language.

Action pseudo code:

```auto
exports.onExecuteCustomEmailProvider = async (event, api) => {
   const selectedLocale = deductLanguage(event.locale)
   const templateParams = { otpHeader: dictionary[selectedLocale].otpHeader }
   const emailContent = renderLiquid(event.html, templateParams)
   // send the email with e.g. sendgrid api
}

```

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [March 25, 2025, 5:58pm UTC](https://community.auth0.com/t/using-custom-email-provider-action-for-localisation/147774/3 "2025-03-25T17:58:07Z")

</div>

Hi @mhautala

I am sorry bout the late reply to your post!

Indeed, localization for email templated is quite limited, being available only through liquid syntax. It would be a great function to allow the custom email providers to handle the localization of emails or have an option inside the Auth0 dashboard to allow localization settings.

I would suggest to post on our [Feedback](https://community.auth0.com/c/feedback/95) page regarding a potential use case and implementation for this.

If you have any other questions, feel free to let me know!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![mhautala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mhautala/32/33331_2.png) [@mhautala](https://community.auth0.com/u/mhautala)\
**Post date:** [March 26, 2025, 7:23am UTC](https://community.auth0.com/t/using-custom-email-provider-action-for-localisation/147774/4 "2025-03-26T07:23:56Z")

</div>

Hi, I actually gave some feedback for the current template functionality: [More consistent localization behavior for all email templates in the Universal Login experience](https://community.auth0.com/t/more-consistent-localization-behavior-for-all-email-templates-in-the-universal-login-experience/148387)

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:

```auto
{
  "code": "{{ code }}"
}

```

And then in the onExecuteCustomEmailProvider action pseudo code example:

```auto
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…

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 9, 2025, 7:24am UTC](https://community.auth0.com/t/using-custom-email-provider-action-for-localisation/147774/5 "2025-04-09T07:24:22Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
