Hi I get such error when login to ory cloud on con...
# ory-network
f
Hi I get such error when login to ory cloud on console
h
Can you please update the ory cli? :)
f
Well, should I reinstall?
h
on mac just do brew upgrade
otherwise follow the install instructions :)
f
Okay, I can login now, thanks
And I have one more question for updating identity-config
I need to customize email verification template
Which domain can be able to use for courier.templates.verification.valid.email.body.html ?
I tried like this
"verification": {
"invalid": { "email": { "body": {} } }, "valid": { "email": { "body": {"html": "http://localhost:3000/tmp.gotmpl"} } } }
But I got `URL
<http://localhost:3000>
is not allowed for
courier.templates.verification.valid.email.body.html
.`
Please help me
w
Hey @fierce-toothbrush-41957, for Cloud you can use base64-encoded URLs only. Try this:
email.body: base64://<your encoded string>
Not sure if it’ll work with a template that lives on
localhost
. If it doesn’t, try hosting it somewhere on the web 😉
f
Good, thanks
And I cannot customize title of verification email?
"smtp": {
"from_name": "My Company" }
I tried like this, but cannot see the result
p
And I cannot customize title of verification email?
Hi @fierce-toothbrush-41957 yes you can customize all aspects of the template, subject and your own smtp service.
f
I mean I changed only
from_name
, but cannot see my result
p
Copy code
NOTE
You can't customize the from_address and from_name fields without also setting your own email sending server (connection_uri).
https://www.ory.sh/docs/guides/emails#send-emails-using-your-smtp-server
👍 1
f
I tried
"body": {"html": "<https://3465-198-105-221-192.ap.ngrok.io/temp.txt>"}
w
the URL is not b64 encoded
f
But failed `URL
<https://3465-198-105-221-192.ap.ngrok.io>
is not allowed for
courier.templates.verification.valid.email.body.html
.`
After I encode the url and changed the config, I see only the url as text in verification email
Not content with templated html
w
ok, but as you see you don’t get errors which means that the template address was used successfully (
almost
)
is your template in the right format? should be
gotmpl
https://www.ory.sh/docs/kratos/concepts/email-sms#creating-templates
and you shared
"body": {"html": "<https://3465-198-105-221-192.ap.ngrok.io/temp.txt>"}
-> looks like a
.txt
file if I’m not mistaken
f
In this file, I wrote template code
And got b64 code of the url
"body": {"html": "base64://aHR0cHM6Ly8zNDY1LTE5OC0xMDUtMjIxLTE5Mi5hcC5uZ3Jvay5pby9lbWFpbF90ZW1wbGF0ZS92ZXJpZmljYXRpb24uZ290bXBs"}
Tried like this
But I cannot get correct content in email
I am not sure why should encode the url as b64
w
ok, that looks right from the config side of things. Is the template itself error-free? I’m no expert, but maybe have a look at that?
f
Copy code
Hi, please verify your account by clicking the following link:

<a href="{{ .VerificationURL }}">{{ .VerificationURL }}</a>
Here is the content of the template
I used sample one
w
@proud-plumber-24205 any ideas what might be wrong in this setup?
f
p
@fierce-toothbrush-41957 We don't support setting the email templates URL to a domain / ip address. It must be a base64 string.
We are still working on adding support for external resources for this, due to it being a security risk.
f
So it doesn't work, you mean?
They don't accept any http and https url for my custom template
I tried with localhost, ngrok and external domain, but all of them failed to set
Would you give me exact answer it is possible or not?
l
@proud-plumber-24205 We understood that we can’t use external resources (domain/ ip address)
How about localhost? We get a different error, @fierce-toothbrush-41957 can you show the error please?
f
"URL
<http://localhost:3000>
is not allowed for
courier.templates.verification.valid.email.body.html
." "URL
<https://3465-198-105-221-192.ap.ngrok.io>
is not allowed for
courier.templates.verification.valid.email.body.html
."
I tried on local and got such error
p
Hi @fierce-toothbrush-41957 and @little-farmer-9523 You cannot use any URL (localhost, external IP, domain etc.) it must be a base64 encoded string. You have to take the template and encode it to a string like so https://www.base64encode.org/
then copy the encoded string and add it to the configuration file, like so:
Copy code
<base64://SGksIHBsZWFzZSB2ZXJpZnkgeW91ciBhY2NvdW50IGJ5IGNsaWNraW5nIHRoZSB>mb2xsb3dpbmcgbGluazoKCjxhIGhyZWY9Int7IC5WZXJpZmljYXRpb25VUkwgfX0iPnt7IC5WZXJpZmljYXRpb25VUkwgfX08L2E+
https://www.ory.sh/docs/kratos/concepts/email-sms#remote-templates
This document is about the open source. We fully support URLs, File resources and base64 in the open source. But we disabled URL and File support on our Cloud service
l
Okay we didn't get it, thx we will test now
👍 1
@proud-plumber-24205 And for
i18n customization
in Ory Cloud, we have to use nested templates: • with remotes templates? • or it’s also possible with a separate templates folder?
p
Hi @little-farmer-9523 You will need to construct the template in the same file https://www.ory.sh/docs/kratos/concepts/email-sms#nested-templates-with-remote-templates
l
Okay thx
@proud-plumber-24205 file does work with Ory cloud
So I guess it’s only URLs that are forbidden in Ory Cloud
w
So what is the file location in such scenario @little-farmer-9523 ?
l
Is it possible to find an example for verification or recovery in two languages?
Copy code
{{define "en_US"}}
{{ $l := cat "lang=" .lang }}
{{ nospace $l }}
{{end}}

