如何在 WhatsApp Flow 中动态定义输入类型?

问题描述 投票:0回答:1

参见下面的示例 -

{ “类型”:“文本输入”, “名称”:“文本输入”, "输入类型": "${data.textInputType}", “标签”:“你的名字” }

我只想在数据示例中定义该输入类型,提前谢谢您!

我已经对 facebook/whatsapp 文档和所有内容进行了完整的研究,是的 Whatsapp 流程支持动态输入类型,但他们的文档中没有提到该示例。

facebook whatsapp whatsapp-cloud-api whatsapp-flows
1个回答
0
投票

目前不支持此功能,

input-type
无法动态。您能否解释一下您的用例,以便我可以提出替代方案?

也许您可以拥有多个不同类型的

TextInput
组件,并根据
visible
属性决定显示哪一个?检查组件文档中的“步骤 5 - 控制组件的可见性”部分

这是一个具有动态输入类型的流 JSON 示例,但当您在流操场中尝试时会显示错误https://developers.facebook.com/docs/whatsapp/flows/playground

{
  "version": "2.1",
  "data_api_version": "3.0",
  "routing_model": {},
  "screens": [
    {
      "id": "DEMO_SCREEN",
      "title": "Demo Screen",
      "terminal": true,
      "data": {
        "input_type": {
          "type": "string",
          "__example__": "email"
        }
      },
      "layout": {
        "type": "SingleColumnLayout",
        "children": [
          {
            "type": "Form",
            "name": "text_input_form",
            "init-values": {
              "text input": "This is text input",
              "text area": "This is text area"
            },
            "children": [
              {
                "type": "TextInput",
                "required": true,
                "label": "${data.input_type}",
                "input-type": "${data.input_type}",
                "name": "text input"
              },
              {
                "type": "Footer",
                "label": "Continue",
                "on-click-action": {
                  "name": "complete",
                  "payload": {}
                }
              }
            ]
          }
        ]
      }
    }
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.