このページでは:条件付きルールを使用してネストされたプロファイル配列を繰り返し処理するパーソナライゼーションの使用例に従って、受け取りや呼び出しの準備が整ったヘルスプランのメールリストの処方箋を作成します。
プロファイルには医療保険が含まれ、各保険には処方箋が含まれます。 処方箋には、「準備完了」、「リコール」、「受け取り済み」など、様々な状態があります。
このユースケースでは、受け取りの準備が整っている処方箋やリコールされた処方箋をすべて含めて、各プロファイルに 1 通のメールを送信します。 このユースケースの実装に使用する構文について詳しくは、以下の各タブをクリックしてください。
こんにちは、John Doe 様、
受け取りの準備が整っている処方箋やリコールされた処方箋は次のとおりです。
医療保険 A
- 処方箋ID: pres1
名前:薬A
状態:準備完了 - 処方箋ID: pres2
名前:薬B
状態:のリコール
医療保険 B
- 処方箋ID: pres4
名前:薬D
状態:準備完了
| code language-html |
|---|
|
| code language-javascript |
|---|
|
This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.
For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.
- TL;DR: This page demonstrates a complete personalization use case: iterating over nested profile arrays (health plans containing prescriptions) with conditional filtering to display only prescriptions in “ready” or “recall” states in an email.
Intents:
- See a rendered output example of a personalized health plan email
- Understand the HTML template using nested
{{#each}}and{%#if%}blocks for conditional array iteration - Understand the required profile data structure: a
plansarray where each plan contains aprescriptionsarray withstatefields
Glossary:
- Nested iteration: Using
{{#each}}loops inside other{{#each}}loops to traverse multi-level array structures in profile data (e.g., plans → prescriptions). - Prescription state: A field on each prescription object indicating its lifecycle status in this use case — values used are “ready”, “recall”, and “picked up”. (use-case specific)
{%#if%}/{%/if%}: Conditional block syntax used within message templates to filter array items during iteration (distinct from the double-curly{{#if}}Handlebars syntax).
Terminology:
- Canonical name: nested array iteration — variants: nested loops, nested each, multi-level iteration
- Do not confuse:
{{#each}}/{{/each}}(Handlebars iteration syntax, double curly braces) ≠{%#if%}/{%/if%}(conditional syntax, percent-curly braces) — both are used together in this template - Do not confuse: “ready” (prescription available for pickup) ≠ “recall” (prescription has been recalled) ≠ “picked up” (prescription already collected — excluded from the output by the conditional filter)
FAQ:
- Q: Which prescription states are included in the email output? — Only prescriptions with state “ready” or “recall” are displayed. Prescriptions with state “picked up” are excluded by the
{%#if prescription.state = "ready" or prescription.state = "recall"%}conditional filter. - Q: What profile data structure is required for this use case? — A profile with a
plansarray, where each plan object contains aprescriptionsarray. Each prescription object must haveprescription_id,name, andstatefields. - Q: How are plans and prescriptions iterated in the template? — The outer
{{#each profile.plans as |plan|}}loop iterates over each health plan. Inside it,{{#each plan.prescriptions as |prescription|}}iterates over each plan’s prescriptions, and a conditional block filters to only “ready” or “recall” states.