whatsapp-flows

Is it possible to set the initial value of a date picker in WhatsApp business flows?


I am trying to use a flow for registration and edit profile in a whatsapp bot. Registration is straightforward but when the user edits their profile I need to pre-populate the data with the user’s data. This works for all values other than dates.

I have tried to specify the initial value for date of birth for example in init-values but that doesn’t seem to do anything.

Is it not possible for a date picker to have an initial value in a WhatsApp flow?


Solution

  • DatePicker can be initialised using a value expressed in milliseconds as a string. Here is an example where DatePicke is initialised to 15 Feb 2024 (in milliseconds, 1707955200000):

    {
      "version": "3.1",
      "screens": [
          {
              "id": "WELCOME_SCREEN",
              "layout": {
                  "type": "SingleColumnLayout",
                  "children": [
                      {
                        "type": "Form",
                        "name": "form",
                        "init-values": {
                            "text_input": "Init text",
                            "date_input": "1707955200000"
                        },
                        "children": [
                          {
                            "type": "TextInput",
                            "label": "Text input",
                            "name": "text_input"
                          },
                          {
                            "type": "DatePicker",
                            "label": "Date picker",
                            "name": "date_input"
                          },
                          {
                            "type": "Footer",
                            "label": "OK",
                            "on-click-action": {
                              "name": "complete",
                              "payload": {}
                            }
                          }
                        ]
                      }
                  ]
              },
              "title": "Welcome",
              "terminal": true,
              "success": true,
              "data": {}
          }
       ]
    }