如何在WhatsApp Flow JSON中传入动态值?报错求助
WhatsApp Flow动态值缺失错误解决办法
错误原因
你在TextBody组件中使用了${data.area}和${data.pincode}动态变量,但当前屏幕的data字段是空对象{},没有定义这两个变量,导致Flow无法找到对应数据,从而抛出缺失动态数据的错误。
解决步骤
- 添加默认值或声明变量:在当前屏幕的
data字段中添加对应变量的定义,可以设置默认值,或者仅声明键名留空(用于接收外部传入的数据):"data": { "area": "默认区域", "pincode": "默认邮编" } - 确保外部数据传入:如果
area和pincode是从Flow启动请求、或上一个屏幕的交互结果中传递过来的,需要确保上游数据包含这两个字段,同时当前屏幕的data字段中存在对应的键名(即使值为空)。
修正后的完整JSON示例
{ "version": "3.1", "screens": [ { "id": "", "title": "Address", "data": { "area": "", "pincode": "" }, "terminal": true, "layout": { "type": "SingleColumnLayout", "children": [ { "type": "Form", "name": "flow_path", "children": [ { "type": "TextInput", "name": "TextInput_23f9a3", "label": "Enter House Address", "required": true, "input-type": "text", "helper-text": "Please enter your house number, floor number and building number." }, { "type": "TextBody", "text": "${data.area}", "visible": true }, { "type": "TextBody", "text": "${data.pincode}", "visible": true }, { "type": "Footer", "label": "Save Address", "on-click-action": { "name": "complete", "payload": { "screen_0_TextInput_0": "${form.TextInput_23f9a3}" } } } ] } ] } } ] }
内容的提问来源于stack exchange,提问作者Ishant Jindal
相关产品推荐
相关产品推荐

