8000 Updated Docs for Render Template by vaibhavK1199 · Pull Request #73 · dimagi/open-chat-studio-docs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Updated Docs for Render Template #73

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

Open
wants to merge 3 commits into
base: main
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
12 changes: 12 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,15 @@ hide:
* Currently we have to create it manually through the admin dashboard, but a near future release will include a dedicated page to view/edit participant data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrase 'but a near future release' should be revised for clarity.

Suggested change
* Currently we have to create it manually through the admin dashboard, but a near future release will include a dedicated page to view/edit participant data.
but a near-future release

* Please note that participant data is experiment specific, meaning that data we have for a participant in one
experiment may not be the same for the next experiment.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrase 'meaning that data we have for a participant in one experiment may not be the same for the next experiment' can be made more concise.

Suggested change
experiment may not be the same for the next experiment.
meaning that participant data may vary between experiments.


## Mar 11, 2025

* **NEW** Updated Render Template node context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term 'RenderTemplate' should be consistently formatted, either as 'Render Template' or 'RenderTemplate'.

Suggested change
* **NEW** Updated Render Template node context
Render Template

* The RenderTemplate node now provides more context for Jinja templates, allowing dynamic rendering without an additional Code Node.
* The template context includes the following variables:
- `input`: The node’s input (string).
- `temp_state`: Pipeline temporary state (dict).
- `participant_details`: Participant details with `identifier` and `platform` keys (dict).
- `participant_data`: Participant data
- `participant_schedules`: Participant schedule data (list).
* This enhancement enables templates to access participant details, pipeline state, and other session data directly, improving flexibility for nodes like `SendEmail`.
46 changes: 46 additions & 0 deletions docs/concepts/pipelines/nodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,52 @@ content = attachment.read_text()
## Template
Renders a [Jinja](https://jinja.palletsprojects.com/en/stable/templates/) template.

The RenderTemplate node ensures that the template node can access and render content dynamically based on participant details, pipeline temporary state, participant data, participant schedules, and the node’s input. This eliminates the need for an additional Code Node to configure the context.

### Available Template Variables
The following variables are available in the template context:

| Key | Description | Type |
|-------------------------|------------------------------------------------|--------|
| `input` | The input to the node | String |
| `temp_state` | Pipeline temporary state | Dict |
| `participant_details` | Participant details (`identifier`, `platform`) | Dict |
| `participant_data` | Participant data | Dict |
| `participant_schedules` | Participant schedule data | List |

### Sample State
`json
{
"experiment_session": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this example an example of what a real context might look like?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is just a simplified example for real Pipeline State object

"participant": {
"identifier": "participant_123",
"platform": "web"
}
},
"messages": ["Cycling"],
"temp_state": {
"my_key": "example_key"
},
"pipeline_version": 1,
"outputs": {}
}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON format in 'Sample State' section is missing a closing brace.

Suggested change
}`
Add a closing brace to the JSON: }


### Sample Template
`Input: {{ input }}
Temp State Key: {{ temp_state.my_key }}
Participant ID: {{ participant_details.identifier }}
Participant Platform: {{ participant_details.platform }}
Participant Data: {{ participant_data.custom_key }}
Schedules: {{ participant_schedules }}
`
### Sample Output
`Input: Cycling
Temp State Key: example_key
Participant ID: participant_123
Participant Platform: web
Participant Data: custom_value
Schedules: []
`
## Email
Send the input to the specified list of email addresses. This node acts as a passthrough, meaning the output will be identical to the input, allowing it to be used in a pipeline without affecting the conversation.

Expand Down
0