You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 20:43:12