Interruzione parzialeshare-external
Feature Request: Accessing Dynamic Data Elements in WhatsApp Flow
1

We request a feature that enables accessing dynamic keys within JSON objects in WhatsApp flows. This enhancement would help us retrieve specific values based on user selection without relying on fixed keys. The ability to reference keys dynamically, especially from form inputs, would reduce the need for additional data exchanges and improve the flexibility and responsiveness of our flows.

Example of What We Need Consider we have a data structure like this:

{
    "items": {
        "item_1": {
            "attribute_1": "value_1",
            "attribute_2": "value_2"
        },
        "item_2": {
            "attribute_1": "value_1",
            "attribute_2": "value_2"
        }
    }
}

In the flow, we would like to access these properties dynamically based on a user’s form selection. For instance, if a user selects an item in a dropdown, we want to retrieve its specific attributes without hardcoding each key. Ideally, we could use syntax such as:

{
    "type": "Dropdown",
    "name": "selected_item",
    "label": "Select an item",
    "data-source": "${data.list}"
},
{
    "type": "If",
    "condition": "${form.selected_item} != ''",
    "then": [
          {
              "type": "TextHeading",
              "text": "${data.items[form.selected_item].attribute_1"
          },
          {
              "type": "TextInput",
              "input-type": "text",
              "label": "Label",
              "name": "value_2",
              "init-value": "${data.items[form.selected_item].attribute_2"
          }
    ]
}

where form.selected_item could dynamically refer to item_1, item_2, etc., based on the user’s selection.

Use Case and Goal Imagine a scenario where the user selects an option from a list in a form. With this feature, we could immediately access and display specific attributes (like attribute_1 or attribute_2) of the selected item in the flow, without needing to send additional data requests to retrieve each attribute separately.

This capability would save time, reduce data requests, and significantly improve the user experience by providing real-time access to dynamic data based on selections.

Djoumessi
Chiesta circa 2 settimane fa
Risposta selezionata
3

Djoumessi - checkout the new Flow JSON version release, 6.0, from earlier this week: https://developers.facebook.com/docs/whatsapp/flows/changelogs#november-12th--2024-release

It includes a couple of new features that can help you build your use-case.

14 novembre alle ore 11:42
Bar
Risposta selezionata
4

keep an eye on the changelog for some exciting releases in the coming days

8 novembre alle ore 08:05
Sukhbir