{{- if eq .lang "en_US" -}}
{{ template "en_US" . }}
{{- end -}}
@fierce-toothbrush-41957 can you share the file?
f
Here is config
I show screenshot
And here is folder structure
l
@wonderful-lamp-2357
f
And here is email.body.gotmpl
l
@wonderful-lamp-2357 @proud-plumber-24205 We thought we would override the template folder but looks like we can’t with Ory Cloud So now we are using remote files
<file://xxxx>
and it works but kind of difficult to understand the syntax for nested templates. Could you share another example for nested templates with remote files because the syntax below is not clear?
Copy code
{{define "en_US"}}
{{ $l := cat "lang=" .lang }}
{{ nospace $l }}
{{end}}

{{- if eq .lang "en_US" -}}
{{ template "en_US" . }}
{{- end -}}
language
is added as a trait in our case
p
The templates use standard Go HTML and Text templates https://pkg.go.dev/html/template Basically the first part defines the template
Copy code
{{ define "en_US"}}
everything inside of that is the
en_US
template. We can then do our logic using if statements
Copy code
{{- if eq .lang "en_US" -}}
In this case
.lang
is arbitrary and here you will be referencing your Identity traits through
Identity.traits.language
https://www.ory.sh/docs/kratos/concepts/email-sms#creating-templates
if true it will render the
en_US
template at
template "en_US"
l
Got it but it’s still not working
It starts to become frustrating 😛
Here is the part of the config file • It’s using base64
Copy code
"courier": {
    "smtp": {
      "from_name": "Voxiplan-DEV via Ory"
    },
    "templates": {
      "recovery": {
        "invalid": {
          "email": {
            "body": {}
          }
        },
        "valid": {
          "email": {
            "body": {
              "html": "<base64://e3tkZWZpbmUgImVuIn19CkhpICwKCkNsaWNrIGJlbG93IHRvIHJlY292ZXIgYWN>jZXNzIHRvIHlvdXIgYWNjb3VudDoKCjxhIGhyZWY9Int7IC5SZWNvdmVyeVVSTCB9fSI+e3sgLlJlY292ZXJ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r3OtM61z4POvM6/OgoKe3sgLlJlY292ZXJ5VVJMIH19CgrOlc+Fz4fOsc+BzrnPg8+Ez44sClRlYW0gVm94aXBsYW4Ke3tlbmR9fQoKe3stIGlmIGVxIC5JZGVudGl0eS50cmFpdHMubGFuZ3VhZ2UgImRlIiAtfX0Ke3sgdGVtcGxhdGUgImRlIiAuIH19Cnt7LSBlbHNlIGlmIGVxIC5JZGVudGl0eS50cmFpdHMubGFuZ3VhZ2UgImZyIiAtfX0Ke3sgdGVtcGxhdGUgImZyIiAuIH19Cnt7LSBlbHNlIGlmIGVxIC5JZGVudGl0eS50cmFpdHMubGFuZ3VhZ2UgIm5sIiAtfX0Ke3sgdGVtcGxhdGUgIm5sIiAuIH19Cnt7LSBlbHNlIGlmIGVxIC5JZGVudGl0eS50cmFpdHMubGFuZ3VhZ2UgIml0IiAtfX0Ke3sgdGVtcGxhdGUgIml0IiAuIH19Cnt7LSBlbHNlIGlmIGVxIC5JZGVudGl0eS50cmFpdHMubGFuZ3VhZ2UgImVsIiAtfX0Ke3sgdGVtcGxhdGUgImVsIiAuIH19Cnt7LSBlbHNlIC19fQp7eyB0ZW1wbGF0ZSAiZW4iIC4gfX0Ke3stIGVuZCAtfX0="
            },
            "subject": "<base64://VGVzdA>=="
          }
        }
      },
      "verification": {
        "invalid": {
          "email": {
            "body": {}
          }
        },
        "valid": {
          "email": {
            "body": {}
          }
        }
      }
    }
  },
