Skip to content

Commit

Permalink
fix: transient payload in email templates
Browse files Browse the repository at this point in the history
  • Loading branch information
vinckr committed Dec 20, 2024
1 parent 8a02ac0 commit 8a6a2ae
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/guides/integrate-with-ory-cloud-through-webhooks.mdx
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>
```

0 comments on commit 8a6a2ae

Please sign in to comment.