使用Braze API发送邮件时,trigger_properties数据无法在模板显示
解决Braze API事务性邮件trigger_properties数据无法在模板显示的问题
问题情况
我用Braze API发送事务性邮件,手动触发发送功能是正常的,但在下面的curl请求里,我在trigger_properties中传入了自定义数据first_name,却没法在邮件模板里显示这个数据。
请求命令
curl -X POST \ -H 'Content-Type:application/json' \ -d '{ "campaign_id": "9854b86c-c185-3362-78a9-c442763bed9e", "trigger_properties": { "first_name":"First Name" }, "broadcast": false, "recipients": [ { "external_user_id": "xxxxx", "trigger_properties": { "first_name":"First Name" }, "send_to_existing_only": false, "attributes": { "first_name": "xxxxx", "last_name": "xxxxx", "email": "xxxx@xxxx.com" } } ] }' \ https://rest.fra-01.braze.eu/campaigns/trigger/send
邮件模板
Discover a new restaurant today{% if {{${first_name}}} == nil %}!{% else %}, {{${first_name}}}!{% endif %}
解决方案
问题出在模板的语法错误:
- Braze模板中引用变量只需要单一层的
${变量名}格式,不需要嵌套双大括号{{}} - 条件判断的语法格式有误,多余的嵌套括号会导致变量无法被识别
修正后的模板如下:
Discover a new restaurant today{% if ${first_name} == nil %}!{% else %}, ${first_name}!{% endif %}
额外检查点
如果修正后还是无法显示,可排查:
- 确认
trigger_properties在API请求中的位置正确(你当前的请求里,全局和收件人层级都设置了该字段,这部分没问题) - 检查邮件模板是否和当前触发的活动正确关联,避免模板与活动不匹配
内容的提问来源于stack exchange,提问作者Melchia
相关产品推荐
相关产品推荐