No errors, it’s just using the built-in templates
@wonderful-lamp-2357 @proud-plumber-24205
email.body.gotmpl
Copy code
{{define "en"}}
Hi ,

Click below to recover access to your account:

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Or, use the following link:

{{ .RecoveryURL }}

Thanks,
Team Voxiplan
{{end}}

{{define "fr"}}
Bonjour ,

Cliquez ci-dessous pour récupérer l'accès à votre compte :

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Ou, utilisez le lien suivant :

{{ .RecoveryURL }}

Merci,
Team Voxiplan
{{end}}

{{define "it"}}
Ciao ,

Fare clic qui sotto per recuperare l'accesso al proprio account:

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Oppure, utilizzare il seguente link:

{{ .RecoveryURL }}

Grazie,
Team Voxiplan
{{end}}

{{define "nl"}}
Hallo ,

Klik hieronder om de toegang tot uw account te herstellen:

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Of, gebruik de volgende link:

{{ .RecoveryURL }}

Bedankt,
Team Voxiplan
{{end}}

{{define "de"}}
Hallo ,

Klicken Sie unten, um den Zugang zu Ihrem Konto wiederherzustellen:

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Oder verwenden Sie den folgenden Link:

{{ .RecoveryURL }}

Danke,
Team Voxiplan
{{end}}

{{define "el"}}
Γεια σας ,

Κάντε κλικ παρακάτω για να ανακτήσετε την πρόσβαση στο λογαριασμό σας:

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Ή χρησιμοποιήστε τον ακόλουθο σύνδεσμο:

{{ .RecoveryURL }}

Ευχαριστώ,
Team Voxiplan
{{end}}

{{- if eq .Identity.traits.language "de" -}}
{{ template "de" . }}
{{- else if eq .Identity.traits.language "fr" -}}
{{ template "fr" . }}
{{- else if eq .Identity.traits.language "nl" -}}
{{ template "nl" . }}
{{- else if eq .Identity.traits.language "it" -}}
{{ template "it" . }}
{{- else if eq .Identity.traits.language "el" -}}
{{ template "el" . }}
{{- else -}}
{{ template "en" . }}
{{- end -}}
email.body.plaintext.gotmpl
Copy code
{{define "en"}}
Hi ,

Click below to recover access to your account:

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Or, use the following link:

{{ .RecoveryURL }}

Thanks,
Team Voxiplan
{{end}}

{{define "fr"}}
Bonjour ,

Cliquez ci-dessous pour récupérer l'accès à votre compte :

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Ou, utilisez le lien suivant :

{{ .RecoveryURL }}

Merci,
Team Voxiplan
{{end}}

{{define "it"}}
Ciao ,

Fare clic qui sotto per recuperare l'accesso al proprio account:

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Oppure, utilizzare il seguente link:

{{ .RecoveryURL }}

Grazie,
Team Voxiplan
{{end}}

{{define "nl"}}
Hallo ,

Klik hieronder om de toegang tot uw account te herstellen:

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Of, gebruik de volgende link:

{{ .RecoveryURL }}

Bedankt,
Team Voxiplan
{{end}}

{{define "de"}}
Hallo ,

Klicken Sie unten, um den Zugang zu Ihrem Konto wiederherzustellen:

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Oder verwenden Sie den folgenden Link:

{{ .RecoveryURL }}

Danke,
Team Voxiplan
{{end}}

{{define "el"}}
Γεια σας ,

Κάντε κλικ παρακάτω για να ανακτήσετε την πρόσβαση στο λογαριασμό σας:

<a href="{{ .RecoveryURL }}">{{ .RecoveryURL }}</a>

Ή χρησιμοποιήστε τον ακόλουθο σύνδεσμο:

{{ .RecoveryURL }}

Ευχαριστώ,
Team Voxiplan
{{end}}

{{- if eq .Identity.traits.language "de" -}}
{{ template "de" . }}
{{- else if eq .Identity.traits.language "fr" -}}
{{ template "fr" . }}
{{- else if eq .Identity.traits.language "nl" -}}
{{ template "nl" . }}
{{- else if eq .Identity.traits.language "it" -}}
{{ template "it" . }}
{{- else if eq .Identity.traits.language "el" -}}
{{ template "el" . }}
{{- else -}}
{{ template "en" . }}
{{- end -}}
In case there is an error in Go HTML templates and like this it can be useful for the community to get good examples of nested templates in the same file when using remote files