Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: transient payload in email templates #1967

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Use the `ctx` object to access these fields in your Jsonnet template, for exampl
```jsonnet title="./segment_identify.jsonnet"
function(ctx) {
userId: ctx.identity.id,
customData: ctx.transient_payload.custom_data
customData: ctx.flow.transient_payload.custom_data
traits: {
email: ctx.identity.traits.email,
name: ctx.identity.traits.name,
Expand Down
38 changes: 38 additions & 0 deletions docs/kratos/emails-sms/05_custom-email-templates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,41 @@ Since metadata is not validated by Ory Identities, missing entries or unexpected
process. If the system encounters errors in the rendering process, Ory Identities uses the default templates.

:::

### Transient payload in templates

The transient payload allows you to pass additional data along with certain self-service flows. Transient payloads can be used for
passing temporary information to your email template without storing it permanently.

The following `example_key` transient payload

```
...
traits: {
email: "user@example.com",
},
transient_payload: {
example_key: "This is an example value"
},
...
```

can be accessed in the email template using `{{index .TransientPayload "example_key"}}`

```gotmpl

<h1>Recovery Details</h1>
<p>To: {{.To}}</p>
<p>Recovery URL: {{.RecoveryURL}}</p>
<p>Transient Payload: {{index .TransientPayload "example_key"}}</p>

```

This results into the following email to be sent to the user.

```gotmpl
<h1>Recovery Details</h1>
<p>To: user@example.com</p>
<p>Recovery URL: https://example.com/recover</p>
<p>Transient Payload: This is an example value</p>
```
Loading