mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 17:08:03 +08:00
feat(api): support variable reference and substitution in Email delivery
The EmailDeliveryConfig.body now support referencing variables generated by precedent nodes.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
from core.workflow.nodes.human_input.entities import EmailDeliveryConfig, EmailRecipients
|
||||
from core.workflow.runtime import VariablePool
|
||||
|
||||
|
||||
def test_replace_url_placeholder_with_value():
|
||||
@ -23,3 +24,17 @@ def test_replace_url_placeholder_missing_value():
|
||||
result = config.body_with_url(None)
|
||||
|
||||
assert result == "No link available."
|
||||
|
||||
|
||||
def test_render_body_template_replaces_variable_values():
|
||||
config = EmailDeliveryConfig(
|
||||
recipients=EmailRecipients(),
|
||||
subject="Subject",
|
||||
body="Hello {{#node1.value#}} {{#url#}}",
|
||||
)
|
||||
variable_pool = VariablePool()
|
||||
variable_pool.add(["node1", "value"], "World")
|
||||
|
||||
result = config.render_body_template(body=config.body, url="https://example.com", variable_pool=variable_pool)
|
||||
|
||||
assert result == "Hello World https://example.com"
|
||||
|
||||
Reference in New Issue
Block a user