Flows Examples#

Tip

This page contains examples of flows for different versions of the WhatsApp Business API.

You can find the code in the tests/data/flows directory of the repository.

v7.1 Examples#

Python Code#
 1from pywa.types.flows import *  # noqa
 2
 3image_carousel = FlowJSON(
 4    version="7.1",
 5    screens=[
 6        Screen(
 7            id="DEMO_SCREEN",
 8            terminal=True,
 9            title="Demo screen",
10            layout=Layout(
11                type=LayoutType.SINGLE_COLUMN,
12                children=[
13                    ImageCarousel(
14                        scale_type=ScaleType.COVER,
15                        images=[
16                            ImageCarouselItem(
17                                alt_text="Landscape image",
18                                src="iVBORw0KGgoAAAANSUhEUgAAAB4AAAAKCAIAAAAsFXl4AAAANElEQVR4nGL5ctWagWjwuH0b8YqZiFdKKhg1Gg2wzOawIV61t1AF8YqHZoAMTaMBAQAA",
19                            ),
20                            ImageCarouselItem(
21                                alt_text="Square image",
22                                src="iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAALElEQVR4nGIRPRrBgATeWLsjc5kY8AKaSrPIL3FA5i9evZNudhOQBgQAAP",
23                            ),
24                            ImageCarouselItem(
25                                alt_text="Portrait image",
26                                src="iVBORw0KGgoAAAANSUhEUgAAAAoAAAAUCAIAAAA7jDsBAAAALUlEQVR4nGIJWfabAQls8DVA5jIx4AUjVZqRP2AJMn",
27                            ),
28                        ],
29                    ),
30                    Footer(
31                        label="Continue",
32                        on_click_action=CompleteAction(),
33                    ),
34                ],
35            ),
36        ),
37    ],
38)
JSON Code#
 1{
 2  "image_carousel": {
 3    "version": "7.1",
 4    "screens": [
 5      {
 6        "id": "DEMO_SCREEN",
 7        "terminal": true,
 8        "title": "Demo screen",
 9        "layout": {
10          "type": "SingleColumnLayout",
11          "children": [
12            {
13              "type": "ImageCarousel",
14              "scale-type": "cover",
15              "images": [
16                {
17                  "alt-text": "Landscape image",
18                  "src": "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAKCAIAAAAsFXl4AAAANElEQVR4nGL5ctWagWjwuH0b8YqZiFdKKhg1Gg2wzOawIV61t1AF8YqHZoAMTaMBAQAA"
19                },
20                {
21                  "alt-text": "Square image",
22                  "src": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAALElEQVR4nGIRPRrBgATeWLsjc5kY8AKaSrPIL3FA5i9evZNudhOQBgQAAP"
23                },
24                {
25                  "alt-text": "Portrait image",
26                  "src": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAUCAIAAAA7jDsBAAAALUlEQVR4nGIJWfabAQls8DVA5jIx4AUjVZqRP2AJMn"
27                }
28              ]
29            },
30            {
31              "type": "Footer",
32              "label": "Continue",
33              "on-click-action": {
34                "name": "complete",
35                "payload": {}
36              }
37            }
38          ]
39        }
40      }
41    ]
42  }
43}

v6.3 Examples#

Python Code#
 1from pywa.types.flows import *  # noqa
 2
 3chips_selector = FlowJSON(
 4    version="6.3",
 5    screens=[
 6        Screen(
 7            id="DEMO_SCREEN",
 8            terminal=True,
 9            title="Demo screen",
10            layout=Layout(
11                type=LayoutType.SINGLE_COLUMN,
12                children=[
13                    ChipsSelector(
14                        name="chips",
15                        label="Personalize your experience",
16                        description="Choose your interests to get personalized design ideas and solution",
17                        max_selected_items=2,
18                        data_source=[
19                            DataSource(id="room_layout", title="🏡 Room layouts"),
20                            DataSource(id="lighting", title="💡 Lighting"),
21                            DataSource(id="renovation", title="🛠️ Renovation"),
22                            DataSource(id="furnitures", title="📐 Room layouts"),
23                        ],
24                    ),
25                    Footer(
26                        label="Continue",
27                        on_click_action=CompleteAction(),
28                    ),
29                ],
30            ),
31        ),
32    ],
33)
JSON Code#
 1{
 2  "chips_selector": {
 3    "version": "6.3",
 4    "screens": [
 5      {
 6        "id": "DEMO_SCREEN",
 7        "terminal": true,
 8        "title": "Demo screen",
 9        "layout": {
10          "type": "SingleColumnLayout",
11          "children": [
12            {
13              "type": "ChipsSelector",
14              "name": "chips",
15              "label": "Personalize your experience",
16              "description": "Choose your interests to get personalized design ideas and solution",
17              "max-selected-items": 2,
18              "data-source": [
19                {
20                  "id": "room_layout",
21                  "title": "🏡 Room layouts"
22                },
23                {
24                  "id": "lighting",
25                  "title": "💡 Lighting"
26                },
27                {
28                  "id": "renovation",
29                  "title": "🛠️ Renovation"
30                },
31                {
32                  "id": "furnitures",
33                  "title": "📐 Room layouts"
34                }
35              ]
36            },
37            {
38              "type": "Footer",
39              "label": "Continue",
40              "on-click-action": {
41                "name": "complete",
42                "payload": {}
43              }
44            }
45          ]
46        }
47      }
48    ]
49  }
50}

v6.2 Examples#

Python Code#
  1import re
  2
  3from pywa.types.flows import *  # noqa
  4
  5regex = FlowJSON(
  6    version="6.2",
  7    screens=[
  8        Screen(
  9            id="DEMO_SCREEN",
 10            title="Demo Screen",
 11            terminal=True,
 12            layout=Layout(
 13                type=LayoutType.SINGLE_COLUMN,
 14                children=[
 15                    TextInput(
 16                        required=True,
 17                        label="Regex Input",
 18                        input_type=InputType.TEXT,
 19                        pattern=re.compile(
 20                            "^(19|20)\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$"
 21                        ),
 22                        helper_text="E.g. 1993-08-04",
 23                        name="regex input",
 24                    ),
 25                    TextInput(
 26                        required=True,
 27                        label="Regex Passcode",
 28                        pattern="007",
 29                        input_type=InputType.PASSCODE,
 30                        name="passcode_oo7",
 31                        helper_text="Contains: 007",
 32                    ),
 33                    Footer(
 34                        label="Continue",
 35                        on_click_action=CompleteAction(),
 36                    ),
 37                ],
 38            ),
 39        )
 40    ],
 41)
 42
 43navigation_list = FlowJSON(
 44    version="6.2",
 45    routing_model={
 46        "FIRST_SCREEN": ["SECOND_SCREEN", "THIRD_SCREEN", "FIFTH_SCREEN"],
 47        "SECOND_SCREEN": ["CONTACT"],
 48        "THIRD_SCREEN": ["CONTACT"],
 49        "FIFTH_SCREEN": ["CONTACT"],
 50        "CONTACT": [],
 51    },
 52    screens=[
 53        Screen(
 54            id="FIRST_SCREEN",
 55            title="Our offers",
 56            data={},
 57            layout=Layout(
 58                type=LayoutType.SINGLE_COLUMN,
 59                children=[
 60                    NavigationList(
 61                        name="insurances",
 62                        list_items=[
 63                            NavigationItem(
 64                                id="home",
 65                                main_content=NavigationItemMainContent(
 66                                    title="Home Insurance",
 67                                    metadata="Safeguard your home against natural disasters, theft, and accidents",
 68                                ),
 69                                end=NavigationItemEnd(
 70                                    title="$100", description="/ month"
 71                                ),
 72                                on_click_action=NavigateAction(
 73                                    next=Next(name="SECOND_SCREEN"),
 74                                ),
 75                            ),
 76                            NavigationItem(
 77                                id="health",
 78                                main_content=NavigationItemMainContent(
 79                                    title="Health Insurance",
 80                                    metadata="Get essential coverage for doctor visits, prescriptions, and hospital stays",
 81                                ),
 82                                end=NavigationItemEnd(
 83                                    title="$80", description="/ month"
 84                                ),
 85                                on_click_action=NavigateAction(
 86                                    next=Next(name="SECOND_SCREEN"),
 87                                ),
 88                            ),
 89                            NavigationItem(
 90                                id="intergalactic",
 91                                main_content=NavigationItemMainContent(
 92                                    title="Intergalactic Insurance",
 93                                    metadata="Enjoy coverage for asteroid collisions, alien encounters, and other risks",
 94                                ),
 95                                end=NavigationItemEnd(
 96                                    title="$1.000", description="/ month"
 97                                ),
 98                                on_click_action=NavigateAction(
 99                                    next=Next(name="FOURTH_SCREEN"),
100                                ),
101                            ),
102                            NavigationItem(
103                                id="timetravel",
104                                main_content=NavigationItemMainContent(
105                                    title="Time Travel Insurance",
106                                    metadata="Ready for paradox-related damages or unforeseen consequences of altering history",
107                                ),
108                                end=NavigationItemEnd(
109                                    title="$980", description="/ month"
110                                ),
111                                on_click_action=NavigateAction(
112                                    next=Next(name="FIFTH_SCREEN"),
113                                ),
114                            ),
115                            NavigationItem(
116                                id="dream",
117                                main_content=NavigationItemMainContent(
118                                    title="Dream Loss Insurance",
119                                    metadata="Protection from recurring nightmares or lost opportunities due to poor sleep",
120                                ),
121                                end=NavigationItemEnd(
122                                    title="$540", description="/ month"
123                                ),
124                                on_click_action=NavigateAction(
125                                    next=Next(name="FIFTH_SCREEN"),
126                                    payload={"first_name": True},
127                                ),
128                            ),
129                        ],
130                    )
131                ],
132            ),
133        ),
134        Screen(
135            id="SECOND_SCREEN",
136            title="Home Insurance",
137            data={},
138            layout=Layout(
139                type=LayoutType.SINGLE_COLUMN,
140                children=[
141                    TextSubheading(text="Tell us about your property"),
142                    Form(
143                        name="property_details_form",
144                        children=[
145                            Dropdown(
146                                name="property_type",
147                                required=True,
148                                label="Property Type",
149                                data_source=[
150                                    DataSource(id="House", title="House"),
151                                    DataSource(id="Apartment", title="Apartment"),
152                                    DataSource(id="Condo", title="Condo"),
153                                ],
154                            ),
155                            TextInput(
156                                name="surface",
157                                label="Total surface (sqm)",
158                                input_type=InputType.NUMBER,
159                                required=True,
160                            ),
161                            TextInput(
162                                name="rooms",
163                                input_type=InputType.NUMBER,
164                                label="Number or rooms",
165                                required=True,
166                            ),
167                            TextInput(name="floors", label="Number of floors"),
168                            Footer(
169                                label="Continue",
170                                on_click_action=NavigateAction(
171                                    next=Next(name="CONTACT"),
172                                ),
173                            ),
174                        ],
175                    ),
176                ],
177            ),
178        ),
179        Screen(
180            id="THIRD_SCREEN",
181            title="Health Insurance",
182            data={},
183            layout=Layout(
184                type=LayoutType.SINGLE_COLUMN,
185                children=[
186                    TextSubheading(
187                        text="Tell us about the type of insurance you are looking for"
188                    ),
189                    Form(
190                        name="health_insurance_form",
191                        children=[
192                            Dropdown(
193                                label="Insurance type",
194                                name="insurance_type",
195                                required=True,
196                                data_source=[
197                                    DataSource(id="individual", title="Individual"),
198                                    DataSource(id="family", title="Family"),
199                                ],
200                            ),
201                            TextInput(
202                                label="Count",
203                                required=True,
204                                helper_text="How may people will be covered by this insurance",
205                                name="number_of_people",
206                            ),
207                            Dropdown(
208                                label="Age range",
209                                name="age_range",
210                                required=True,
211                                data_source=[
212                                    DataSource(id="18-24", title="18-24"),
213                                    DataSource(id="25-34", title="25-34"),
214                                ],
215                            ),
216                            Footer(
217                                label="Next",
218                                on_click_action=NavigateAction(
219                                    next=Next(name="CONTACT"),
220                                ),
221                            ),
222                        ],
223                    ),
224                ],
225            ),
226        ),
227        Screen(
228            id="FIFTH_SCREEN",
229            title="Time Travel Insurance",
230            data=[first_name := ScreenData(key="first_name", example="Bob")],
231            layout=Layout(
232                type=LayoutType.SINGLE_COLUMN,
233                children=[
234                    TextBody(
235                        text=f"`{first_name.ref} ', we are excited you are joining our community of time travellers!'`"
236                    ),
237                    TextBody(
238                        text="We require a few more details to make sure you have the best cover possible for your needs."
239                    ),
240                    Form(
241                        name="health_insurance_form",
242                        children=[
243                            Dropdown(
244                                label="Insurance type",
245                                name="insurance_type",
246                                required=True,
247                                data_source=[
248                                    DataSource(id="individual", title="Individual"),
249                                    DataSource(id="family", title="Family"),
250                                ],
251                            ),
252                            TextInput(
253                                label="Count",
254                                required=True,
255                                helper_text="How may people will be covered by this insurance",
256                                name="number_of_people",
257                            ),
258                            Dropdown(
259                                label="Age range",
260                                name="age_range",
261                                required=True,
262                                data_source=[
263                                    DataSource(id="18-24", title="18-24"),
264                                    DataSource(id="25-34", title="25-34"),
265                                ],
266                            ),
267                            Footer(
268                                label="Next",
269                                on_click_action=NavigateAction(
270                                    next=Next(name="CONTACT"),
271                                ),
272                            ),
273                        ],
274                    ),
275                ],
276            ),
277        ),
278        Screen(
279            id="CONTACT",
280            title="Contact details",
281            terminal=True,
282            data={},
283            layout=Layout(
284                type=LayoutType.SINGLE_COLUMN,
285                children=[
286                    TextHeading(text="How can we get in contact with you?"),
287                    Form(
288                        name="form",
289                        children=[
290                            name := TextInput(
291                                name="name",
292                                label="Full name",
293                                required=True,
294                            ),
295                            phone := TextInput(
296                                name="phone",
297                                required=True,
298                                label="Phone number",
299                            ),
300                            Footer(
301                                label="Complete",
302                                on_click_action=CompleteAction(
303                                    payload={
304                                        "phone": phone.ref,
305                                        "name": name.ref,
306                                    },
307                                ),
308                            ),
309                        ],
310                    ),
311                ],
312            ),
313        ),
314    ],
315)
316
317
318navigation_list_dynamic = FlowJSON(
319    version="6.2",
320    data_api_version="3.0",
321    routing_model={
322        "FIRST_SCREEN": ["SECOND_SCREEN", "THIRD_SCREEN"],
323        "SECOND_SCREEN": ["CONTACT"],
324        "THIRD_SCREEN": ["CONTACT"],
325        "CONTACT": [],
326    },
327    screens=[
328        Screen(
329            id="FIRST_SCREEN",
330            title="Our offers",
331            data=[
332                insurances := ScreenData(
333                    key="insurances",
334                    example=[
335                        NavigationItem(
336                            id="home",
337                            main_content=NavigationItemMainContent(
338                                title="Home Insurance",
339                                metadata="Safeguard your home against natural disasters, theft, and accidents.",
340                            ),
341                            on_click_action=DataExchangeAction(
342                                payload={"selection": "home"},
343                            ),
344                        ),
345                        NavigationItem(
346                            id="health",
347                            main_content=NavigationItemMainContent(
348                                title="Health Insurance",
349                                metadata="Get essential coverage for doctor visits, prescriptions, and hospital stays.",
350                            ),
351                            on_click_action=DataExchangeAction(
352                                payload={"selection": "health"},
353                            ),
354                        ),
355                    ],
356                ),
357            ],
358            layout=Layout(
359                type=LayoutType.SINGLE_COLUMN,
360                children=[
361                    NavigationList(
362                        name="insurances",
363                        list_items=insurances.ref,
364                    )
365                ],
366            ),
367        ),
368        Screen(
369            id="SECOND_SCREEN",
370            title="Home Insurance",
371            data={},
372            layout=Layout(
373                type=LayoutType.SINGLE_COLUMN,
374                children=[
375                    TextSubheading(text="Tell us about your property"),
376                    Form(
377                        name="property_details_form",
378                        children=[
379                            Dropdown(
380                                name="property_type",
381                                required=True,
382                                label="Property Type",
383                                data_source=[
384                                    DataSource(id="House", title="House"),
385                                    DataSource(id="Apartment", title="Apartment"),
386                                    DataSource(id="Condo", title="Condo"),
387                                ],
388                            ),
389                            TextInput(
390                                name="surface",
391                                label="Total surface (sqm)",
392                                input_type=InputType.NUMBER,
393                                required=True,
394                            ),
395                            TextInput(
396                                name="rooms",
397                                input_type=InputType.NUMBER,
398                                label="Number or rooms",
399                                required=True,
400                            ),
401                            TextInput(
402                                name="floors",
403                                label="Number of floors",
404                            ),
405                            Footer(
406                                label="Continue",
407                                on_click_action=NavigateAction(
408                                    next=Next(name="CONTACT"),
409                                ),
410                            ),
411                        ],
412                    ),
413                ],
414            ),
415        ),
416        Screen(
417            id="THIRD_SCREEN",
418            title="Health Insurance",
419            data={},
420            layout=Layout(
421                type=LayoutType.SINGLE_COLUMN,
422                children=[
423                    TextSubheading(
424                        text="Tell us about the type of insurance you are looking for"
425                    ),
426                    Form(
427                        name="health_insurance_form",
428                        children=[
429                            Dropdown(
430                                label="Insurance type",
431                                name="insurance_type",
432                                required=True,
433                                data_source=[
434                                    DataSource(id="individual", title="Individual"),
435                                    DataSource(id="family", title="Family"),
436                                ],
437                            ),
438                            TextInput(
439                                label="Count",
440                                required=True,
441                                helper_text="How may people will be covered by this insurance",
442                                name="number_of_people",
443                            ),
444                            Dropdown(
445                                label="Age range",
446                                name="age_range",
447                                required=True,
448                                data_source=[
449                                    DataSource(id="18-24", title="18-24"),
450                                    DataSource(id="25-34", title="25-34"),
451                                ],
452                            ),
453                            Footer(
454                                label="Next",
455                                on_click_action=NavigateAction(
456                                    next=Next(name="CONTACT"),
457                                ),
458                            ),
459                        ],
460                    ),
461                ],
462            ),
463        ),
464        Screen(
465            id="CONTACT",
466            title="Contact details",
467            terminal=True,
468            data={},
469            layout=Layout(
470                type=LayoutType.SINGLE_COLUMN,
471                children=[
472                    TextHeading(text="How can we get in contact with you?"),
473                    Form(
474                        name="form",
475                        children=[
476                            name := TextInput(
477                                name="name",
478                                label="Full name",
479                                required=True,
480                            ),
481                            phone := TextInput(
482                                name="phone",
483                                required=True,
484                                label="Phone number",
485                            ),
486                            Footer(
487                                label="Complete",
488                                on_click_action=CompleteAction(
489                                    payload={
490                                        "phone": phone.ref,
491                                        "name": name.ref,
492                                    }
493                                ),
494                            ),
495                        ],
496                    ),
497                ],
498            ),
499        ),
500    ],
501)
JSON Code#
  1{
  2  "regex": {
  3    "version": "6.2",
  4    "screens": [
  5      {
  6        "id": "DEMO_SCREEN",
  7        "title": "Demo Screen",
  8        "terminal": true,
  9        "layout": {
 10          "type": "SingleColumnLayout",
 11          "children": [
 12            {
 13              "type": "TextInput",
 14              "required": true,
 15              "label": "Regex Input",
 16              "input-type": "text",
 17              "pattern": "^(19|20)\\d\\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$",
 18              "helper-text": "E.g. 1993-08-04",
 19              "name": "regex input"
 20            },
 21            {
 22              "type": "TextInput",
 23              "required": true,
 24              "label": "Regex Passcode",
 25              "pattern": "007",
 26              "input-type": "passcode",
 27              "name": "passcode_oo7",
 28              "helper-text": "Contains: 007"
 29            },
 30            {
 31              "type": "Footer",
 32              "label": "Continue",
 33              "on-click-action": {
 34                "name": "complete",
 35                "payload": {}
 36              }
 37            }
 38          ]
 39        }
 40      }
 41    ]
 42  },
 43  "navigation_list": {
 44    "version": "6.2",
 45    "routing_model": {
 46      "FIRST_SCREEN": [
 47        "SECOND_SCREEN",
 48        "THIRD_SCREEN",
 49        "FIFTH_SCREEN"
 50      ],
 51      "SECOND_SCREEN": [
 52        "CONTACT"
 53      ],
 54      "THIRD_SCREEN": [
 55        "CONTACT"
 56      ],
 57      "FIFTH_SCREEN": [
 58        "CONTACT"
 59      ],
 60      "CONTACT": []
 61    },
 62    "screens": [
 63      {
 64        "id": "FIRST_SCREEN",
 65        "title": "Our offers",
 66        "data": {},
 67        "layout": {
 68          "type": "SingleColumnLayout",
 69          "children": [
 70            {
 71              "type": "NavigationList",
 72              "name": "insurances",
 73              "list-items": [
 74                {
 75                  "id": "home",
 76                  "main-content": {
 77                    "title": "Home Insurance",
 78                    "metadata": "Safeguard your home against natural disasters, theft, and accidents"
 79                  },
 80                  "end": {
 81                    "title": "$100",
 82                    "description": "/ month"
 83                  },
 84                  "on-click-action": {
 85                    "name": "navigate",
 86                    "next": {
 87                      "name": "SECOND_SCREEN",
 88                      "type": "screen"
 89                    },
 90                    "payload": {}
 91                  }
 92                },
 93                {
 94                  "id": "health",
 95                  "main-content": {
 96                    "title": "Health Insurance",
 97                    "metadata": "Get essential coverage for doctor visits, prescriptions, and hospital stays"
 98                  },
 99                  "end": {
100                    "title": "$80",
101                    "description": "/ month"
102                  },
103                  "on-click-action": {
104                    "name": "navigate",
105                    "next": {
106                      "name": "SECOND_SCREEN",
107                      "type": "screen"
108                    },
109                    "payload": {}
110                  }
111                },
112                {
113                  "id": "intergalactic",
114                  "main-content": {
115                    "title": "Intergalactic Insurance",
116                    "metadata": "Enjoy coverage for asteroid collisions, alien encounters, and other risks"
117                  },
118                  "end": {
119                    "title": "$1.000",
120                    "description": "/ month"
121                  },
122                  "on-click-action": {
123                    "name": "navigate",
124                    "next": {
125                      "name": "FOURTH_SCREEN",
126                      "type": "screen"
127                    },
128                    "payload": {}
129                  }
130                },
131                {
132                  "id": "timetravel",
133                  "main-content": {
134                    "title": "Time Travel Insurance",
135                    "metadata": "Ready for paradox-related damages or unforeseen consequences of altering history"
136                  },
137                  "end": {
138                    "title": "$980",
139                    "description": "/ month"
140                  },
141                  "on-click-action": {
142                    "name": "navigate",
143                    "next": {
144                      "name": "FIFTH_SCREEN",
145                      "type": "screen"
146                    },
147                    "payload": {}
148                  }
149                },
150                {
151                  "id": "dream",
152                  "main-content": {
153                    "title": "Dream Loss Insurance",
154                    "metadata": "Protection from recurring nightmares or lost opportunities due to poor sleep"
155                  },
156                  "end": {
157                    "title": "$540",
158                    "description": "/ month"
159                  },
160                  "on-click-action": {
161                    "name": "navigate",
162                    "next": {
163                      "name": "FIFTH_SCREEN",
164                      "type": "screen"
165                    },
166                    "payload": {
167                      "first_name": true
168                    }
169                  }
170                }
171              ]
172            }
173          ]
174        }
175      },
176      {
177        "id": "SECOND_SCREEN",
178        "title": "Home Insurance",
179        "data": {},
180        "layout": {
181          "type": "SingleColumnLayout",
182          "children": [
183            {
184              "type": "TextSubheading",
185              "text": "Tell us about your property"
186            },
187            {
188              "type": "Form",
189              "name": "property_details_form",
190              "children": [
191                {
192                  "type": "Dropdown",
193                  "name": "property_type",
194                  "required": true,
195                  "label": "Property Type",
196                  "data-source": [
197                    {
198                      "id": "House",
199                      "title": "House"
200                    },
201                    {
202                      "id": "Apartment",
203                      "title": "Apartment"
204                    },
205                    {
206                      "id": "Condo",
207                      "title": "Condo"
208                    }
209                  ]
210                },
211                {
212                  "type": "TextInput",
213                  "name": "surface",
214                  "label": "Total surface (sqm)",
215                  "input-type": "number",
216                  "required": true
217                },
218                {
219                  "type": "TextInput",
220                  "name": "rooms",
221                  "input-type": "number",
222                  "label": "Number or rooms",
223                  "required": true
224                },
225                {
226                  "type": "TextInput",
227                  "name": "floors",
228                  "label": "Number of floors"
229                },
230                {
231                  "type": "Footer",
232                  "label": "Continue",
233                  "on-click-action": {
234                    "name": "navigate",
235                    "next": {
236                      "name": "CONTACT",
237                      "type": "screen"
238                    },
239                    "payload": {}
240                  }
241                }
242              ]
243            }
244          ]
245        }
246      },
247      {
248        "id": "THIRD_SCREEN",
249        "title": "Health Insurance",
250        "data": {},
251        "layout": {
252          "type": "SingleColumnLayout",
253          "children": [
254            {
255              "type": "TextSubheading",
256              "text": "Tell us about the type of insurance you are looking for"
257            },
258            {
259              "type": "Form",
260              "name": "health_insurance_form",
261              "children": [
262                {
263                  "type": "Dropdown",
264                  "label": "Insurance type",
265                  "name": "insurance_type",
266                  "required": true,
267                  "data-source": [
268                    {
269                      "id": "individual",
270                      "title": "Individual"
271                    },
272                    {
273                      "id": "family",
274                      "title": "Family"
275                    }
276                  ]
277                },
278                {
279                  "type": "TextInput",
280                  "label": "Count",
281                  "required": true,
282                  "helper-text": "How may people will be covered by this insurance",
283                  "name": "number_of_people"
284                },
285                {
286                  "type": "Dropdown",
287                  "label": "Age range",
288                  "name": "age_range",
289                  "required": true,
290                  "data-source": [
291                    {
292                      "id": "18-24",
293                      "title": "18-24"
294                    },
295                    {
296                      "id": "25-34",
297                      "title": "25-34"
298                    }
299                  ]
300                },
301                {
302                  "type": "Footer",
303                  "label": "Next",
304                  "on-click-action": {
305                    "name": "navigate",
306                    "next": {
307                      "type": "screen",
308                      "name": "CONTACT"
309                    },
310                    "payload": {}
311                  }
312                }
313              ]
314            }
315          ]
316        }
317      },
318      {
319        "id": "FIFTH_SCREEN",
320        "title": "Time Travel Insurance",
321        "data": {
322          "first_name": {
323            "type": "string",
324            "__example__": "Bob"
325          }
326        },
327        "layout": {
328          "type": "SingleColumnLayout",
329          "children": [
330            {
331              "type": "TextBody",
332              "text": "`${data.first_name} ', we are excited you are joining our community of time travellers!'`"
333            },
334            {
335              "type": "TextBody",
336              "text": "We require a few more details to make sure you have the best cover possible for your needs."
337            },
338            {
339              "type": "Form",
340              "name": "health_insurance_form",
341              "children": [
342                {
343                  "type": "Dropdown",
344                  "label": "Insurance type",
345                  "name": "insurance_type",
346                  "required": true,
347                  "data-source": [
348                    {
349                      "id": "individual",
350                      "title": "Individual"
351                    },
352                    {
353                      "id": "family",
354                      "title": "Family"
355                    }
356                  ]
357                },
358                {
359                  "type": "TextInput",
360                  "label": "Count",
361                  "required": true,
362                  "helper-text": "How may people will be covered by this insurance",
363                  "name": "number_of_people"
364                },
365                {
366                  "type": "Dropdown",
367                  "label": "Age range",
368                  "name": "age_range",
369                  "required": true,
370                  "data-source": [
371                    {
372                      "id": "18-24",
373                      "title": "18-24"
374                    },
375                    {
376                      "id": "25-34",
377                      "title": "25-34"
378                    }
379                  ]
380                },
381                {
382                  "type": "Footer",
383                  "label": "Next",
384                  "on-click-action": {
385                    "name": "navigate",
386                    "next": {
387                      "type": "screen",
388                      "name": "CONTACT"
389                    },
390                    "payload": {}
391                  }
392                }
393              ]
394            }
395          ]
396        }
397      },
398      {
399        "id": "CONTACT",
400        "title": "Contact details",
401        "terminal": true,
402        "data": {},
403        "layout": {
404          "type": "SingleColumnLayout",
405          "children": [
406            {
407              "type": "TextHeading",
408              "text": "How can we get in contact with you?"
409            },
410            {
411              "type": "Form",
412              "name": "form",
413              "children": [
414                {
415                  "type": "TextInput",
416                  "name": "name",
417                  "label": "Full name",
418                  "required": true
419                },
420                {
421                  "type": "TextInput",
422                  "name": "phone",
423                  "required": true,
424                  "label": "Phone number"
425                },
426                {
427                  "type": "Footer",
428                  "label": "Complete",
429                  "on-click-action": {
430                    "name": "complete",
431                    "payload": {
432                      "phone": "${form.phone}",
433                      "name": "${form.name}"
434                    }
435                  }
436                }
437              ]
438            }
439          ]
440        }
441      }
442    ]
443  },
444  "navigation_list_dynamic": {
445    "version": "6.2",
446    "data_api_version": "3.0",
447    "routing_model": {
448      "FIRST_SCREEN": [
449        "SECOND_SCREEN",
450        "THIRD_SCREEN"
451      ],
452      "SECOND_SCREEN": [
453        "CONTACT"
454      ],
455      "THIRD_SCREEN": [
456        "CONTACT"
457      ],
458      "CONTACT": []
459    },
460    "screens": [
461      {
462        "id": "FIRST_SCREEN",
463        "title": "Our offers",
464        "data": {
465          "insurances": {
466            "type": "array",
467            "items": {
468              "type": "object",
469              "properties": {
470                "id": {
471                  "type": "string"
472                },
473                "main-content": {
474                  "type": "object",
475                  "properties": {
476                    "title": {
477                      "type": "string"
478                    },
479                    "metadata": {
480                      "type": "string"
481                    }
482                  }
483                }
484              }
485            },
486            "__example__": [
487              {
488                "id": "home",
489                "main-content": {
490                  "title": "Home Insurance",
491                  "metadata": "Safeguard your home against natural disasters, theft, and accidents."
492                },
493                "on-click-action": {
494                  "name": "data_exchange",
495                  "payload": {
496                    "selection": "home"
497                  }
498                }
499              },
500              {
501                "id": "health",
502                "main-content": {
503                  "title": "Health Insurance",
504                  "metadata": "Get essential coverage for doctor visits, prescriptions, and hospital stays."
505                },
506                "on-click-action": {
507                  "name": "data_exchange",
508                  "payload": {
509                    "selection": "health"
510                  }
511                }
512              }
513            ]
514          }
515        },
516        "layout": {
517          "type": "SingleColumnLayout",
518          "children": [
519            {
520              "type": "NavigationList",
521              "name": "insurances",
522              "list-items": "${data.insurances}"
523            }
524          ]
525        }
526      },
527      {
528        "id": "SECOND_SCREEN",
529        "title": "Home Insurance",
530        "data": {},
531        "layout": {
532          "type": "SingleColumnLayout",
533          "children": [
534            {
535              "type": "TextSubheading",
536              "text": "Tell us about your property"
537            },
538            {
539              "type": "Form",
540              "name": "property_details_form",
541              "children": [
542                {
543                  "type": "Dropdown",
544                  "name": "property_type",
545                  "required": true,
546                  "label": "Property Type",
547                  "data-source": [
548                    {
549                      "id": "House",
550                      "title": "House"
551                    },
552                    {
553                      "id": "Apartment",
554                      "title": "Apartment"
555                    },
556                    {
557                      "id": "Condo",
558                      "title": "Condo"
559                    }
560                  ]
561                },
562                {
563                  "type": "TextInput",
564                  "name": "surface",
565                  "label": "Total surface (sqm)",
566                  "input-type": "number",
567                  "required": true
568                },
569                {
570                  "type": "TextInput",
571                  "name": "rooms",
572                  "input-type": "number",
573                  "label": "Number or rooms",
574                  "required": true
575                },
576                {
577                  "type": "TextInput",
578                  "name": "floors",
579                  "label": "Number of floors"
580                },
581                {
582                  "type": "Footer",
583                  "label": "Continue",
584                  "on-click-action": {
585                    "name": "navigate",
586                    "next": {
587                      "name": "CONTACT",
588                      "type": "screen"
589                    },
590                    "payload": {}
591                  }
592                }
593              ]
594            }
595          ]
596        }
597      },
598      {
599        "id": "THIRD_SCREEN",
600        "title": "Health Insurance",
601        "data": {},
602        "layout": {
603          "type": "SingleColumnLayout",
604          "children": [
605            {
606              "type": "TextSubheading",
607              "text": "Tell us about the type of insurance you are looking for"
608            },
609            {
610              "type": "Form",
611              "name": "health_insurance_form",
612              "children": [
613                {
614                  "type": "Dropdown",
615                  "label": "Insurance type",
616                  "name": "insurance_type",
617                  "required": true,
618                  "data-source": [
619                    {
620                      "id": "individual",
621                      "title": "Individual"
622                    },
623                    {
624                      "id": "family",
625                      "title": "Family"
626                    }
627                  ]
628                },
629                {
630                  "type": "TextInput",
631                  "label": "Count",
632                  "required": true,
633                  "helper-text": "How may people will be covered by this insurance",
634                  "name": "number_of_people"
635                },
636                {
637                  "type": "Dropdown",
638                  "label": "Age range",
639                  "name": "age_range",
640                  "required": true,
641                  "data-source": [
642                    {
643                      "id": "18-24",
644                      "title": "18-24"
645                    },
646                    {
647                      "id": "25-34",
648                      "title": "25-34"
649                    }
650                  ]
651                },
652                {
653                  "type": "Footer",
654                  "label": "Next",
655                  "on-click-action": {
656                    "name": "navigate",
657                    "next": {
658                      "type": "screen",
659                      "name": "CONTACT"
660                    },
661                    "payload": {}
662                  }
663                }
664              ]
665            }
666          ]
667        }
668      },
669      {
670        "id": "CONTACT",
671        "title": "Contact details",
672        "terminal": true,
673        "data": {},
674        "layout": {
675          "type": "SingleColumnLayout",
676          "children": [
677            {
678              "type": "TextHeading",
679              "text": "How can we get in contact with you?"
680            },
681            {
682              "type": "Form",
683              "name": "form",
684              "children": [
685                {
686                  "type": "TextInput",
687                  "name": "name",
688                  "label": "Full name",
689                  "required": true
690                },
691                {
692                  "type": "TextInput",
693                  "name": "phone",
694                  "required": true,
695                  "label": "Phone number"
696                },
697                {
698                  "type": "Footer",
699                  "label": "Complete",
700                  "on-click-action": {
701                    "name": "complete",
702                    "payload": {
703                      "phone": "${form.phone}",
704                      "name": "${form.name}"
705                    }
706                  }
707                }
708              ]
709            }
710          ]
711        }
712      }
713    ]
714  }
715}

v6.1 Examples#

Python Code#
  1from pywa.types.flows import *  # noqa
  2import datetime
  3
  4
  5calendar_picker_single_mode = FlowJSON(
  6    version="6.1",
  7    data_api_version="3.0",
  8    routing_model={},
  9    screens=[
 10        Screen(
 11            id="DEMO_SCREEN",
 12            terminal=True,
 13            title="Demo screen",
 14            layout=Layout(
 15                type=LayoutType.SINGLE_COLUMN,
 16                children=[
 17                    CalendarPicker(
 18                        name="calendar",
 19                        label="Single date",
 20                        helper_text="Select a date",
 21                        required=True,
 22                        mode=CalendarPickerMode.SINGLE,
 23                        min_date=datetime.date(2024, 10, 21),
 24                        max_date=datetime.date(2025, 12, 12),
 25                        unavailable_dates=[
 26                            datetime.date(2024, 11, 28),
 27                            datetime.date(2024, 11, 1),
 28                        ],
 29                        include_days=[
 30                            CalendarDay.MON,
 31                            CalendarDay.TUE,
 32                            CalendarDay.WED,
 33                            CalendarDay.THU,
 34                            CalendarDay.FRI,
 35                        ],
 36                        init_value=datetime.date(2024, 10, 23),
 37                        on_select_action=DataExchangeAction(
 38                            payload={"calendar": ComponentRef("calendar")},
 39                        ),
 40                    ),
 41                    Footer(
 42                        label="Continue",
 43                        on_click_action=DataExchangeAction(),
 44                    ),
 45                ],
 46            ),
 47        )
 48    ],
 49)
 50
 51
 52calendar_picker_range_mode = FlowJSON(
 53    version="6.1",
 54    data_api_version="3.0",
 55    routing_model={},
 56    screens=[
 57        Screen(
 58            id="DEMO_SCREEN",
 59            terminal=True,
 60            title="Demo screen",
 61            layout=Layout(
 62                type=LayoutType.SINGLE_COLUMN,
 63                children=[
 64                    CalendarPicker(
 65                        name="calendar_range",
 66                        title="Range calendar",
 67                        description="Use this to select a date range",
 68                        label=CalendarRangeValues(
 69                            start_date="Start date",
 70                            end_date="End date",
 71                        ),
 72                        helper_text=CalendarRangeValues(
 73                            start_date="Select from date",
 74                            end_date="Select to date",
 75                        ),
 76                        required=CalendarRangeValues(
 77                            start_date=True,
 78                            end_date=False,
 79                        ),
 80                        mode=CalendarPickerMode.RANGE,
 81                        min_date=datetime.date(2024, 10, 21),
 82                        max_date=datetime.date(2025, 12, 12),
 83                        unavailable_dates=[
 84                            datetime.date(2024, 11, 28),
 85                            datetime.date(2024, 11, 1),
 86                        ],
 87                        include_days=[
 88                            CalendarDay.MON,
 89                            CalendarDay.TUE,
 90                            CalendarDay.WED,
 91                            CalendarDay.THU,
 92                            CalendarDay.FRI,
 93                        ],
 94                        min_days=3,
 95                        max_days=10,
 96                        init_value=CalendarRangeValues(
 97                            start_date=datetime.date(2024, 10, 22),
 98                            end_date=datetime.date(2024, 10, 25),
 99                        ),
100                        on_select_action=DataExchangeAction(
101                            payload={"calendar_range": ComponentRef("calendar_range")},
102                        ),
103                    ),
104                    Footer(
105                        label="Continue",
106                        on_click_action=DataExchangeAction(),
107                    ),
108                ],
109            ),
110        )
111    ],
112)
JSON Code#
  1{
  2  "calendar_picker_single_mode": {
  3    "version": "6.1",
  4    "data_api_version": "3.0",
  5    "routing_model": {},
  6    "screens": [
  7      {
  8        "id": "DEMO_SCREEN",
  9        "terminal": true,
 10        "title": "Demo screen",
 11        "layout": {
 12          "type": "SingleColumnLayout",
 13          "children": [
 14            {
 15              "type": "CalendarPicker",
 16              "name": "calendar",
 17              "label": "Single date",
 18              "helper-text": "Select a date",
 19              "required": true,
 20              "mode": "single",
 21              "min-date": "2024-10-21",
 22              "max-date": "2025-12-12",
 23              "unavailable-dates": [
 24                "2024-11-28",
 25                "2024-11-01"
 26              ],
 27              "include-days": [
 28                "Mon",
 29                "Tue",
 30                "Wed",
 31                "Thu",
 32                "Fri"
 33              ],
 34              "init-value": "2024-10-23",
 35              "on-select-action": {
 36                "name": "data_exchange",
 37                "payload": {
 38                  "calendar": "${form.calendar}"
 39                }
 40              }
 41            },
 42            {
 43              "type": "Footer",
 44              "label": "Continue",
 45              "on-click-action": {
 46                "name": "data_exchange",
 47                "payload": {}
 48              }
 49            }
 50          ]
 51        }
 52      }
 53    ]
 54  },
 55  "calendar_picker_range_mode": {
 56    "version": "6.1",
 57    "data_api_version": "3.0",
 58    "routing_model": {},
 59    "screens": [
 60      {
 61        "id": "DEMO_SCREEN",
 62        "terminal": true,
 63        "title": "Demo screen",
 64        "layout": {
 65          "type": "SingleColumnLayout",
 66          "children": [
 67            {
 68              "type": "CalendarPicker",
 69              "name": "calendar_range",
 70              "title": "Range calendar",
 71              "description": "Use this to select a date range",
 72              "label": {
 73                "start-date": "Start date",
 74                "end-date": "End date"
 75              },
 76              "helper-text": {
 77                "start-date": "Select from date",
 78                "end-date": "Select to date"
 79              },
 80              "required": {
 81                "start-date": true,
 82                "end-date": false
 83              },
 84              "mode": "range",
 85              "min-date": "2024-10-21",
 86              "max-date": "2025-12-12",
 87              "unavailable-dates": [
 88                "2024-11-28",
 89                "2024-11-01"
 90              ],
 91              "include-days": [
 92                "Mon",
 93                "Tue",
 94                "Wed",
 95                "Thu",
 96                "Fri"
 97              ],
 98              "min-days": 3,
 99              "max-days": 10,
100              "init-value": {
101                "start-date": "2024-10-22",
102                "end-date": "2024-10-25"
103              },
104              "on-select-action": {
105                "name": "data_exchange",
106                "payload": {
107                  "calendar_range": "${form.calendar_range}"
108                }
109              }
110            },
111            {
112              "type": "Footer",
113              "label": "Continue",
114              "on-click-action": {
115                "name": "data_exchange",
116                "payload": {}
117              }
118            }
119          ]
120        }
121      }
122    ]
123  }
124}

v6.0 Examples#

Python Code#
  1from pywa.types.flows import *  # noqa
  2
  3string_concatenation = FlowJSON(
  4    version="6.0",
  5    screens=[
  6        Screen(
  7            id="DEMO_SCREEN",
  8            terminal=True,
  9            title="Demo screen",
 10            layout=Layout(
 11                type=LayoutType.SINGLE_COLUMN,
 12                children=[
 13                    first_name := TextInput(
 14                        label="First name",
 15                        input_type=InputType.TEXT,
 16                        name="first_name",
 17                        required=True,
 18                    ),
 19                    age := TextInput(
 20                        label="Age",
 21                        input_type=InputType.NUMBER,
 22                        name="age",
 23                        required=True,
 24                    ),
 25                    TextBody(text=FlowStr("Hello {name}", name=first_name.ref)),
 26                    TextBody(
 27                        text=FlowStr(
 28                            "{name} you are {age} years old.",
 29                            name=first_name.ref,
 30                            age=age.ref,
 31                        )
 32                    ),
 33                    Footer(
 34                        label="Footer",
 35                        on_click_action=CompleteAction(),
 36                    ),
 37                ],
 38            ),
 39        )
 40    ],
 41)
 42
 43open_url = FlowJSON(
 44    version="6.0",
 45    screens=[
 46        Screen(
 47            id="DEMO_SCREEN",
 48            terminal=True,
 49            title="Demo screen",
 50            layout=Layout(
 51                type=LayoutType.SINGLE_COLUMN,
 52                children=[
 53                    EmbeddedLink(
 54                        text="This is an external link.",
 55                        on_click_action=OpenURLAction(
 56                            url="https://pywa.readthedocs.io/",
 57                        ),
 58                    ),
 59                    OptIn(
 60                        label="I agree to the terms.",
 61                        name="T&Cs",
 62                        on_click_action=OpenURLAction(
 63                            url="https://pywa.readthedocs.io/",
 64                        ),
 65                    ),
 66                    Footer(
 67                        label="Footer",
 68                        on_click_action=CompleteAction(),
 69                    ),
 70                ],
 71            ),
 72        )
 73    ],
 74)
 75
 76update_data = FlowJSON(
 77    version="6.0",
 78    screens=[
 79        Screen(
 80            id="ADDRESS_SELECTION",
 81            title="Address selection",
 82            terminal=True,
 83            success=True,
 84            data=[
 85                state_visibility := ScreenData(
 86                    key="state_visibility",
 87                    example=False,
 88                ),
 89                pincode_visibility := ScreenData(
 90                    key="pincode_visibility",
 91                    example=False,
 92                ),
 93                states := ScreenData(
 94                    key="states",
 95                    example=[DataSource(id="1", title="USA")],
 96                ),
 97                pincode := ScreenData(
 98                    key="pincode",
 99                    example=[DataSource(id="M6B2A9", title="M6B2A9")],
100                ),
101                countries := ScreenData(
102                    key="countries",
103                    example=[
104                        DataSource(
105                            id="1",
106                            title="USA",
107                            on_select_action=UpdateDataAction(
108                                payload=[
109                                    states.update(
110                                        new_value=[
111                                            DataSource(
112                                                id="new_york",
113                                                title="New York",
114                                                on_unselect_action=UpdateDataAction(
115                                                    payload=[
116                                                        pincode_visibility.update(
117                                                            new_value=False
118                                                        )
119                                                    ],
120                                                ),
121                                                on_select_action=UpdateDataAction(
122                                                    payload=[
123                                                        pincode.update(
124                                                            new_value=[
125                                                                DataSource(
126                                                                    id="10001",
127                                                                    title="10001",
128                                                                ),
129                                                                DataSource(
130                                                                    id="10005",
131                                                                    title="10005",
132                                                                ),
133                                                            ]
134                                                        ),
135                                                        pincode_visibility.update(
136                                                            new_value=True
137                                                        ),
138                                                    ],
139                                                ),
140                                            ),
141                                            DataSource(
142                                                id="california",
143                                                title="California",
144                                                on_unselect_action=UpdateDataAction(
145                                                    payload=[
146                                                        pincode_visibility.update(
147                                                            new_value=False
148                                                        )
149                                                    ],
150                                                ),
151                                                on_select_action=UpdateDataAction(
152                                                    payload=[
153                                                        pincode.update(
154                                                            new_value=[
155                                                                DataSource(
156                                                                    id="90019",
157                                                                    title="90019",
158                                                                ),
159                                                                DataSource(
160                                                                    id="93504",
161                                                                    title="93504",
162                                                                ),
163                                                            ]
164                                                        ),
165                                                        pincode_visibility.update(
166                                                            new_value=True
167                                                        ),
168                                                    ],
169                                                ),
170                                            ),
171                                        ]
172                                    ),
173                                    state_visibility.update(new_value=True),
174                                ],
175                            ),
176                            on_unselect_action=UpdateDataAction(
177                                payload=[
178                                    state_visibility.update(new_value=False),
179                                    pincode_visibility.update(new_value=False),
180                                ],
181                            ),
182                        ),
183                        DataSource(
184                            id="2",
185                            title="Canada",
186                            on_select_action=UpdateDataAction(
187                                payload=[
188                                    states.update(
189                                        new_value=[
190                                            DataSource(
191                                                id="ontario",
192                                                title="Ontario",
193                                                on_unselect_action=UpdateDataAction(
194                                                    payload=[
195                                                        pincode_visibility.update(
196                                                            new_value=False
197                                                        )
198                                                    ],
199                                                ),
200                                                on_select_action=UpdateDataAction(
201                                                    payload=[
202                                                        pincode.update(
203                                                            new_value=[
204                                                                DataSource(
205                                                                    id="L4K",
206                                                                    title="L4K",
207                                                                ),
208                                                                DataSource(
209                                                                    id="M3C",
210                                                                    title="M3C",
211                                                                ),
212                                                            ]
213                                                        ),
214                                                        pincode_visibility.update(
215                                                            new_value=True
216                                                        ),
217                                                    ],
218                                                ),
219                                            ),
220                                            DataSource(
221                                                id="quebec",
222                                                title="Quebec",
223                                                on_unselect_action=UpdateDataAction(
224                                                    payload=[
225                                                        pincode_visibility.update(
226                                                            new_value=False
227                                                        )
228                                                    ],
229                                                ),
230                                                on_select_action=UpdateDataAction(
231                                                    payload=[
232                                                        pincode.update(
233                                                            new_value=[
234                                                                DataSource(
235                                                                    id="M6B2A9",
236                                                                    title="M6B2A9",
237                                                                ),
238                                                                DataSource(
239                                                                    id="M5V",
240                                                                    title="M5V",
241                                                                ),
242                                                            ]
243                                                        ),
244                                                        pincode_visibility.update(
245                                                            new_value=True
246                                                        ),
247                                                    ],
248                                                ),
249                                            ),
250                                        ]
251                                    ),
252                                    state_visibility.update(new_value=True),
253                                ],
254                            ),
255                            on_unselect_action=UpdateDataAction(
256                                payload=[
257                                    state_visibility.update(new_value=False),
258                                    pincode_visibility.update(new_value=False),
259                                ],
260                            ),
261                        ),
262                    ],
263                ),
264            ],
265            layout=Layout(
266                type=LayoutType.SINGLE_COLUMN,
267                children=[
268                    RadioButtonsGroup(
269                        name="select_country",
270                        label="Select country:",
271                        data_source=countries.ref,
272                    ),
273                    RadioButtonsGroup(
274                        name="select_states",
275                        label="Select state:",
276                        visible=state_visibility.ref,
277                        data_source=states.ref,
278                    ),
279                    RadioButtonsGroup(
280                        name="pincode",
281                        label="Select pincode:",
282                        visible=pincode_visibility.ref,
283                        data_source=pincode.ref,
284                    ),
285                    Footer(
286                        label="Complete",
287                        on_click_action=CompleteAction(),
288                    ),
289                ],
290            ),
291        )
292    ],
293)
294
295
296math_operators = FlowJSON(
297    version="6.0",
298    screens=[
299        Screen(
300            id="DEMO_SCREEN",
301            title="Demo Screen",
302            terminal=True,
303            success=True,
304            data=[
305                number_1 := ScreenData(
306                    key="number_1",
307                    example=10,
308                ),
309                number_2 := ScreenData(
310                    key="number_2",
311                    example=20,
312                ),
313            ],
314            layout=Layout(
315                type=LayoutType.SINGLE_COLUMN,
316                children=[
317                    TextBody(
318                        text=[
319                            FlowStr(
320                                "The sum of {num1} and {num2} is {sum}",
321                                num1=number_1.ref,
322                                num2=number_2.ref,
323                                sum=number_1.ref + number_2.ref,
324                            ),
325                            FlowStr(
326                                "The difference of {num1} and {num2} is {diff}",
327                                num1=number_1.ref,
328                                num2=number_2.ref,
329                                diff=number_1.ref - number_2.ref,
330                            ),
331                            FlowStr(
332                                "The product of {num1} and {num2} is {prod}",
333                                num1=number_1.ref,
334                                num2=number_2.ref,
335                                prod=number_1.ref * number_2.ref,
336                            ),
337                            FlowStr(
338                                "The division of {num1} by {num2} is {div}",
339                                num1=number_1.ref,
340                                num2=number_2.ref,
341                                div=number_1.ref / number_2.ref,
342                            ),
343                        ]
344                    ),
345                    Footer(
346                        label="Static footer label",
347                        on_click_action=CompleteAction(),
348                    ),
349                ],
350            ),
351        ),
352    ],
353)
354
355visible_condition = FlowJSON(
356    version="6.0",
357    screens=[
358        Screen(
359            id="DEMO_SCREEN",
360            title="Demo Screen",
361            terminal=True,
362            success=True,
363            layout=Layout(
364                type=LayoutType.SINGLE_COLUMN,
365                children=[
366                    number := TextInput(
367                        label="Enter a number",
368                        input_type=InputType.NUMBER,
369                        name="number",
370                    ),
371                    TextBody(
372                        text="You choose the right number!",
373                        visible=number.ref == 42,
374                    ),
375                    Footer(
376                        label="Static footer label",
377                        on_click_action=CompleteAction(),
378                    ),
379                ],
380            ),
381        )
382    ],
383)
JSON Code#
  1{
  2  "string_concatenation": {
  3    "version": "6.0",
  4    "screens": [
  5      {
  6        "id": "DEMO_SCREEN",
  7        "terminal": true,
  8        "title": "Demo screen",
  9        "layout": {
 10          "type": "SingleColumnLayout",
 11          "children": [
 12            {
 13              "type": "TextInput",
 14              "label": "First name",
 15              "input-type": "text",
 16              "name": "first_name",
 17              "required": true
 18            },
 19            {
 20              "type": "TextInput",
 21              "label": "Age",
 22              "input-type": "number",
 23              "name": "age",
 24              "required": true
 25            },
 26            {
 27              "type": "TextBody",
 28              "text": "` 'Hello ' ${form.first_name}`"
 29            },
 30            {
 31              "type": "TextBody",
 32              "text": "`${form.first_name} ' you are ' ${form.age} ' years old.' `"
 33            },
 34            {
 35              "type": "Footer",
 36              "label": "Footer",
 37              "on-click-action": {
 38                "name": "complete",
 39                "payload": {}
 40              }
 41            }
 42          ]
 43        }
 44      }
 45    ]
 46  },
 47  "open_url": {
 48    "version": "6.0",
 49    "screens": [
 50      {
 51        "id": "DEMO_SCREEN",
 52        "terminal": true,
 53        "title": "Demo screen",
 54        "layout": {
 55          "type": "SingleColumnLayout",
 56          "children": [
 57            {
 58              "type": "EmbeddedLink",
 59              "text": "This is an external link.",
 60              "on-click-action": {
 61                "name": "open_url",
 62                "url": "https://pywa.readthedocs.io/"
 63              }
 64            },
 65            {
 66              "type": "OptIn",
 67              "label": "I agree to the terms.",
 68              "name": "T&Cs",
 69              "on-click-action": {
 70                "name": "open_url",
 71                "url": "https://pywa.readthedocs.io/"
 72              }
 73            },
 74            {
 75              "type": "Footer",
 76              "label": "Footer",
 77              "on-click-action": {
 78                "name": "complete",
 79                "payload": {}
 80              }
 81            }
 82          ]
 83        }
 84      }
 85    ]
 86  },
 87  "update_data": {
 88    "version": "6.0",
 89    "screens": [
 90      {
 91        "id": "ADDRESS_SELECTION",
 92        "layout": {
 93          "type": "SingleColumnLayout",
 94          "children": [
 95            {
 96              "type": "RadioButtonsGroup",
 97              "name": "select_country",
 98              "label": "Select country:",
 99              "data-source": "${data.countries}"
100            },
101            {
102              "type": "RadioButtonsGroup",
103              "name": "select_states",
104              "label": "Select state:",
105              "visible": "${data.state_visibility}",
106              "data-source": "${data.states}"
107            },
108            {
109              "type": "RadioButtonsGroup",
110              "name": "pincode",
111              "label": "Select pincode:",
112              "visible": "${data.pincode_visibility}",
113              "data-source": "${data.pincode}"
114            },
115            {
116              "type": "Footer",
117              "label": "Complete",
118              "on-click-action": {
119                "name": "complete",
120                "payload": {}
121              }
122            }
123          ]
124        },
125        "title": "Address selection",
126        "terminal": true,
127        "success": true,
128        "data": {
129          "countries": {
130            "type": "array",
131            "items": {
132              "type": "object",
133              "properties": {
134                "id": {
135                  "type": "string"
136                },
137                "title": {
138                  "type": "string"
139                }
140              }
141            },
142            "__example__": [
143              {
144                "id": "1",
145                "title": "USA",
146                "on-select-action": {
147                  "name": "update_data",
148                  "payload": {
149                    "states": [
150                      {
151                        "id": "new_york",
152                        "title": "New York",
153                        "on-unselect-action": {
154                          "name": "update_data",
155                          "payload": {
156                            "pincode_visibility": false
157                          }
158                        },
159                        "on-select-action": {
160                          "name": "update_data",
161                          "payload": {
162                            "pincode": [
163                              {
164                                "id": "10001",
165                                "title": "10001"
166                              },
167                              {
168                                "id": "10005",
169                                "title": "10005"
170                              }
171                            ],
172                            "pincode_visibility": true
173                          }
174                        }
175                      },
176                      {
177                        "id": "california",
178                        "title": "California",
179                        "on-unselect-action": {
180                          "name": "update_data",
181                          "payload": {
182                            "pincode_visibility": false
183                          }
184                        },
185                        "on-select-action": {
186                          "name": "update_data",
187                          "payload": {
188                            "pincode": [
189                              {
190                                "id": "90019",
191                                "title": "90019"
192                              },
193                              {
194                                "id": "93504",
195                                "title": "93504"
196                              }
197                            ],
198                            "pincode_visibility": true
199                          }
200                        }
201                      }
202                    ],
203                    "state_visibility": true
204                  }
205                },
206                "on-unselect-action": {
207                  "name": "update_data",
208                  "payload": {
209                    "state_visibility": false,
210                    "pincode_visibility": false
211                  }
212                }
213              },
214              {
215                "id": "2",
216                "title": "Canada",
217                "on-select-action": {
218                  "name": "update_data",
219                  "payload": {
220                    "states": [
221                      {
222                        "id": "ontario",
223                        "title": "Ontario",
224                        "on-unselect-action": {
225                          "name": "update_data",
226                          "payload": {
227                            "pincode_visibility": false
228                          }
229                        },
230                        "on-select-action": {
231                          "name": "update_data",
232                          "payload": {
233                            "pincode": [
234                              {
235                                "id": "L4K",
236                                "title": "L4K"
237                              },
238                              {
239                                "id": "M3C",
240                                "title": "M3C"
241                              }
242                            ],
243                            "pincode_visibility": true
244                          }
245                        }
246                      },
247                      {
248                        "id": "quebec",
249                        "title": "Quebec",
250                        "on-unselect-action": {
251                          "name": "update_data",
252                          "payload": {
253                            "pincode_visibility": false
254                          }
255                        },
256                        "on-select-action": {
257                          "name": "update_data",
258                          "payload": {
259                            "pincode": [
260                              {
261                                "id": "M6B2A9",
262                                "title": "M6B2A9"
263                              },
264                              {
265                                "id": "M5V",
266                                "title": "M5V"
267                              }
268                            ],
269                            "pincode_visibility": true
270                          }
271                        }
272                      }
273                    ],
274                    "state_visibility": true
275                  }
276                },
277                "on-unselect-action": {
278                  "name": "update_data",
279                  "payload": {
280                    "state_visibility": false,
281                    "pincode_visibility": false
282                  }
283                }
284              }
285            ]
286          },
287          "states": {
288            "type": "array",
289            "items": {
290              "type": "object",
291              "properties": {
292                "id": {
293                  "type": "string"
294                },
295                "title": {
296                  "type": "string"
297                }
298              }
299            },
300            "__example__": [
301              {
302                "id": "1",
303                "title": "USA"
304              }
305            ]
306          },
307          "pincode": {
308            "type": "array",
309            "items": {
310              "type": "object",
311              "properties": {
312                "id": {
313                  "type": "string"
314                },
315                "title": {
316                  "type": "string"
317                }
318              }
319            },
320            "__example__": [
321              {
322                "id": "M6B2A9",
323                "title": "M6B2A9"
324              }
325            ]
326          },
327          "state_visibility": {
328            "type": "boolean",
329            "__example__": false
330          },
331          "pincode_visibility": {
332            "type": "boolean",
333            "__example__": false
334          }
335        }
336      }
337    ]
338  },
339  "math_operators": {
340    "version": "6.0",
341    "screens": [
342      {
343        "id": "DEMO_SCREEN",
344        "title": "Demo Screen",
345        "terminal": true,
346        "success": true,
347        "data": {
348          "number_1": {
349            "type": "number",
350            "__example__": 10
351          },
352          "number_2": {
353            "type": "number",
354            "__example__": 20
355          }
356        },
357        "layout": {
358          "type": "SingleColumnLayout",
359          "children": [
360            {
361              "type": "TextBody",
362              "text": [
363                "` 'The sum of ' ${data.number_1} ' and ' ${data.number_2} ' is ' (${data.number_1} + ${data.number_2})`",
364                "` 'The difference of ' ${data.number_1} ' and ' ${data.number_2} ' is ' (${data.number_1} - ${data.number_2})`",
365                "` 'The product of ' ${data.number_1} ' and ' ${data.number_2} ' is ' (${data.number_1} * ${data.number_2})`",
366                "` 'The division of ' ${data.number_1} ' by ' ${data.number_2} ' is ' (${data.number_1} / ${data.number_2})`"
367              ]
368            },
369            {
370              "type": "Footer",
371              "label": "Static footer label",
372              "on-click-action": {
373                "name": "complete",
374                "payload": {}
375              }
376            }
377          ]
378        }
379      }
380    ]
381  },
382  "visible_condition": {
383    "version": "6.0",
384    "screens": [
385      {
386        "id": "DEMO_SCREEN",
387        "title": "Demo Screen",
388        "terminal": true,
389        "success": true,
390        "layout": {
391          "type": "SingleColumnLayout",
392          "children": [
393            {
394              "type": "TextInput",
395              "label": "Enter a number",
396              "input-type": "number",
397              "name": "number"
398            },
399            {
400              "type": "TextBody",
401              "text": "You choose the right number!",
402              "visible": "`(${form.number} == 42)`"
403            },
404            {
405              "type": "Footer",
406              "label": "Static footer label",
407              "on-click-action": {
408                "name": "complete",
409                "payload": {}
410              }
411            }
412          ]
413        }
414      }
415    ]
416  }
417}

v5.1 Examples#

Python Code#
  1from pywa.types.flows import *  # noqa: F403
  2
  3rich_text = FlowJSON(
  4    version="5.1",
  5    screens=[
  6        Screen(
  7            id="FIRST_SCREEN",
  8            title="Welcome",
  9            terminal=True,
 10            layout=Layout(
 11                type=LayoutType.SINGLE_COLUMN,
 12                children=[
 13                    TextCaption(
 14                        markdown=True,
 15                        text=[
 16                            "This is a markdown example inside **TextCaption**. You can combine **different** *formatting* ~~***styles***~~",
 17                            "You can also add [links](https://whatsapp.com) to external web-sites",
 18                        ],
 19                    ),
 20                    TextBody(
 21                        markdown=True,
 22                        text=[
 23                            "This is a markdown example inside **TextCaption**. You can combine **different** *formatting* ~~***styles***~~.",
 24                            "You can also add [links](https://whatsapp.com) to external web-sites",
 25                            "And use **Ordered** and **Unordered** lists:",
 26                            "1. List item",
 27                            "2. List item",
 28                        ],
 29                    ),
 30                    OptIn(
 31                        name="toc",
 32                        required=True,
 33                        label="RichText can be used to render large static or dynamic texts.",
 34                        on_click_action=NavigateAction(
 35                            next=Next(name="TOC"),
 36                        ),
 37                    ),
 38                    Footer(
 39                        label="Proceed",
 40                        on_click_action=CompleteAction(),
 41                    ),
 42                ],
 43            ),
 44        ),
 45        Screen(
 46            id="TOC",
 47            title="Terms of Service",
 48            layout=Layout(
 49                type=LayoutType.SINGLE_COLUMN,
 50                children=[
 51                    RichText(
 52                        text=[
 53                            "This is a mock-up of ToC demonstrating the supported syntax of RichText components",
 54                            "# Terms of Service",
 55                            "## 1. Acceptance of Terms",
 56                            'By using our services, you *agree* to a these lol **Terms of Service** (*"Terms"*). If you do not *agree*, please do not use our services.',
 57                            "**Here is image example:**",
 58                            '"![Whatsapp-logo](data:image/png;base64,meQAyMDIzLTA0LTA4VDE3OjMyOjA1KzAwOjAw8ZGfFgAAAABJRU5ErkJggg==)"',
 59                            "We are not **liable** for:",
 60                            "1. *indirect* including the ones that happens all the time in normal life, I just need to make this text slightly longer",
 61                            "2. *incidental*,",
 62                            "3. *special*,",
 63                            "4. *punitive* damages",
 64                            "including loss of:",
 65                            "+ *profits*,",
 66                            "+ *data*",
 67                            "+ *use*.",
 68                            "## 2. Modifications to Terms",
 69                            'We *reserve* the right to **modify** these *Terms* at any time. Changes will be indicated by the **"Last Updated"** date. Continued use after changes constitutes acceptance.',
 70                            "## 3. Use of Services",
 71                            "**Eligibility:** You must be at least *18 years old*. By using our services, you *confirm* you meet this requirement.",
 72                            "**Account Responsibilities:** You are **responsible** for your account confidentiality and activities.",
 73                            "## 4. User Conduct",
 74                            "You *agree* not to **violate** laws, **infringe** rights, or transmit *objectionable* content.",
 75                            "## 5. Termination",
 76                            "We may **terminate** or *suspend* your access immediately, without notice, for any reason, including **breach** of *Terms*.",
 77                            "## 6. Disclaimer of Warranties",
 78                            'Services are provided ***"AS IS"*** and ***"AS AVAILABLE"***. We disclaim all **warranties**, express or implied, including *merchantability* and *fitness for a particular purpose*.',
 79                            "## 7. Limitation of Liability",
 80                            "We are not **liable** for:",
 81                            "1. *indirect* including the ones that happens all the time in normal life, I just need to make this text slightly longer",
 82                            "2. *incidental*,",
 83                            "3. *special*,",
 84                            "4. *punitive* damages",
 85                            "including loss of:",
 86                            "+ *profits*,",
 87                            "+ *data*",
 88                            "+ *use*.",
 89                            "## 8. Governing Law",
 90                            "| Column  with extended width   | Column  with extended width   | Column  with extended width   |",
 91                            "| --------   | --------   |",
 92                            "| It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.|  Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum |",
 93                            "| It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.|  Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum |",
 94                            "## 9. Contact Information",
 95                            "For questions, contact us at **[your email address]**.",
 96                            "Alternatively please go to our [Fancy web-site](https://www.whatsapp.com) to learn more about our services.",
 97                            "**Last Updated:** ***[Date]***",
 98                        ]
 99                    )
100                ],
101            ),
102        ),
103    ],
104)
JSON Code#
  1{
  2  "rich_text": {
  3    "version": "5.1",
  4    "screens": [
  5      {
  6        "id": "FIRST_SCREEN",
  7        "title": "Welcome",
  8        "terminal": true,
  9        "layout": {
 10          "type": "SingleColumnLayout",
 11          "children": [
 12            {
 13              "type": "TextCaption",
 14              "markdown": true,
 15              "text": [
 16                "This is a markdown example inside **TextCaption**. You can combine **different** *formatting* ~~***styles***~~",
 17                "You can also add [links](https://whatsapp.com) to external web-sites"
 18              ]
 19            },
 20            {
 21              "type": "TextBody",
 22              "markdown": true,
 23              "text": [
 24                "This is a markdown example inside **TextCaption**. You can combine **different** *formatting* ~~***styles***~~.",
 25                "You can also add [links](https://whatsapp.com) to external web-sites",
 26                "And use **Ordered** and **Unordered** lists:",
 27                "1. List item",
 28                "2. List item"
 29              ]
 30            },
 31            {
 32              "type": "OptIn",
 33              "name": "toc",
 34              "required": true,
 35              "label": "RichText can be used to render large static or dynamic texts.",
 36              "on-click-action": {
 37                "name": "navigate",
 38                "next": {
 39                  "type": "screen",
 40                  "name": "TOC"
 41                },
 42                "payload": {}
 43              }
 44            },
 45            {
 46              "type": "Footer",
 47              "label": "Proceed",
 48              "on-click-action": {
 49                "name": "complete",
 50                "payload": {}
 51              }
 52            }
 53          ]
 54        }
 55      },
 56      {
 57        "id": "TOC",
 58        "title": "Terms of Service",
 59        "layout": {
 60          "type": "SingleColumnLayout",
 61          "children": [
 62            {
 63              "type": "RichText",
 64              "text": [
 65                "This is a mock-up of ToC demonstrating the supported syntax of RichText components",
 66                "# Terms of Service",
 67                "## 1. Acceptance of Terms",
 68                "By using our services, you *agree* to a these lol **Terms of Service** (*\"Terms\"*). If you do not *agree*, please do not use our services.",
 69                "**Here is image example:**",
 70                "\"![Whatsapp-logo](data:image/png;base64,meQAyMDIzLTA0LTA4VDE3OjMyOjA1KzAwOjAw8ZGfFgAAAABJRU5ErkJggg==)\"",
 71                "We are not **liable** for:",
 72                "1. *indirect* including the ones that happens all the time in normal life, I just need to make this text slightly longer",
 73                "2. *incidental*,",
 74                "3. *special*,",
 75                "4. *punitive* damages",
 76                "including loss of:",
 77                "+ *profits*,",
 78                "+ *data*",
 79                "+ *use*.",
 80                "## 2. Modifications to Terms",
 81                "We *reserve* the right to **modify** these *Terms* at any time. Changes will be indicated by the **\"Last Updated\"** date. Continued use after changes constitutes acceptance.",
 82                "## 3. Use of Services",
 83                "**Eligibility:** You must be at least *18 years old*. By using our services, you *confirm* you meet this requirement.",
 84                "**Account Responsibilities:** You are **responsible** for your account confidentiality and activities.",
 85                "## 4. User Conduct",
 86                "You *agree* not to **violate** laws, **infringe** rights, or transmit *objectionable* content.",
 87                "## 5. Termination",
 88                "We may **terminate** or *suspend* your access immediately, without notice, for any reason, including **breach** of *Terms*.",
 89                "## 6. Disclaimer of Warranties",
 90                "Services are provided ***\"AS IS\"*** and ***\"AS AVAILABLE\"***. We disclaim all **warranties**, express or implied, including *merchantability* and *fitness for a particular purpose*.",
 91                "## 7. Limitation of Liability",
 92                "We are not **liable** for:",
 93                "1. *indirect* including the ones that happens all the time in normal life, I just need to make this text slightly longer",
 94                "2. *incidental*,",
 95                "3. *special*,",
 96                "4. *punitive* damages",
 97                "including loss of:",
 98                "+ *profits*,",
 99                "+ *data*",
100                "+ *use*.",
101                "## 8. Governing Law",
102                "| Column  with extended width   | Column  with extended width   | Column  with extended width   |",
103                "| --------   | --------   |",
104                "| It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.|  Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum |",
105                "| It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. | Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.|  Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum |",
106                "## 9. Contact Information",
107                "For questions, contact us at **[your email address]**.",
108                "Alternatively please go to our [Fancy web-site](https://www.whatsapp.com) to learn more about our services.",
109                "**Last Updated:** ***[Date]***"
110              ]
111            }
112          ]
113        }
114      }
115    ]
116  }
117}

v5.0 Examples#

Python Code#
 1import datetime
 2
 3from pywa.types.flows import *  # noqa: F403
 4
 5
 6radio_buttons_with_pics = FlowJSON(
 7    version="5.0",
 8    screens=[
 9        Screen(
10            id="TRAVEL_PACKAGES",
11            layout=Layout(
12                type=LayoutType.SINGLE_COLUMN,
13                children=[
14                    RadioButtonsGroup(
15                        name="packages",
16                        required=True,
17                        data_source=[
18                            DataSource(
19                                id="1",
20                                title="Tropical Beach Vacation",
21                                description="Enjoy 7 nights and 8 days at a luxury beach resort in Bali. Including flights and stays",
22                                alt_text="beach vacation",
23                                image="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
24                            ),
25                            DataSource(
26                                id="2",
27                                title="Mountain Adventure",
28                                description="Embark on a 5-day guided trek in the Swiss Alps. Package includes flights and stays",
29                                image="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
30                            ),
31                            DataSource(
32                                id="3",
33                                title="City Break",
34                                description="Explore the sights and sounds of New York City with our 4 nights and 5 days package",
35                                image="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
36                            ),
37                            DataSource(
38                                id="4",
39                                title="Historical Tour",
40                                description="Take a 7-day historical tour of Rome, Italy. Package includes flights and stays",
41                                image="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
42                            ),
43                        ],
44                        label="Explore our exciting packages",
45                    ),
46                    Footer(
47                        label="Continue",
48                        on_click_action=CompleteAction(),
49                    ),
50                ],
51            ),
52            title="Travel Packages",
53            terminal=True,
54        ),
55    ],
56)
57
58date_picker_dates_obj = FlowJSON(
59    version="5.0",
60    data_api_version="3.0",
61    routing_model={},
62    screens=[
63        Screen(
64            id="DEMO_SCREEN",
65            terminal=True,
66            title="Demo screen",
67            layout=Layout(
68                type=LayoutType.SINGLE_COLUMN,
69                children=[
70                    date := DatePicker(
71                        name="date",
72                        label="Date",
73                        min_date=datetime.date(2024, 10, 21),
74                        max_date=datetime.date(2024, 11, 12),
75                        unavailable_dates=[
76                            datetime.date(2024, 10, 28),
77                            datetime.date(2024, 11, 1),
78                        ],
79                        on_select_action=DataExchangeAction(
80                            payload={"date": ComponentRef("date")},
81                        ),
82                    ),
83                    Footer(
84                        label="Continue",
85                        on_click_action=DataExchangeAction(),
86                    ),
87                ],
88            ),
89        )
90    ],
91)
JSON Code#
  1{
  2
  3  "radio_buttons_with_pics": {
  4    "version": "5.0",
  5    "screens": [
  6      {
  7        "id": "TRAVEL_PACKAGES",
  8        "layout": {
  9          "type": "SingleColumnLayout",
 10          "children": [
 11            {
 12              "type": "RadioButtonsGroup",
 13              "name": "packages",
 14              "required": true,
 15              "data-source": [
 16                {
 17                  "id": "1",
 18                  "title": "Tropical Beach Vacation",
 19                  "description": "Enjoy 7 nights and 8 days at a luxury beach resort in Bali. Including flights and stays",
 20                  "alt-text": "beach vacation",
 21                  "image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="
 22                },
 23                {
 24                  "id": "2",
 25                  "title": "Mountain Adventure",
 26                  "description": "Embark on a 5-day guided trek in the Swiss Alps. Package includes flights and stays",
 27                  "image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="
 28                },
 29                {
 30                  "id": "3",
 31                  "title": "City Break",
 32                  "description": "Explore the sights and sounds of New York City with our 4 nights and 5 days package",
 33                  "image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="
 34                },
 35                {
 36                  "id": "4",
 37                  "title": "Historical Tour",
 38                  "description": "Take a 7-day historical tour of Rome, Italy. Package includes flights and stays",
 39                  "image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="
 40                }
 41              ],
 42              "label": "Explore our exciting packages"
 43            },
 44            {
 45              "type": "Footer",
 46              "label": "Continue",
 47              "on-click-action": {
 48                "name": "complete",
 49                "payload": {}
 50              }
 51            }
 52          ]
 53        },
 54        "title": "Travel Packages",
 55        "terminal": true
 56      }
 57    ]
 58  },
 59  "date_picker_dates_obj": {
 60    "version": "5.0",
 61    "data_api_version": "3.0",
 62    "routing_model": {},
 63    "screens": [
 64      {
 65        "id": "DEMO_SCREEN",
 66        "terminal": true,
 67        "title": "Demo screen",
 68        "layout": {
 69          "type": "SingleColumnLayout",
 70          "children": [
 71            {
 72              "type": "DatePicker",
 73              "name": "date",
 74              "label": "Date",
 75              "min-date": "2024-10-21",
 76              "max-date": "2024-11-12",
 77              "unavailable-dates": [
 78                "2024-10-28",
 79                "2024-11-01"
 80              ],
 81              "on-select-action": {
 82                "name": "data_exchange",
 83                "payload": {
 84                  "date": "${form.date}"
 85                }
 86              }
 87            },
 88            {
 89              "type": "Footer",
 90              "label": "Continue",
 91              "on-click-action": {
 92                "name": "data_exchange",
 93                "payload": {}
 94              }
 95            }
 96          ]
 97        }
 98      }
 99    ]
100  }
101}

v4.0 Examples#

Python Code#
  1from pywa.types.flows import *  # noqa: F403
  2
  3switch = FlowJSON(
  4    version="4.0",
  5    screens=[
  6        Screen(
  7            id="SCREEN",
  8            title="Welcome",
  9            terminal=True,
 10            success=True,
 11            data=[ScreenData(key="value", example="cat")],
 12            layout=Layout(
 13                children=[
 14                    animal := TextInput(
 15                        name="animal",
 16                        label="Animal",
 17                        helper_text="Type: cat, dog or anything else",
 18                    ),
 19                    Switch(
 20                        value=animal.ref,
 21                        cases={
 22                            "cat": [TextHeading(text="It is a cat")],
 23                            "dog": [TextHeading(text="It is a dog")],
 24                            "default": [
 25                                TextHeading(text="It is neither a cat nor a dog")
 26                            ],
 27                        },
 28                    ),
 29                    Footer(
 30                        label="Complete",
 31                        on_click_action=CompleteAction(),
 32                    ),
 33                ]
 34            ),
 35        )
 36    ],
 37)
 38
 39if_ = FlowJSON(
 40    version="4.0",
 41    screens=[
 42        Screen(
 43            id="SCREEN",
 44            title="Welcome",
 45            terminal=True,
 46            success=True,
 47            data=[value := ScreenData(key="value", example=True)],
 48            layout=Layout(
 49                children=[
 50                    animal := TextInput(
 51                        name="animal",
 52                        label="Animal",
 53                        helper_text="Type: cat",
 54                    ),
 55                    If(
 56                        condition=value.ref & (animal.ref == "cat"),
 57                        then=[TextHeading(text="It is a cat")],
 58                        else_=[TextHeading(text="It is not a cat")],
 59                    ),
 60                    Footer(
 61                        label="Complete",
 62                        on_click_action=CompleteAction(),
 63                    ),
 64                ]
 65            ),
 66        )
 67    ],
 68)
 69
 70photo_picker = FlowJSON(
 71    version="4.0",
 72    routing_model={"FIRST": []},
 73    data_api_version="3.0",
 74    screens=[
 75        Screen(
 76            id="FIRST",
 77            title="Photo Picker Example",
 78            terminal=True,
 79            data={},
 80            layout=Layout(
 81                type=LayoutType.SINGLE_COLUMN,
 82                children=[
 83                    Form(
 84                        name="flow_path",
 85                        children=[
 86                            photo_picker := PhotoPicker(
 87                                name="photo_picker",
 88                                label="Upload photos",
 89                                description="Please attach images about the received items",
 90                                photo_source="camera_gallery",
 91                                min_uploaded_photos=1,
 92                                max_uploaded_photos=10,
 93                                max_file_size_kb=10240,
 94                            ),
 95                            Footer(
 96                                label="Submit",
 97                                on_click_action=DataExchangeAction(
 98                                    payload={"images": photo_picker.ref},
 99                                ),
100                            ),
101                        ],
102                    )
103                ],
104            ),
105        )
106    ],
107)
108
109doc_picker = FlowJSON(
110    version="4.0",
111    routing_model={"SECOND": []},
112    data_api_version="3.0",
113    screens=[
114        Screen(
115            id="SECOND",
116            terminal=True,
117            title="Document Picker Example",
118            data={},
119            layout=Layout(
120                type=LayoutType.SINGLE_COLUMN,
121                children=[
122                    Form(
123                        name="flow_path",
124                        children=[
125                            document_picker := DocumentPicker(
126                                name="document_picker",
127                                label="Contract",
128                                description="Attach the signed copy of the contract",
129                                min_uploaded_documents=1,
130                                max_uploaded_documents=1,
131                                max_file_size_kb=1024,
132                                allowed_mime_types=[
133                                    "image/jpeg",
134                                    "application/pdf",
135                                ],
136                            ),
137                            Footer(
138                                label="Submit",
139                                on_click_action=CompleteAction(
140                                    payload={"documents": document_picker.ref},
141                                ),
142                            ),
143                        ],
144                    )
145                ],
146            ),
147        )
148    ],
149)
150
151
152date_picker_dates_str = FlowJSON(
153    version="4.0",
154    data_api_version="3.0",
155    routing_model={},
156    screens=[
157        Screen(
158            id="DEMO_SCREEN",
159            terminal=True,
160            title="Demo screen",
161            layout=Layout(
162                type=LayoutType.SINGLE_COLUMN,
163                children=[
164                    Form(
165                        name="form_name",
166                        children=[
167                            DatePicker(
168                                name="date",
169                                label="Date",
170                                min_date="1693569600000",
171                                max_date="1767182400000",
172                                unavailable_dates=[
173                                    "1694779200000",
174                                    "1697371200000",
175                                ],
176                                on_select_action=DataExchangeAction(
177                                    payload={"date": ComponentRef("date")},
178                                ),
179                            ),
180                            Footer(
181                                label="Continue",
182                                on_click_action=DataExchangeAction(),
183                            ),
184                        ],
185                    )
186                ],
187            ),
188        )
189    ],
190)
191
192global_fields = FlowJSON(
193    version="4.0",
194    screens=[
195        screen_one := Screen(
196            data=[
197                field2 := ScreenData(key="field2", example="data"),
198            ],
199            id="SCREEN_ONE",
200            layout=Layout(
201                type=LayoutType.SINGLE_COLUMN,
202                children=[
203                    field1 := TextInput(name="field1", label="Enter your name"),
204                    Footer(
205                        label="CTA",
206                        on_click_action=NavigateAction(
207                            next=Next(name="SCREEN_TWO"),
208                        ),
209                    ),
210                ],
211            ),
212            title="Screen 1",
213        ),
214        Screen(
215            id="SCREEN_TWO",
216            terminal=True,
217            layout=Layout(
218                type=LayoutType.SINGLE_COLUMN,
219                children=[
220                    Footer(
221                        label="Complete",
222                        on_click_action=CompleteAction(
223                            payload={
224                                "field1": screen_one / field1.ref,
225                                "field2": screen_one / field2.ref,
226                            },
227                        ),
228                    ),
229                ],
230            ),
231            title="Screen 2",
232            data={},
233        ),
234    ],
235)
236
237
238forward_refs = FlowJSON(
239    version="4.0",
240    routing_model={"SELECT_SERVICES": ["SELECT_INSURANCE"]},
241    screens=[
242        select_insurance_screen := Screen(
243            id="SELECT_INSURANCE",
244            title="Select insurance",
245            layout=Layout(
246                type=LayoutType.SINGLE_COLUMN,
247                children=[
248                    insurance := RadioButtonsGroup(
249                        name="insurance",
250                        label="Please select your coverage",
251                        data_source=[
252                            basic := DataSource(id="basic", title="Basic"),
253                            standard := DataSource(id="standard", title="Standard"),
254                            full := DataSource(id="full", title="Premium"),
255                        ],
256                    )
257                ],
258            ),
259        ),
260        Screen(
261            terminal=True,
262            id="SELECT_SERVICES",
263            title="Select services",
264            layout=Layout(
265                type=LayoutType.SINGLE_COLUMN,
266                children=[
267                    TextSubheading(text="Select insurance type"),
268                    If(
269                        condition=select_insurance_screen / insurance.ref != "",
270                        then=[
271                            Switch(
272                                value=select_insurance_screen / insurance.ref,
273                                cases={
274                                    "basic": [
275                                        TextBody(
276                                            text="You've selected a basic insurance"
277                                        )
278                                    ],
279                                    "standard": [
280                                        TextBody(
281                                            text="You've selected a standard insurance"
282                                        )
283                                    ],
284                                    "full": [
285                                        TextBody(
286                                            text="You've selected a comprehensive insurance"
287                                        )
288                                    ],
289                                },
290                            )
291                        ],
292                        else_=[
293                            TextBody(text="You haven't selected any insurance type")
294                        ],
295                    ),
296                    EmbeddedLink(
297                        text="Choose insurance type",
298                        on_click_action=NavigateAction(
299                            next=Next(type=NextType.SCREEN, name="SELECT_INSURANCE"),
300                        ),
301                    ),
302                    Footer(
303                        label="Complete",
304                        on_click_action=CompleteAction(
305                            payload={
306                                "selected_insurance_type": select_insurance_screen
307                                / insurance.ref
308                            },
309                        ),
310                    ),
311                ],
312            ),
313        ),
314    ],
315)
JSON Code#
  1{
  2  "if_": {
  3    "version": "4.0",
  4    "screens": [
  5      {
  6        "data": {
  7          "value": {
  8            "type": "boolean",
  9            "__example__": true
 10          }
 11        },
 12        "id": "SCREEN",
 13        "layout": {
 14          "type": "SingleColumnLayout",
 15          "children": [
 16            {
 17              "type": "TextInput",
 18              "label": "Animal",
 19              "name": "animal",
 20              "helper-text": "Type: cat"
 21            },
 22            {
 23              "type": "If",
 24              "condition": "(${data.value} && (${form.animal} == 'cat'))",
 25              "then": [
 26                {
 27                  "type": "TextHeading",
 28                  "text": "It is a cat"
 29                }
 30              ],
 31              "else": [
 32                {
 33                  "type": "TextHeading",
 34                  "text": "It is not a cat"
 35                }
 36              ]
 37            },
 38            {
 39              "type": "Footer",
 40              "label": "Complete",
 41              "on-click-action": {
 42                "name": "complete",
 43                "payload": {}
 44              }
 45            }
 46          ]
 47        },
 48        "title": "Welcome",
 49        "terminal": true,
 50        "success": true
 51      }
 52    ]
 53  },
 54  "switch": {
 55    "version": "4.0",
 56    "screens": [
 57      {
 58        "data": {
 59          "value": {
 60            "type": "string",
 61            "__example__": "cat"
 62          }
 63        },
 64        "id": "SCREEN",
 65        "layout": {
 66          "type": "SingleColumnLayout",
 67          "children": [
 68            {
 69              "type": "TextInput",
 70              "label": "Animal",
 71              "name": "animal",
 72              "helper-text": "Type: cat, dog or anything else"
 73            },
 74            {
 75              "type": "Switch",
 76              "value": "${form.animal}",
 77              "cases": {
 78                "cat": [
 79                  {
 80                    "type": "TextHeading",
 81                    "text": "It is a cat"
 82                  }
 83                ],
 84                "dog": [
 85                  {
 86                    "type": "TextHeading",
 87                    "text": "It is a dog"
 88                  }
 89                ],
 90                "default": [
 91                  {
 92                    "type": "TextHeading",
 93                    "text": "It is neither a cat nor a dog"
 94                  }
 95                ]
 96              }
 97            },
 98            {
 99              "type": "Footer",
100              "label": "Complete",
101              "on-click-action": {
102                "name": "complete",
103                "payload": {}
104              }
105            }
106          ]
107        },
108        "title": "Welcome",
109        "terminal": true,
110        "success": true
111      }
112    ]
113  },
114  "photo_picker": {
115    "version": "4.0",
116    "routing_model": {
117      "FIRST": []
118    },
119    "data_api_version": "3.0",
120    "screens": [
121      {
122        "id": "FIRST",
123        "title": "Photo Picker Example",
124        "terminal": true,
125        "data": {},
126        "layout": {
127          "type": "SingleColumnLayout",
128          "children": [
129            {
130              "type": "Form",
131              "name": "flow_path",
132              "children": [
133                {
134                  "type": "PhotoPicker",
135                  "name": "photo_picker",
136                  "label": "Upload photos",
137                  "description": "Please attach images about the received items",
138                  "photo-source": "camera_gallery",
139                  "min-uploaded-photos": 1,
140                  "max-uploaded-photos": 10,
141                  "max-file-size-kb": 10240
142                },
143                {
144                  "type": "Footer",
145                  "label": "Submit",
146                  "on-click-action": {
147                    "name": "data_exchange",
148                    "payload": {
149                      "images": "${form.photo_picker}"
150                    }
151                  }
152                }
153              ]
154            }
155          ]
156        }
157      }
158    ]
159  },
160  "doc_picker": {
161    "version": "4.0",
162    "routing_model": {
163      "SECOND": []
164    },
165    "data_api_version": "3.0",
166    "screens": [
167      {
168        "id": "SECOND",
169        "terminal": true,
170        "title": "Document Picker Example",
171        "data": {},
172        "layout": {
173          "type": "SingleColumnLayout",
174          "children": [
175            {
176              "type": "Form",
177              "name": "flow_path",
178              "children": [
179                {
180                  "type": "DocumentPicker",
181                  "name": "document_picker",
182                  "label": "Contract",
183                  "description": "Attach the signed copy of the contract",
184                  "min-uploaded-documents": 1,
185                  "max-uploaded-documents": 1,
186                  "max-file-size-kb": 1024,
187                  "allowed-mime-types": [
188                    "image/jpeg",
189                    "application/pdf"
190                  ]
191                },
192                {
193                  "type": "Footer",
194                  "label": "Submit",
195                  "on-click-action": {
196                    "name": "complete",
197                    "payload": {
198                      "documents": "${form.document_picker}"
199                    }
200                  }
201                }
202              ]
203            }
204          ]
205        }
206      }
207    ]
208  },
209  "date_picker_dates_str": {
210    "version": "4.0",
211    "data_api_version": "3.0",
212    "routing_model": {},
213    "screens": [
214      {
215        "id": "DEMO_SCREEN",
216        "terminal": true,
217        "title": "Demo screen",
218        "layout": {
219          "type": "SingleColumnLayout",
220          "children": [
221            {
222              "type": "Form",
223              "name": "form_name",
224              "children": [
225                {
226                  "type": "DatePicker",
227                  "name": "date",
228                  "label": "Date",
229                  "min-date": "1693569600000",
230                  "max-date": "1767182400000",
231                  "unavailable-dates": [
232                    "1694779200000",
233                    "1697371200000"
234                  ],
235                  "on-select-action": {
236                    "name": "data_exchange",
237                    "payload": {
238                      "date": "${form.date}"
239                    }
240                  }
241                },
242                {
243                  "type": "Footer",
244                  "label": "Continue",
245                  "on-click-action": {
246                    "name": "data_exchange",
247                    "payload": {}
248                  }
249                }
250              ]
251            }
252          ]
253        }
254      }
255    ]
256  },
257  "global_fields": {
258    "version": "4.0",
259    "screens": [
260      {
261        "data": {
262          "field2": {
263            "type": "string",
264            "__example__": "data"
265          }
266        },
267        "id": "SCREEN_ONE",
268        "layout": {
269          "type": "SingleColumnLayout",
270          "children": [
271            {
272              "type": "TextInput",
273              "name": "field1",
274              "label": "Enter your name"
275            },
276            {
277              "type": "Footer",
278              "label": "CTA",
279              "on-click-action": {
280                "name": "navigate",
281                "next": {
282                  "type": "screen",
283                  "name": "SCREEN_TWO"
284                },
285                "payload": {}
286              }
287            }
288          ]
289        },
290        "title": "Screen 1"
291      },
292      {
293        "id": "SCREEN_TWO",
294        "terminal": true,
295        "layout": {
296          "type": "SingleColumnLayout",
297          "children": [
298            {
299              "type": "Footer",
300              "label": "Complete",
301              "on-click-action": {
302                "name": "complete",
303                "payload": {
304                  "field1": "${screen.SCREEN_ONE.form.field1}",
305                  "field2": "${screen.SCREEN_ONE.data.field2}"
306                }
307              }
308            }
309          ]
310        },
311        "title": "Screen 2",
312        "data": {}
313      }
314    ]
315  },
316  "forward_refs": {
317    "version": "4.0",
318    "routing_model": {
319      "SELECT_SERVICES": [
320        "SELECT_INSURANCE"
321      ]
322    },
323    "screens": [
324      {
325        "id": "SELECT_INSURANCE",
326        "title": "Select insurance",
327        "layout": {
328          "type": "SingleColumnLayout",
329          "children": [
330            {
331              "type": "RadioButtonsGroup",
332              "name": "insurance",
333              "label": "Please select your coverage",
334              "data-source": [
335                {
336                  "id": "basic",
337                  "title": "Basic"
338                },
339                {
340                  "id": "standard",
341                  "title": "Standard"
342                },
343                {
344                  "id": "full",
345                  "title": "Premium"
346                }
347              ]
348            }
349          ]
350        }
351      },
352      {
353        "terminal": true,
354        "id": "SELECT_SERVICES",
355        "title": "Select services",
356        "layout": {
357          "type": "SingleColumnLayout",
358          "children": [
359            {
360              "type": "TextSubheading",
361              "text": "Select insurance type"
362            },
363            {
364              "type": "If",
365              "condition": "(${screen.SELECT_INSURANCE.form.insurance} != '')",
366              "then": [
367                {
368                  "type": "Switch",
369                  "value": "${screen.SELECT_INSURANCE.form.insurance}",
370                  "cases": {
371                    "basic": [
372                      {
373                        "type": "TextBody",
374                        "text": "You've selected a basic insurance"
375                      }
376                    ],
377                    "standard": [
378                      {
379                        "type": "TextBody",
380                        "text": "You've selected a standard insurance"
381                      }
382                    ],
383                    "full": [
384                      {
385                        "type": "TextBody",
386                        "text": "You've selected a comprehensive insurance"
387                      }
388                    ]
389                  }
390                }
391              ],
392              "else": [
393                {
394                  "type": "TextBody",
395                  "text": "You haven't selected any insurance type"
396                }
397              ]
398            },
399            {
400              "type": "EmbeddedLink",
401              "text": "Choose insurance type",
402              "on-click-action": {
403                "name": "navigate",
404                "next": {
405                  "type": "screen",
406                  "name": "SELECT_INSURANCE"
407                },
408                "payload": {}
409              }
410            },
411            {
412              "type": "Footer",
413              "label": "Complete",
414              "on-click-action": {
415                "name": "complete",
416                "payload": {
417                  "selected_insurance_type": "${screen.SELECT_INSURANCE.form.insurance}"
418                }
419              }
420            }
421          ]
422        }
423      }
424    ]
425  }
426}

v2.1 Examples#

Python Code#
   1from pywa.types.flows import *  # noqa: F403
   2
   3customer_satisfaction_survey = FlowJSON(
   4    version="2.1",
   5    screens=[
   6        Screen(
   7            id="RECOMMEND",
   8            title="Feedback 1 of 2",
   9            data={},
  10            layout=Layout(
  11                type=LayoutType.SINGLE_COLUMN,
  12                children=[
  13                    Form(
  14                        name="form",
  15                        children=[
  16                            TextSubheading(text="Would you recommend us to a friend?"),
  17                            recommend_radio := RadioButtonsGroup(
  18                                name="recommend_radio",
  19                                label="Choose one",
  20                                data_source=[
  21                                    DataSource(id="0", title="Yes"),
  22                                    DataSource(id="1", title="No"),
  23                                ],
  24                                required=True,
  25                            ),
  26                            TextSubheading(text="How could we do better?"),
  27                            comment_text := TextArea(
  28                                name="comment_text",
  29                                label="Leave a comment",
  30                                required=False,
  31                            ),
  32                            Footer(
  33                                label="Continue",
  34                                on_click_action=NavigateAction(
  35                                    next=Next(name="RATE"),
  36                                    payload={
  37                                        "recommend_radio": recommend_radio.ref,
  38                                        "comment_text": comment_text.ref,
  39                                    },
  40                                ),
  41                            ),
  42                        ],
  43                    )
  44                ],
  45            ),
  46        ),
  47        Screen(
  48            id="RATE",
  49            title="Feedback 2 of 2",
  50            data=[
  51                recommend_radio := ScreenData(key="recommend_radio", example="Example"),
  52                comment_text := ScreenData(key="comment_text", example="Example"),
  53            ],
  54            terminal=True,
  55            layout=Layout(
  56                type=LayoutType.SINGLE_COLUMN,
  57                children=[
  58                    Form(
  59                        name="form",
  60                        children=[
  61                            TextSubheading(text="Rate the following: "),
  62                            purchase_rating := Dropdown(
  63                                name="purchase_rating",
  64                                label="Purchase experience",
  65                                required=True,
  66                                data_source=[
  67                                    DataSource(id="0", title="★★★★★ • Excellent (5/5)"),
  68                                    DataSource(id="1", title="★★★★☆ • Good (4/5)"),
  69                                    DataSource(id="2", title="★★★☆☆ • Average (3/5)"),
  70                                    DataSource(id="3", title="★★☆☆☆ • Poor (2/5)"),
  71                                    DataSource(id="4", title="★☆☆☆☆ • Very Poor (1/5)"),
  72                                ],
  73                            ),
  74                            delivery_rating := Dropdown(
  75                                name="delivery_rating",
  76                                label="Delivery and setup",
  77                                required=True,
  78                                data_source=[
  79                                    DataSource(id="0", title="★★★★★ • Excellent (5/5)"),
  80                                    DataSource(id="1", title="★★★★☆ • Good (4/5)"),
  81                                    DataSource(id="2", title="★★★☆☆ • Average (3/5)"),
  82                                    DataSource(id="3", title="★★☆☆☆ • Poor (2/5)"),
  83                                    DataSource(id="4", title="★☆☆☆☆ • Very Poor (1/5)"),
  84                                ],
  85                            ),
  86                            cs_rating := Dropdown(
  87                                name="cs_rating",
  88                                label="Customer service",
  89                                required=True,
  90                                data_source=[
  91                                    DataSource(id="0", title="★★★★★ • Excellent (5/5)"),
  92                                    DataSource(id="1", title="★★★★☆ • Good (4/5)"),
  93                                    DataSource(id="2", title="★★★☆☆ • Average (3/5)"),
  94                                    DataSource(id="3", title="★★☆☆☆ • Poor (2/5)"),
  95                                    DataSource(id="4", title="★☆☆☆☆ • Very Poor (1/5)"),
  96                                ],
  97                            ),
  98                            Footer(
  99                                label="Done",
 100                                on_click_action=CompleteAction(
 101                                    payload={
 102                                        "purchase_rating": purchase_rating.ref,
 103                                        "delivery_rating": delivery_rating.ref,
 104                                        "cs_rating": cs_rating.ref,
 105                                        "recommend_radio": recommend_radio.ref,
 106                                        "comment_text": comment_text.ref,
 107                                    },
 108                                ),
 109                            ),
 110                        ],
 111                    )
 112                ],
 113            ),
 114        ),
 115    ],
 116)
 117
 118load_re_engagement = FlowJSON(
 119    version="2.1",
 120    screens=[
 121        Screen(
 122            id="SIGN_UP",
 123            title="Finish Sign Up",
 124            terminal=True,
 125            data={},
 126            layout=Layout(
 127                type=LayoutType.SINGLE_COLUMN,
 128                children=[
 129                    Form(
 130                        name="form",
 131                        children=[
 132                            first_name := TextInput(
 133                                name="firstName",
 134                                label="First Name",
 135                                input_type=InputType.TEXT,
 136                                required=True,
 137                                visible=True,
 138                            ),
 139                            last_name := TextInput(
 140                                name="lastName",
 141                                label="Last Name",
 142                                input_type=InputType.TEXT,
 143                                required=True,
 144                                visible=True,
 145                            ),
 146                            email := TextInput(
 147                                name="email",
 148                                label="Email Address",
 149                                input_type=InputType.EMAIL,
 150                                required=True,
 151                                visible=True,
 152                            ),
 153                            Footer(
 154                                label="Done",
 155                                enabled=True,
 156                                on_click_action=CompleteAction(
 157                                    payload={
 158                                        "firstName": first_name.ref,
 159                                        "lastName": last_name.ref,
 160                                        "email": email.ref,
 161                                    },
 162                                ),
 163                            ),
 164                        ],
 165                    )
 166                ],
 167            ),
 168        )
 169    ],
 170)
 171
 172costumer_engagement = FlowJSON(
 173    version="2.1",
 174    screens=[
 175        Screen(
 176            id="QUESTION_ONE",
 177            title="Question 1 of 3",
 178            data={},
 179            layout=Layout(
 180                type=LayoutType.SINGLE_COLUMN,
 181                children=[
 182                    Form(
 183                        name="form",
 184                        children=[
 185                            TextHeading(
 186                                text="You've found the perfect deal, what do you do next?"
 187                            ),
 188                            question1_checkbox := CheckboxGroup(
 189                                name="question1Checkbox",
 190                                label="Choose all that apply:",
 191                                required=True,
 192                                data_source=[
 193                                    DataSource(id="0", title="Buy it right away"),
 194                                    DataSource(
 195                                        id="1", title="Check reviews before buying"
 196                                    ),
 197                                    DataSource(
 198                                        id="2", title="Share it with friends + family"
 199                                    ),
 200                                    DataSource(
 201                                        id="3", title="Buy multiple, while its cheap"
 202                                    ),
 203                                    DataSource(id="4", title="None of the above"),
 204                                ],
 205                            ),
 206                            Footer(
 207                                label="Continue",
 208                                on_click_action=NavigateAction(
 209                                    next=Next(
 210                                        type=NextType.SCREEN, name="QUESTION_TWO"
 211                                    ),
 212                                    payload={
 213                                        "question1Checkbox": question1_checkbox.ref
 214                                    },
 215                                ),
 216                            ),
 217                        ],
 218                    )
 219                ],
 220            ),
 221        ),
 222        Screen(
 223            id="QUESTION_TWO",
 224            title="Question 2 of 3",
 225            data=[
 226                question1_checkbox := ScreenData(
 227                    key="question1Checkbox", example=["Example", "Example2"]
 228                ),
 229            ],
 230            layout=Layout(
 231                type=LayoutType.SINGLE_COLUMN,
 232                children=[
 233                    Form(
 234                        name="form",
 235                        children=[
 236                            TextHeading(
 237                                text="Its your birthday in two weeks, how might you prepare?"
 238                            ),
 239                            question2_radio_buttons := RadioButtonsGroup(
 240                                name="question2RadioButtons",
 241                                label="Choose all that apply:",
 242                                required=True,
 243                                data_source=[
 244                                    DataSource(id="0", title="Buy something new"),
 245                                    DataSource(id="1", title="Wear the same, as usual"),
 246                                    DataSource(id="2", title="Look for a deal online"),
 247                                ],
 248                            ),
 249                            Footer(
 250                                label="Continue",
 251                                on_click_action=NavigateAction(
 252                                    next=Next(
 253                                        type=NextType.SCREEN,
 254                                        name="QUESTION_THREE",
 255                                    ),
 256                                    payload={
 257                                        "question2RadioButtons": question2_radio_buttons.ref,
 258                                        "question1Checkbox": question1_checkbox.ref,
 259                                    },
 260                                ),
 261                            ),
 262                        ],
 263                    )
 264                ],
 265            ),
 266        ),
 267        Screen(
 268            id="QUESTION_THREE",
 269            title="Question 3 of 3",
 270            data=[
 271                question2_radio_buttons := ScreenData(
 272                    key="question2RadioButtons", example="Example"
 273                ),
 274                question1_checkbox := ScreenData(
 275                    key="question1Checkbox", example=["Example", "Example2"]
 276                ),
 277            ],
 278            terminal=True,
 279            layout=Layout(
 280                type=LayoutType.SINGLE_COLUMN,
 281                children=[
 282                    Form(
 283                        name="form",
 284                        children=[
 285                            TextHeading(text="What's the best gift for a friend?"),
 286                            question3_checkbox := CheckboxGroup(
 287                                name="question3Checkbox",
 288                                label="Choose all that apply:",
 289                                required=True,
 290                                data_source=[
 291                                    DataSource(id="0", title="A gift voucher"),
 292                                    DataSource(id="1", title="A new outfit "),
 293                                    DataSource(id="2", title="A bouquet of flowers"),
 294                                    DataSource(id="3", title="A meal out together"),
 295                                ],
 296                            ),
 297                            Footer(
 298                                label="Done",
 299                                on_click_action=CompleteAction(
 300                                    payload={
 301                                        "question1Checkbox": question1_checkbox.ref,
 302                                        "question2RadioButtons": question2_radio_buttons.ref,
 303                                        "question3Checkbox": question3_checkbox.ref,
 304                                    },
 305                                ),
 306                            ),
 307                        ],
 308                    )
 309                ],
 310            ),
 311        ),
 312    ],
 313)
 314
 315support_request = FlowJSON(
 316    version="2.1",
 317    screens=[
 318        Screen(
 319            id="DETAILS",
 320            title="Get help",
 321            data={},
 322            terminal=True,
 323            layout=Layout(
 324                type=LayoutType.SINGLE_COLUMN,
 325                children=[
 326                    Form(
 327                        name="form",
 328                        children=[
 329                            name := TextInput(
 330                                name="name",
 331                                label="Name",
 332                                input_type=InputType.TEXT,
 333                                required=True,
 334                            ),
 335                            order_number := TextInput(
 336                                label="Order number",
 337                                name="orderNumber",
 338                                input_type=InputType.NUMBER,
 339                                required=True,
 340                                helper_text="",
 341                            ),
 342                            topic_radio := RadioButtonsGroup(
 343                                label="Choose a topic",
 344                                name="topicRadio",
 345                                data_source=[
 346                                    DataSource(id="0", title="Orders and payments"),
 347                                    DataSource(id="1", title="Maintenance"),
 348                                    DataSource(id="2", title="Delivery"),
 349                                    DataSource(id="3", title="Returns"),
 350                                    DataSource(id="4", title="Other"),
 351                                ],
 352                                required=True,
 353                            ),
 354                            desc := TextArea(
 355                                label="Description of issue",
 356                                required=False,
 357                                name="description",
 358                            ),
 359                            Footer(
 360                                label="Done",
 361                                on_click_action=CompleteAction(
 362                                    payload={
 363                                        "name": name.ref,
 364                                        "orderNumber": order_number.ref,
 365                                        "topicRadio": topic_radio.ref,
 366                                        "description": desc.ref,
 367                                    },
 368                                ),
 369                            ),
 370                        ],
 371                    )
 372                ],
 373            ),
 374        )
 375    ],
 376)
 377
 378communication_preferences = FlowJSON(
 379    version="2.1",
 380    screens=[
 381        Screen(
 382            id="PREFERENCES",
 383            title="Update Preferences",
 384            data={},
 385            terminal=True,
 386            layout=Layout(
 387                type=LayoutType.SINGLE_COLUMN,
 388                children=[
 389                    Form(
 390                        name="form",
 391                        children=[
 392                            communication_types := CheckboxGroup(
 393                                label="Communication types",
 394                                required=True,
 395                                name="communicationTypes",
 396                                data_source=[
 397                                    DataSource(
 398                                        id="0", title="Special offers and promotions"
 399                                    ),
 400                                    DataSource(
 401                                        id="1", title="Changes to my subscription"
 402                                    ),
 403                                    DataSource(id="2", title="News and events"),
 404                                    DataSource(id="3", title="New products"),
 405                                ],
 406                            ),
 407                            contact_prefs := CheckboxGroup(
 408                                label="Contact Preferences",
 409                                required=False,
 410                                name="contactPrefs",
 411                                data_source=[
 412                                    DataSource(id="0", title="Whatsapp"),
 413                                    DataSource(id="1", title="Email"),
 414                                    DataSource(id="2", title="SMS"),
 415                                ],
 416                            ),
 417                            Footer(
 418                                label="Done",
 419                                on_click_action=CompleteAction(
 420                                    payload={
 421                                        "communicationTypes": communication_types.ref,
 422                                        "contactPrefs": contact_prefs.ref,
 423                                    },
 424                                ),
 425                            ),
 426                        ],
 427                    )
 428                ],
 429            ),
 430        )
 431    ],
 432)
 433
 434register_for_an_event = FlowJSON(
 435    version="2.1",
 436    screens=[
 437        Screen(
 438            id="SIGN_UP",
 439            title="Sign Up",
 440            data={},
 441            layout=Layout(
 442                type=LayoutType.SINGLE_COLUMN,
 443                children=[
 444                    Form(
 445                        name="form",
 446                        children=[
 447                            TextHeading(text="Join our next webinar!"),
 448                            TextBody(text="First, we'll need a few details from you."),
 449                            first_name := TextInput(
 450                                name="firstName",
 451                                label="First Name",
 452                                input_type=InputType.TEXT,
 453                                required=True,
 454                            ),
 455                            last_name := TextInput(
 456                                label="Last Name",
 457                                name="lastName",
 458                                input_type=InputType.TEXT,
 459                                required=True,
 460                            ),
 461                            email := TextInput(
 462                                label="Email Address",
 463                                name="email",
 464                                input_type=InputType.EMAIL,
 465                                required=True,
 466                            ),
 467                            Footer(
 468                                label="Continue",
 469                                on_click_action=NavigateAction(
 470                                    next=Next(type=NextType.SCREEN, name="SURVEY"),
 471                                    payload={
 472                                        "firstName": first_name.ref,
 473                                        "lastName": last_name.ref,
 474                                        "email": email.ref,
 475                                    },
 476                                ),
 477                            ),
 478                        ],
 479                    )
 480                ],
 481            ),
 482        ),
 483        Screen(
 484            id="SURVEY",
 485            title="Thank you",
 486            data=[
 487                first_name := ScreenData(key="firstName", example="Example"),
 488                last_name := ScreenData(key="lastName", example="Example"),
 489                email := ScreenData(key="email", example="Example"),
 490            ],
 491            terminal=True,
 492            layout=Layout(
 493                type=LayoutType.SINGLE_COLUMN,
 494                children=[
 495                    Form(
 496                        name="form",
 497                        children=[
 498                            TextHeading(text="Before you go"),
 499                            TextBody(text="How did you hear about us?"),
 500                            source := RadioButtonsGroup(
 501                                name="source",
 502                                label="Choose one",
 503                                required=False,
 504                                data_source=[
 505                                    DataSource(id="0", title="Friend's recommendation"),
 506                                    DataSource(id="1", title="TV advertisement"),
 507                                    DataSource(id="2", title="Search engine"),
 508                                    DataSource(id="3", title="Social media"),
 509                                ],
 510                            ),
 511                            Footer(
 512                                label="Done",
 513                                on_click_action=CompleteAction(
 514                                    payload={
 515                                        "source": source.ref,
 516                                        "firstName": first_name.ref,
 517                                        "lastName": last_name.ref,
 518                                        "email": email.ref,
 519                                    },
 520                                ),
 521                            ),
 522                        ],
 523                    )
 524                ],
 525            ),
 526        ),
 527    ],
 528)
 529
 530sign_in = FlowJSON(
 531    version="2.1",
 532    data_api_version="3.0",
 533    data_channel_uri="https://example.com",
 534    routing_model={
 535        "SIGN_IN": ["SIGN_UP", "FORGOT_PASSWORD"],
 536        "SIGN_UP": ["TERMS_AND_CONDITIONS"],
 537        "FORGOT_PASSWORD": [],
 538        "TERMS_AND_CONDITIONS": [],
 539    },
 540    screens=[
 541        Screen(
 542            id="SIGN_IN",
 543            title="Sign in",
 544            terminal=True,
 545            data={},
 546            layout=Layout(
 547                type=LayoutType.SINGLE_COLUMN,
 548                children=[
 549                    Form(
 550                        name="sign_in_form",
 551                        children=[
 552                            email := TextInput(
 553                                name="email",
 554                                label="Email address",
 555                                input_type=InputType.EMAIL,
 556                                required=True,
 557                            ),
 558                            password := TextInput(
 559                                name="password",
 560                                label="Password",
 561                                input_type=InputType.PASSWORD,
 562                                required=True,
 563                            ),
 564                            EmbeddedLink(
 565                                text="Don't have an account? Sign up",
 566                                on_click_action=NavigateAction(
 567                                    next=Next(type=NextType.SCREEN, name="SIGN_UP"),
 568                                ),
 569                            ),
 570                            EmbeddedLink(
 571                                text="Forgot password",
 572                                on_click_action=NavigateAction(
 573                                    next=Next(
 574                                        type=NextType.SCREEN,
 575                                        name="FORGOT_PASSWORD",
 576                                    ),
 577                                    payload={"body": "Example"},
 578                                ),
 579                            ),
 580                            Footer(
 581                                label="Sign in",
 582                                on_click_action=DataExchangeAction(
 583                                    payload={
 584                                        "email": email.ref,
 585                                        "password": password.ref,
 586                                    },
 587                                ),
 588                            ),
 589                        ],
 590                    )
 591                ],
 592            ),
 593        ),
 594        Screen(
 595            id="SIGN_UP",
 596            title="Sign up",
 597            data={},
 598            layout=Layout(
 599                type=LayoutType.SINGLE_COLUMN,
 600                children=[
 601                    Form(
 602                        name="sign_up_form",
 603                        children=[
 604                            first_name := TextInput(
 605                                name="first_name",
 606                                label="First Name",
 607                                input_type=InputType.TEXT,
 608                                required=True,
 609                            ),
 610                            last_name := TextInput(
 611                                name="last_name",
 612                                label="Last Name",
 613                                input_type=InputType.TEXT,
 614                                required=True,
 615                            ),
 616                            email := TextInput(
 617                                name="email",
 618                                label="Email address",
 619                                input_type=InputType.EMAIL,
 620                                required=True,
 621                            ),
 622                            password := TextInput(
 623                                name="password",
 624                                label="Set password",
 625                                input_type=InputType.PASSWORD,
 626                                required=True,
 627                            ),
 628                            confirm_password := TextInput(
 629                                name="confirm_password",
 630                                label="Confirm password",
 631                                input_type=InputType.PASSWORD,
 632                                required=True,
 633                            ),
 634                            terms_agreement := OptIn(
 635                                name="terms_agreement",
 636                                label="I agree with the terms.",
 637                                required=True,
 638                                on_click_action=NavigateAction(
 639                                    next=Next(
 640                                        type=NextType.SCREEN,
 641                                        name="TERMS_AND_CONDITIONS",
 642                                    ),
 643                                ),
 644                            ),
 645                            offers_acceptance := OptIn(
 646                                name="offers_acceptance",
 647                                label="I would like to receive news and offers.",
 648                            ),
 649                            Footer(
 650                                label="Continue",
 651                                on_click_action=DataExchangeAction(
 652                                    payload={
 653                                        "first_name": first_name.ref,
 654                                        "last_name": last_name.ref,
 655                                        "email": email.ref,
 656                                        "password": password.ref,
 657                                        "confirm_password": confirm_password.ref,
 658                                        "terms_agreement": terms_agreement.ref,
 659                                        "offers_acceptance": offers_acceptance.ref,
 660                                    },
 661                                ),
 662                            ),
 663                        ],
 664                    )
 665                ],
 666            ),
 667        ),
 668        Screen(
 669            id="FORGOT_PASSWORD",
 670            title="Forgot password",
 671            terminal=True,
 672            data=[
 673                body := ScreenData(
 674                    key="body",
 675                    example=(
 676                        "Enter your email address for your account and we'll send a reset link. "
 677                        "The single-use link will expire after 24 hours."
 678                    ),
 679                ),
 680            ],
 681            layout=Layout(
 682                type=LayoutType.SINGLE_COLUMN,
 683                children=[
 684                    Form(
 685                        name="forgot_password_form",
 686                        children=[
 687                            TextBody(text=body.ref),
 688                            email := TextInput(
 689                                name="email",
 690                                label="Email address",
 691                                input_type=InputType.EMAIL,
 692                                required=True,
 693                            ),
 694                            Footer(
 695                                label="Sign in",
 696                                on_click_action=DataExchangeAction(
 697                                    payload={"email": email.ref},
 698                                ),
 699                            ),
 700                        ],
 701                    )
 702                ],
 703            ),
 704        ),
 705        Screen(
 706            id="TERMS_AND_CONDITIONS",
 707            title="Terms and conditions",
 708            data={},
 709            layout=Layout(
 710                type=LayoutType.SINGLE_COLUMN,
 711                children=[
 712                    TextHeading(text="Our Terms"),
 713                    TextSubheading(text="Data usage"),
 714                    TextBody(
 715                        text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
 716                    ),
 717                    TextSubheading(text="Privacy policy"),
 718                    TextBody(
 719                        text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
 720                    ),
 721                ],
 722            ),
 723        ),
 724    ],
 725)
 726
 727register = FlowJSON(
 728    version="2.1",
 729    data_api_version="3.0",
 730    data_channel_uri="https://example.com",
 731    routing_model={"REGISTER": ["TERMS_AND_CONDITIONS"], "TERMS_AND_CONDITIONS": []},
 732    screens=[
 733        Screen(
 734            id="REGISTER",
 735            title="Register for an account",
 736            terminal=True,
 737            data=[
 738                error_messages := ScreenData(
 739                    key="error_messages",
 740                    example={"confirm_password": "Passwords don't match."},
 741                ),
 742            ],
 743            layout=Layout(
 744                type=LayoutType.SINGLE_COLUMN,
 745                children=[
 746                    Form(
 747                        name="register_form",
 748                        error_messages=error_messages.ref,
 749                        children=[
 750                            first_name := TextInput(
 751                                name="first_name",
 752                                required=True,
 753                                label="First name",
 754                                input_type="text",
 755                            ),
 756                            last_name := TextInput(
 757                                name="last_name",
 758                                required=True,
 759                                label="Last name",
 760                                input_type="text",
 761                            ),
 762                            email := TextInput(
 763                                name="email",
 764                                required=True,
 765                                label="Email address",
 766                                input_type="email",
 767                            ),
 768                            password := TextInput(
 769                                name="password",
 770                                required=True,
 771                                label="Set password",
 772                                input_type="password",
 773                            ),
 774                            confirm_password := TextInput(
 775                                name="confirm_password",
 776                                required=True,
 777                                label="Confirm password",
 778                                input_type="password",
 779                            ),
 780                            terms_agreement := OptIn(
 781                                name="terms_agreement",
 782                                label="I agree with the terms.",
 783                                required=True,
 784                                on_click_action=NavigateAction(
 785                                    next=Next(
 786                                        type=NextType.SCREEN,
 787                                        name="TERMS_AND_CONDITIONS",
 788                                    ),
 789                                ),
 790                            ),
 791                            offers_acceptance := OptIn(
 792                                name="offers_acceptance",
 793                                label="I would like to receive news and offers.",
 794                            ),
 795                            Footer(
 796                                label="Continue",
 797                                on_click_action=DataExchangeAction(
 798                                    payload={
 799                                        "first_name": first_name.ref,
 800                                        "last_name": last_name.ref,
 801                                        "email": email.ref,
 802                                        "password": password.ref,
 803                                        "confirm_password": confirm_password.ref,
 804                                        "terms_agreement": terms_agreement.ref,
 805                                        "offers_acceptance": offers_acceptance.ref,
 806                                    },
 807                                ),
 808                            ),
 809                        ],
 810                    )
 811                ],
 812            ),
 813        ),
 814        Screen(
 815            id="TERMS_AND_CONDITIONS",
 816            title="Terms and conditions",
 817            data={},
 818            layout=Layout(
 819                type=LayoutType.SINGLE_COLUMN,
 820                children=[
 821                    TextHeading(text="Our Terms"),
 822                    TextSubheading(text="Data usage"),
 823                    TextBody(
 824                        text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
 825                    ),
 826                    TextSubheading(text="Privacy policy"),
 827                    TextBody(
 828                        text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
 829                    ),
 830                ],
 831            ),
 832        ),
 833    ],
 834)
 835book_a_table = FlowJSON(
 836    version="2.1",
 837    data_api_version="3.0",
 838    data_channel_uri="https://example.com",
 839    routing_model={
 840        "BOOK_TABLE": ["BOOKING_DETAILS"],
 841        "BOOKING_DETAILS": ["BOOKING_CONFIRMATION"],
 842        "BOOKING_CONFIRMATION": ["TERMS_AND_CONDITIONS"],
 843        "TERMS_AND_CONDITIONS": [],
 844    },
 845    screens=[
 846        Screen(
 847            id="BOOK_TABLE",
 848            title="Book a table",
 849            data=[
 850                min_date := ScreenData(key="min_date", example="1696892400000"),
 851                max_date := ScreenData(key="max_date", example="1760050800000"),
 852                unavailable_dates := ScreenData(
 853                    key="unavailable_dates", example=["1760310000000"]
 854                ),
 855                time := ScreenData(
 856                    key="time",
 857                    example=[
 858                        DataSource(id="1", title="12:30"),
 859                        DataSource(id="2", title="13:30"),
 860                        DataSource(id="3", title="18:30"),
 861                        DataSource(id="4", title="19:30"),
 862                        DataSource(id="5", title="20:30"),
 863                    ],
 864                ),
 865                people := ScreenData(
 866                    key="people",
 867                    example=[
 868                        DataSource(id="1", title="1"),
 869                        DataSource(id="2", title="2"),
 870                        DataSource(id="3", title="3"),
 871                        DataSource(id="4", title="4"),
 872                        DataSource(id="5", title="5"),
 873                        DataSource(id="6", title="6"),
 874                        DataSource(id="7+", title="7+"),
 875                    ],
 876                ),
 877                location_data := ScreenData(
 878                    key="location",
 879                    example=[
 880                        DataSource(id="1", title="Shorty Heights, Light City, 59923")
 881                    ],
 882                ),
 883            ],
 884            layout=Layout(
 885                type=LayoutType.SINGLE_COLUMN,
 886                children=[
 887                    Form(
 888                        name="book_table_form",
 889                        children=[
 890                            location := Dropdown(
 891                                label="Location",
 892                                name="location",
 893                                data_source=location_data.ref,
 894                                required=True,
 895                                on_select_action=DataExchangeAction(
 896                                    payload={"location": ComponentRef("location")},
 897                                ),
 898                            ),
 899                            people_form := Dropdown(
 900                                label="People",
 901                                name="people",
 902                                data_source=people.ref,
 903                                required=True,
 904                                on_select_action=DataExchangeAction(
 905                                    payload={"people": ComponentRef("people")},
 906                                ),
 907                            ),
 908                            date := DatePicker(
 909                                name="date",
 910                                label="Date",
 911                                min_date=min_date.ref,
 912                                max_date=max_date.ref,
 913                                unavailable_dates=unavailable_dates.ref,
 914                                required=True,
 915                                on_select_action=DataExchangeAction(
 916                                    payload={"date": ComponentRef("date")},
 917                                ),
 918                            ),
 919                            time_form := Dropdown(
 920                                label="Time",
 921                                name="time",
 922                                data_source=time.ref,
 923                                required=True,
 924                            ),
 925                            Footer(
 926                                label="Continue",
 927                                on_click_action=NavigateAction(
 928                                    next=Next(
 929                                        type=NextType.SCREEN,
 930                                        name="BOOKING_DETAILS",
 931                                    ),
 932                                ),
 933                            ),
 934                        ],
 935                    )
 936                ],
 937            ),
 938        ),
 939        Screen(
 940            id="BOOKING_DETAILS",
 941            title="Booking details",
 942            data={},
 943            layout=Layout(
 944                type=LayoutType.SINGLE_COLUMN,
 945                children=[
 946                    Form(
 947                        name="booking_details_form",
 948                        children=[
 949                            name := TextInput(label="Name", name="name", required=True),
 950                            special_occasion := Dropdown(
 951                                label="Special occasion",
 952                                name="special_occasion",
 953                                data_source=[
 954                                    DataSource(id="1", title="Birthday"),
 955                                    DataSource(id="2", title="Anniversary"),
 956                                    DataSource(id="3", title="Engagement"),
 957                                    DataSource(id="4", title="Graduation"),
 958                                    DataSource(id="5", title="Other"),
 959                                ],
 960                                required=False,
 961                            ),
 962                            requirements := TextArea(
 963                                label="Requirements",
 964                                name="requirements",
 965                                helper_text="e.g. Dietary or accessibility",
 966                                required=False,
 967                            ),
 968                            Footer(
 969                                label="Continue",
 970                                on_click_action=DataExchangeAction(
 971                                    payload={
 972                                        "name": name.ref,
 973                                        "special_occasion": special_occasion.ref,
 974                                        "requirements": requirements.ref,
 975                                    },
 976                                ),
 977                            ),
 978                        ],
 979                    )
 980                ],
 981            ),
 982        ),
 983        Screen(
 984            id="BOOKING_CONFIRMATION",
 985            title="Booking confirmation",
 986            terminal=True,
 987            data=[
 988                date := ScreenData(key="date", example="Date: Saturday, June 7 2023"),
 989                time := ScreenData(key="time", example="Time: 19:30"),
 990                people := ScreenData(key="people", example="People: 4"),
 991                location := ScreenData(
 992                    key="location",
 993                    example="Location: Shorty Heights, Light City, 59923",
 994                ),
 995                name := ScreenData(key="name", example="Name: John Doe"),
 996                special_occasion := ScreenData(
 997                    key="special_occasion", example="Special Occasion: Birthday"
 998                ),
 999            ],
1000            layout=Layout(
1001                type=LayoutType.SINGLE_COLUMN,
1002                children=[
1003                    Form(
1004                        name="confirmation_form",
1005                        children=[
1006                            TextBody(text=date.ref),
1007                            TextBody(text=time.ref),
1008                            TextBody(text=people.ref),
1009                            TextBody(text=location.ref),
1010                            TextBody(text=name.ref),
1011                            TextBody(text=special_occasion.ref),
1012                            privacy_policy := OptIn(
1013                                name="privacy_policy",
1014                                label="Accept our Privacy Policy",
1015                                required=True,
1016                                on_click_action=NavigateAction(
1017                                    next=Next(
1018                                        type=NextType.SCREEN,
1019                                        name="TERMS_AND_CONDITIONS",
1020                                    ),
1021                                ),
1022                            ),
1023                            Footer(
1024                                label="Confirm booking",
1025                                on_click_action=DataExchangeAction(),
1026                            ),
1027                        ],
1028                    )
1029                ],
1030            ),
1031        ),
1032        Screen(
1033            id="TERMS_AND_CONDITIONS",
1034            title="Terms and conditions",
1035            data={},
1036            layout=Layout(
1037                type=LayoutType.SINGLE_COLUMN,
1038                children=[
1039                    TextHeading(text="Our Terms"),
1040                    TextSubheading(text="Data usage"),
1041                    TextBody(
1042                        text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus.",
1043                    ),
1044                    TextSubheading(text="Privacy policy"),
1045                    TextBody(
1046                        text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus.",
1047                    ),
1048                ],
1049            ),
1050        ),
1051    ],
1052)
1053
1054get_a_quote = FlowJSON(
1055    version="2.1",
1056    data_api_version="3.0",
1057    data_channel_uri="https://example.com",
1058    routing_model={
1059        "DETAILS": ["COVER"],
1060        "COVER": ["QUOTE"],
1061        "QUOTE": ["TERMS_AND_CONDITIONS"],
1062        "TERMS_AND_CONDITIONS": [],
1063    },
1064    screens=[
1065        Screen(
1066            id="DETAILS",
1067            title="Your details",
1068            data=[
1069                city := ScreenData(
1070                    key="city", example=[DataSource(id="1", title="Light City, SO")]
1071                ),
1072            ],
1073            layout=Layout(
1074                type=LayoutType.SINGLE_COLUMN,
1075                children=[
1076                    Form(
1077                        name="details_form",
1078                        children=[
1079                            name := TextInput(
1080                                label="Your name",
1081                                input_type=InputType.TEXT,
1082                                name="name",
1083                                required=True,
1084                            ),
1085                            address := TextInput(
1086                                label="Street address",
1087                                input_type=InputType.TEXT,
1088                                name="address",
1089                                required=True,
1090                            ),
1091                            city := Dropdown(
1092                                label="City, State",
1093                                name="city",
1094                                data_source=city.ref,
1095                                required=True,
1096                            ),
1097                            zip_code := TextInput(
1098                                label="Zip code",
1099                                input_type=InputType.TEXT,
1100                                name="zip_code",
1101                                required=True,
1102                            ),
1103                            country_region := TextInput(
1104                                label="Country/Region",
1105                                input_type=InputType.TEXT,
1106                                name="country_region",
1107                                required=True,
1108                            ),
1109                            Footer(
1110                                label="Continue",
1111                                on_click_action=DataExchangeAction(
1112                                    payload={
1113                                        "name": name.ref,
1114                                        "address": address.ref,
1115                                        "city": city.ref,
1116                                        "zip_code": zip_code.ref,
1117                                        "country_region": country_region.ref,
1118                                    },
1119                                ),
1120                            ),
1121                        ],
1122                    )
1123                ],
1124            ),
1125        ),
1126        Screen(
1127            id="COVER",
1128            title="Your cover",
1129            data=[
1130                options := ScreenData(
1131                    key="options",
1132                    example=[
1133                        DataSource(
1134                            id="1",
1135                            title="Fire and theft",
1136                            description="Cover your home against incidents of theft or accidental fires",
1137                        ),
1138                        DataSource(
1139                            id="2",
1140                            title="Natural disaster",
1141                            description="Protect your home against disasters including earthquakes, floods and storms",
1142                        ),
1143                        DataSource(
1144                            id="3",
1145                            title="Liability",
1146                            description="Protect yourself from legal liabilities that occur from accidents on your property",
1147                        ),
1148                    ],
1149                ),
1150            ],
1151            layout=Layout(
1152                type=LayoutType.SINGLE_COLUMN,
1153                children=[
1154                    Form(
1155                        name="cover_form",
1156                        children=[
1157                            options_form := CheckboxGroup(
1158                                name="options",
1159                                data_source=options.ref,
1160                                label="Options",
1161                                required=True,
1162                            ),
1163                            Footer(
1164                                label="Continue",
1165                                on_click_action=DataExchangeAction(
1166                                    payload={"options": options_form.ref},
1167                                ),
1168                            ),
1169                        ],
1170                    )
1171                ],
1172            ),
1173        ),
1174        Screen(
1175            id="QUOTE",
1176            title="Your quote",
1177            terminal=True,
1178            data=[
1179                excess := ScreenData(
1180                    key="excess", example=[DataSource(id="1", title="$250")]
1181                ),
1182                total := ScreenData(key="total", example="$47.98 per month"),
1183            ],
1184            layout=Layout(
1185                type=LayoutType.SINGLE_COLUMN,
1186                children=[
1187                    Form(
1188                        name="quote_form",
1189                        children=[
1190                            Dropdown(
1191                                label="Excess",
1192                                name="excess",
1193                                data_source=excess.ref,
1194                                on_select_action=DataExchangeAction(
1195                                    payload={"excess": ComponentRef("excess")},
1196                                ),
1197                                required=True,
1198                            ),
1199                            RadioButtonsGroup(
1200                                name="payment_options",
1201                                label="Payment options",
1202                                data_source=[
1203                                    DataSource(id="1", title="Monthly"),
1204                                    DataSource(id="2", title="Annually (Save $115)"),
1205                                ],
1206                                on_select_action=DataExchangeAction(
1207                                    payload={
1208                                        "payment_options": ComponentRef(
1209                                            "payment_options"
1210                                        )
1211                                    },
1212                                ),
1213                                required=True,
1214                                init_value="1",
1215                            ),
1216                            TextHeading(text=total.ref),
1217                            privacy_policy := OptIn(
1218                                name="privacy_policy",
1219                                label="Accept our Privacy Policy",
1220                                required=True,
1221                                on_click_action=NavigateAction(
1222                                    next=Next(
1223                                        type=NextType.SCREEN,
1224                                        name="TERMS_AND_CONDITIONS",
1225                                    ),
1226                                ),
1227                            ),
1228                            Footer(
1229                                label="Choose quote",
1230                                on_click_action=DataExchangeAction(
1231                                    payload={
1232                                        "privacy_policy": privacy_policy.ref,
1233                                    },
1234                                ),
1235                            ),
1236                        ],
1237                    )
1238                ],
1239            ),
1240        ),
1241        Screen(
1242            id="TERMS_AND_CONDITIONS",
1243            title="Terms and conditions",
1244            data={},
1245            layout=Layout(
1246                type=LayoutType.SINGLE_COLUMN,
1247                children=[
1248                    TextHeading(text="Our Terms"),
1249                    TextSubheading(text="Data usage"),
1250                    TextBody(
1251                        text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
1252                    ),
1253                    TextSubheading(text="Privacy policy"),
1254                    TextBody(
1255                        text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
1256                    ),
1257                ],
1258            ),
1259        ),
1260    ],
1261)
JSON Code#
   1{
   2  "customer_satisfaction_survey": {
   3    "version": "2.1",
   4    "screens": [
   5      {
   6        "id": "RECOMMEND",
   7        "title": "Feedback 1 of 2",
   8        "data": {},
   9        "layout": {
  10          "type": "SingleColumnLayout",
  11          "children": [
  12            {
  13              "type": "Form",
  14              "name": "form",
  15              "children": [
  16                {
  17                  "type": "TextSubheading",
  18                  "text": "Would you recommend us to a friend?"
  19                },
  20                {
  21                  "type": "RadioButtonsGroup",
  22                  "label": "Choose one",
  23                  "name": "recommend_radio",
  24                  "data-source": [
  25                    {
  26                      "id": "0",
  27                      "title": "Yes"
  28                    },
  29                    {
  30                      "id": "1",
  31                      "title": "No"
  32                    }
  33                  ],
  34                  "required": true
  35                },
  36                {
  37                  "type": "TextSubheading",
  38                  "text": "How could we do better?"
  39                },
  40                {
  41                  "type": "TextArea",
  42                  "label": "Leave a comment",
  43                  "required": false,
  44                  "name": "comment_text"
  45                },
  46                {
  47                  "type": "Footer",
  48                  "label": "Continue",
  49                  "on-click-action": {
  50                    "name": "navigate",
  51                    "next": {
  52                      "type": "screen",
  53                      "name": "RATE"
  54                    },
  55                    "payload": {
  56                      "recommend_radio": "${form.recommend_radio}",
  57                      "comment_text": "${form.comment_text}"
  58                    }
  59                  }
  60                }
  61              ]
  62            }
  63          ]
  64        }
  65      },
  66      {
  67        "id": "RATE",
  68        "title": "Feedback 2 of 2",
  69        "data": {
  70          "recommend_radio": {
  71            "type": "string",
  72            "__example__": "Example"
  73          },
  74          "comment_text": {
  75            "type": "string",
  76            "__example__": "Example"
  77          }
  78        },
  79        "terminal": true,
  80        "layout": {
  81          "type": "SingleColumnLayout",
  82          "children": [
  83            {
  84              "type": "Form",
  85              "name": "form",
  86              "children": [
  87                {
  88                  "type": "TextSubheading",
  89                  "text": "Rate the following: "
  90                },
  91                {
  92                  "type": "Dropdown",
  93                  "label": "Purchase experience",
  94                  "required": true,
  95                  "name": "purchase_rating",
  96                  "data-source": [
  97                    {
  98                      "id": "0",
  99                      "title": "★★★★★ • Excellent (5/5)"
 100                    },
 101                    {
 102                      "id": "1",
 103                      "title": "★★★★☆ • Good (4/5)"
 104                    },
 105                    {
 106                      "id": "2",
 107                      "title": "★★★☆☆ • Average (3/5)"
 108                    },
 109                    {
 110                      "id": "3",
 111                      "title": "★★☆☆☆ • Poor (2/5)"
 112                    },
 113                    {
 114                      "id": "4",
 115                      "title": "★☆☆☆☆ • Very Poor (1/5)"
 116                    }
 117                  ]
 118                },
 119                {
 120                  "type": "Dropdown",
 121                  "label": "Delivery and setup",
 122                  "required": true,
 123                  "name": "delivery_rating",
 124                  "data-source": [
 125                    {
 126                      "id": "0",
 127                      "title": "★★★★★ • Excellent (5/5)"
 128                    },
 129                    {
 130                      "id": "1",
 131                      "title": "★★★★☆ • Good (4/5)"
 132                    },
 133                    {
 134                      "id": "2",
 135                      "title": "★★★☆☆ • Average (3/5)"
 136                    },
 137                    {
 138                      "id": "3",
 139                      "title": "★★☆☆☆ • Poor (2/5)"
 140                    },
 141                    {
 142                      "id": "4",
 143                      "title": "★☆☆☆☆ • Very Poor (1/5)"
 144                    }
 145                  ]
 146                },
 147                {
 148                  "type": "Dropdown",
 149                  "label": "Customer service",
 150                  "required": true,
 151                  "name": "cs_rating",
 152                  "data-source": [
 153                    {
 154                      "id": "0",
 155                      "title": "★★★★★ • Excellent (5/5)"
 156                    },
 157                    {
 158                      "id": "1",
 159                      "title": "★★★★☆ • Good (4/5)"
 160                    },
 161                    {
 162                      "id": "2",
 163                      "title": "★★★☆☆ • Average (3/5)"
 164                    },
 165                    {
 166                      "id": "3",
 167                      "title": "★★☆☆☆ • Poor (2/5)"
 168                    },
 169                    {
 170                      "id": "4",
 171                      "title": "★☆☆☆☆ • Very Poor (1/5)"
 172                    }
 173                  ]
 174                },
 175                {
 176                  "type": "Footer",
 177                  "label": "Done",
 178                  "on-click-action": {
 179                    "name": "complete",
 180                    "payload": {
 181                      "purchase_rating": "${form.purchase_rating}",
 182                      "delivery_rating": "${form.delivery_rating}",
 183                      "cs_rating": "${form.cs_rating}",
 184                      "recommend_radio": "${data.recommend_radio}",
 185                      "comment_text": "${data.comment_text}"
 186                    }
 187                  }
 188                }
 189              ]
 190            }
 191          ]
 192        }
 193      }
 194    ]
 195  },
 196  "load_re_engagement": {
 197    "version": "2.1",
 198    "screens": [
 199      {
 200        "id": "SIGN_UP",
 201        "layout": {
 202          "type": "SingleColumnLayout",
 203          "children": [
 204            {
 205              "type": "Form",
 206              "name": "form",
 207              "children": [
 208                {
 209                  "type": "TextInput",
 210                  "name": "firstName",
 211                  "label": "First Name",
 212                  "input-type": "text",
 213                  "required": true,
 214                  "visible": true
 215                },
 216                {
 217                  "type": "TextInput",
 218                  "name": "lastName",
 219                  "label": "Last Name",
 220                  "input-type": "text",
 221                  "required": true,
 222                  "visible": true
 223                },
 224                {
 225                  "type": "TextInput",
 226                  "name": "email",
 227                  "label": "Email Address",
 228                  "input-type": "email",
 229                  "required": true,
 230                  "visible": true
 231                },
 232                {
 233                  "type": "Footer",
 234                  "label": "Done",
 235                  "on-click-action": {
 236                    "name": "complete",
 237                    "payload": {
 238                      "firstName": "${form.firstName}",
 239                      "lastName": "${form.lastName}",
 240                      "email": "${form.email}"
 241                    }
 242                  },
 243                  "enabled": true
 244                }
 245              ]
 246            }
 247          ]
 248        },
 249        "terminal": true,
 250        "data": {},
 251        "title": "Finish Sign Up"
 252      }
 253    ]
 254  },
 255  "costumer_engagement": {
 256    "version": "2.1",
 257    "screens": [
 258      {
 259        "id": "QUESTION_ONE",
 260        "title": "Question 1 of 3",
 261        "data": {},
 262        "layout": {
 263          "type": "SingleColumnLayout",
 264          "children": [
 265            {
 266              "type": "Form",
 267              "name": "form",
 268              "children": [
 269                {
 270                  "type": "TextHeading",
 271                  "text": "You've found the perfect deal, what do you do next?"
 272                },
 273                {
 274                  "type": "CheckboxGroup",
 275                  "label": "Choose all that apply:",
 276                  "required": true,
 277                  "name": "question1Checkbox",
 278                  "data-source": [
 279                    {
 280                      "id": "0",
 281                      "title": "Buy it right away"
 282                    },
 283                    {
 284                      "id": "1",
 285                      "title": "Check reviews before buying"
 286                    },
 287                    {
 288                      "id": "2",
 289                      "title": "Share it with friends + family"
 290                    },
 291                    {
 292                      "id": "3",
 293                      "title": "Buy multiple, while its cheap"
 294                    },
 295                    {
 296                      "id": "4",
 297                      "title": "None of the above"
 298                    }
 299                  ]
 300                },
 301                {
 302                  "type": "Footer",
 303                  "label": "Continue",
 304                  "on-click-action": {
 305                    "name": "navigate",
 306                    "next": {
 307                      "type": "screen",
 308                      "name": "QUESTION_TWO"
 309                    },
 310                    "payload": {
 311                      "question1Checkbox": "${form.question1Checkbox}"
 312                    }
 313                  }
 314                }
 315              ]
 316            }
 317          ]
 318        }
 319      },
 320      {
 321        "id": "QUESTION_TWO",
 322        "title": "Question 2 of 3",
 323        "data": {
 324          "question1Checkbox": {
 325            "type": "array",
 326            "items": {
 327              "type": "string"
 328            },
 329            "__example__": ["Example", "Example2"]
 330          }
 331        },
 332        "layout": {
 333          "type": "SingleColumnLayout",
 334          "children": [
 335            {
 336              "type": "Form",
 337              "name": "form",
 338              "children": [
 339                {
 340                  "type": "TextHeading",
 341                  "text": "Its your birthday in two weeks, how might you prepare?"
 342                },
 343                {
 344                  "type": "RadioButtonsGroup",
 345                  "label": "Choose all that apply:",
 346                  "required": true,
 347                  "name": "question2RadioButtons",
 348                  "data-source": [
 349                    {
 350                      "id": "0",
 351                      "title": "Buy something new"
 352                    },
 353                    {
 354                      "id": "1",
 355                      "title": "Wear the same, as usual"
 356                    },
 357                    {
 358                      "id": "2",
 359                      "title": "Look for a deal online"
 360                    }
 361                  ]
 362                },
 363                {
 364                  "type": "Footer",
 365                  "label": "Continue",
 366                  "on-click-action": {
 367                    "name": "navigate",
 368                    "next": {
 369                      "type": "screen",
 370                      "name": "QUESTION_THREE"
 371                    },
 372                    "payload": {
 373                      "question2RadioButtons": "${form.question2RadioButtons}",
 374                      "question1Checkbox": "${data.question1Checkbox}"
 375                    }
 376                  }
 377                }
 378              ]
 379            }
 380          ]
 381        }
 382      },
 383      {
 384        "id": "QUESTION_THREE",
 385        "title": "Question 3 of 3",
 386        "data": {
 387          "question2RadioButtons": {
 388            "type": "string",
 389            "__example__": "Example"
 390          },
 391          "question1Checkbox": {
 392            "type": "array",
 393            "items": {
 394              "type": "string"
 395            },
 396            "__example__": ["Example", "Example2"]
 397          }
 398        },
 399        "terminal": true,
 400        "layout": {
 401          "type": "SingleColumnLayout",
 402          "children": [
 403            {
 404              "type": "Form",
 405              "name": "form",
 406              "children": [
 407                {
 408                  "type": "TextHeading",
 409                  "text": "What's the best gift for a friend?"
 410                },
 411                {
 412                  "type": "CheckboxGroup",
 413                  "label": "Choose all that apply:",
 414                  "required": true,
 415                  "name": "question3Checkbox",
 416                  "data-source": [
 417                    {
 418                      "id": "0",
 419                      "title": "A gift voucher"
 420                    },
 421                    {
 422                      "id": "1",
 423                      "title": "A new outfit "
 424                    },
 425                    {
 426                      "id": "2",
 427                      "title": "A bouquet of flowers"
 428                    },
 429                    {
 430                      "id": "3",
 431                      "title": "A meal out together"
 432                    }
 433                  ]
 434                },
 435                {
 436                  "type": "Footer",
 437                  "label": "Done",
 438                  "on-click-action": {
 439                    "name": "complete",
 440                    "payload": {
 441                      "question1Checkbox": "${data.question1Checkbox}",
 442                      "question2RadioButtons": "${data.question2RadioButtons}",
 443                      "question3Checkbox": "${form.question3Checkbox}"
 444                    }
 445                  }
 446                }
 447              ]
 448            }
 449          ]
 450        }
 451      }
 452    ]
 453  },
 454  "support_request": {
 455    "version": "2.1",
 456    "screens": [
 457      {
 458        "id": "DETAILS",
 459        "title": "Get help",
 460        "data": {},
 461        "terminal": true,
 462        "layout": {
 463          "type": "SingleColumnLayout",
 464          "children": [
 465            {
 466              "type": "Form",
 467              "name": "form",
 468              "children": [
 469                {
 470                  "type": "TextInput",
 471                  "name": "name",
 472                  "label": "Name",
 473                  "input-type": "text",
 474                  "required": true
 475                },
 476                {
 477                  "type": "TextInput",
 478                  "label": "Order number",
 479                  "name": "orderNumber",
 480                  "input-type": "number",
 481                  "required": true,
 482                  "helper-text": ""
 483                },
 484                {
 485                  "type": "RadioButtonsGroup",
 486                  "label": "Choose a topic",
 487                  "name": "topicRadio",
 488                  "data-source": [
 489                    {
 490                      "id": "0",
 491                      "title": "Orders and payments"
 492                    },
 493                    {
 494                      "id": "1",
 495                      "title": "Maintenance"
 496                    },
 497                    {
 498                      "id": "2",
 499                      "title": "Delivery"
 500                    },
 501                    {
 502                      "id": "3",
 503                      "title": "Returns"
 504                    },
 505                    {
 506                      "id": "4",
 507                      "title": "Other"
 508                    }
 509                  ],
 510                  "required": true
 511                },
 512                {
 513                  "type": "TextArea",
 514                  "label": "Description of issue",
 515                  "required": false,
 516                  "name": "description"
 517                },
 518                {
 519                  "type": "Footer",
 520                  "label": "Done",
 521                  "on-click-action": {
 522                    "name": "complete",
 523                    "payload": {
 524                      "name": "${form.name}",
 525                      "orderNumber": "${form.orderNumber}",
 526                      "topicRadio": "${form.topicRadio}",
 527                      "description": "${form.description}"
 528                    }
 529                  }
 530                }
 531              ]
 532            }
 533          ]
 534        }
 535      }
 536    ]
 537  },
 538  "communication_preferences": {
 539    "version": "2.1",
 540    "screens": [
 541      {
 542        "id": "PREFERENCES",
 543        "title": "Update Preferences",
 544        "data": {},
 545        "terminal": true,
 546        "layout": {
 547          "type": "SingleColumnLayout",
 548          "children": [
 549            {
 550              "type": "Form",
 551              "name": "form",
 552              "children": [
 553                {
 554                  "type": "CheckboxGroup",
 555                  "label": "Communication types",
 556                  "required": true,
 557                  "name": "communicationTypes",
 558                  "data-source": [
 559                    {
 560                      "id": "0",
 561                      "title": "Special offers and promotions"
 562                    },
 563                    {
 564                      "id": "1",
 565                      "title": "Changes to my subscription"
 566                    },
 567                    {
 568                      "id": "2",
 569                      "title": "News and events"
 570                    },
 571                    {
 572                      "id": "3",
 573                      "title": "New products"
 574                    }
 575                  ]
 576                },
 577                {
 578                  "type": "CheckboxGroup",
 579                  "label": "Contact Preferences",
 580                  "required": false,
 581                  "name": "contactPrefs",
 582                  "data-source": [
 583                    {
 584                      "id": "0",
 585                      "title": "Whatsapp"
 586                    },
 587                    {
 588                      "id": "1",
 589                      "title": "Email"
 590                    },
 591                    {
 592                      "id": "2",
 593                      "title": "SMS"
 594                    }
 595                  ]
 596                },
 597                {
 598                  "type": "Footer",
 599                  "label": "Done",
 600                  "on-click-action": {
 601                    "name": "complete",
 602                    "payload": {
 603                      "communicationTypes": "${form.communicationTypes}",
 604                      "contactPrefs": "${form.contactPrefs}"
 605                    }
 606                  }
 607                }
 608              ]
 609            }
 610          ]
 611        }
 612      }
 613    ]
 614  },
 615  "register_for_an_event": {
 616    "version": "2.1",
 617    "screens": [
 618      {
 619        "id": "SIGN_UP",
 620        "title": "Sign Up",
 621        "data": {},
 622        "layout": {
 623          "type": "SingleColumnLayout",
 624          "children": [
 625            {
 626              "type": "Form",
 627              "name": "form",
 628              "children": [
 629                {
 630                  "type": "TextHeading",
 631                  "text": "Join our next webinar!"
 632                },
 633                {
 634                  "type": "TextBody",
 635                  "text": "First, we'll need a few details from you."
 636                },
 637                {
 638                  "type": "TextInput",
 639                  "name": "firstName",
 640                  "label": "First Name",
 641                  "input-type": "text",
 642                  "required": true
 643                },
 644                {
 645                  "type": "TextInput",
 646                  "label": "Last Name",
 647                  "name": "lastName",
 648                  "input-type": "text",
 649                  "required": true
 650                },
 651                {
 652                  "type": "TextInput",
 653                  "label": "Email Address",
 654                  "name": "email",
 655                  "input-type": "email",
 656                  "required": true
 657                },
 658                {
 659                  "type": "Footer",
 660                  "label": "Continue",
 661                  "on-click-action": {
 662                    "name": "navigate",
 663                    "next": {
 664                      "type": "screen",
 665                      "name": "SURVEY"
 666                    },
 667                    "payload": {
 668                      "firstName": "${form.firstName}",
 669                      "lastName": "${form.lastName}",
 670                      "email": "${form.email}"
 671                    }
 672                  }
 673                }
 674              ]
 675            }
 676          ]
 677        }
 678      },
 679      {
 680        "id": "SURVEY",
 681        "title": "Thank you",
 682        "data": {
 683          "firstName": {
 684            "type": "string",
 685            "__example__": "Example"
 686          },
 687          "lastName": {
 688            "type": "string",
 689            "__example__": "Example"
 690          },
 691          "email": {
 692            "type": "string",
 693            "__example__": "Example"
 694          }
 695        },
 696        "terminal": true,
 697        "layout": {
 698          "type": "SingleColumnLayout",
 699          "children": [
 700            {
 701              "type": "Form",
 702              "name": "form",
 703              "children": [
 704                {
 705                  "type": "TextHeading",
 706                  "text": "Before you go"
 707                },
 708                {
 709                  "type": "TextBody",
 710                  "text": "How did you hear about us?"
 711                },
 712                {
 713                  "type": "RadioButtonsGroup",
 714                  "label": "Choose one",
 715                  "required": false,
 716                  "name": "source",
 717                  "data-source": [
 718                    {
 719                      "id": "0",
 720                      "title": "Friend's recommendation"
 721                    },
 722                    {
 723                      "id": "1",
 724                      "title": "TV advertisement"
 725                    },
 726                    {
 727                      "id": "2",
 728                      "title": "Search engine"
 729                    },
 730                    {
 731                      "id": "3",
 732                      "title": "Social media"
 733                    }
 734                  ]
 735                },
 736                {
 737                  "type": "Footer",
 738                  "label": "Done",
 739                  "on-click-action": {
 740                    "name": "complete",
 741                    "payload": {
 742                      "source": "${form.source}",
 743                      "firstName": "${data.firstName}",
 744                      "lastName": "${data.lastName}",
 745                      "email": "${data.email}"
 746                    }
 747                  }
 748                }
 749              ]
 750            }
 751          ]
 752        }
 753      }
 754    ]
 755  },
 756  "sign_in": {
 757    "version": "2.1",
 758    "data_api_version": "3.0",
 759    "data_channel_uri": "https://example.com",
 760    "routing_model": {
 761      "SIGN_IN": [
 762        "SIGN_UP",
 763        "FORGOT_PASSWORD"
 764      ],
 765      "SIGN_UP": [
 766        "TERMS_AND_CONDITIONS"
 767      ],
 768      "FORGOT_PASSWORD": [],
 769      "TERMS_AND_CONDITIONS": []
 770    },
 771    "screens": [
 772      {
 773        "id": "SIGN_IN",
 774        "title": "Sign in",
 775        "terminal": true,
 776        "data": {},
 777        "layout": {
 778          "type": "SingleColumnLayout",
 779          "children": [
 780            {
 781              "type": "Form",
 782              "name": "sign_in_form",
 783              "children": [
 784                {
 785                  "type": "TextInput",
 786                  "required": true,
 787                  "label": "Email address",
 788                  "name": "email",
 789                  "input-type": "email"
 790                },
 791                {
 792                  "type": "TextInput",
 793                  "required": true,
 794                  "label": "Password",
 795                  "name": "password",
 796                  "input-type": "password"
 797                },
 798                {
 799                  "type": "EmbeddedLink",
 800                  "text": "Don't have an account? Sign up",
 801                  "on-click-action": {
 802                    "name": "navigate",
 803                    "next": {
 804                      "type": "screen",
 805                      "name": "SIGN_UP"
 806                    },
 807                    "payload": {}
 808                  }
 809                },
 810                {
 811                  "type": "EmbeddedLink",
 812                  "text": "Forgot password",
 813                  "on-click-action": {
 814                    "name": "navigate",
 815                    "next": {
 816                      "type": "screen",
 817                      "name": "FORGOT_PASSWORD"
 818                    },
 819                    "payload": {
 820                      "body": "Example"
 821                    }
 822                  }
 823                },
 824                {
 825                  "type": "Footer",
 826                  "label": "Sign in",
 827                  "on-click-action": {
 828                    "name": "data_exchange",
 829                    "payload": {
 830                      "email": "${form.email}",
 831                      "password": "${form.password}"
 832                    }
 833                  }
 834                }
 835              ]
 836            }
 837          ]
 838        }
 839      },
 840      {
 841        "id": "SIGN_UP",
 842        "title": "Sign up",
 843        "data": {},
 844        "layout": {
 845          "type": "SingleColumnLayout",
 846          "children": [
 847            {
 848              "type": "Form",
 849              "name": "sign_up_form",
 850              "children": [
 851                {
 852                  "type": "TextInput",
 853                  "required": true,
 854                  "label": "First Name",
 855                  "name": "first_name",
 856                  "input-type": "text"
 857                },
 858                {
 859                  "type": "TextInput",
 860                  "required": true,
 861                  "label": "Last Name",
 862                  "name": "last_name",
 863                  "input-type": "text"
 864                },
 865                {
 866                  "type": "TextInput",
 867                  "required": true,
 868                  "label": "Email address",
 869                  "name": "email",
 870                  "input-type": "email"
 871                },
 872                {
 873                  "type": "TextInput",
 874                  "required": true,
 875                  "label": "Set password",
 876                  "name": "password",
 877                  "input-type": "password"
 878                },
 879                {
 880                  "type": "TextInput",
 881                  "required": true,
 882                  "label": "Confirm password",
 883                  "name": "confirm_password",
 884                  "input-type": "password"
 885                },
 886                {
 887                  "type": "OptIn",
 888                  "name": "terms_agreement",
 889                  "label": "I agree with the terms.",
 890                  "required": true,
 891                  "on-click-action": {
 892                    "name": "navigate",
 893                    "next": {
 894                      "type": "screen",
 895                      "name": "TERMS_AND_CONDITIONS"
 896                    },
 897                    "payload": {}
 898                  }
 899                },
 900                {
 901                  "type": "OptIn",
 902                  "name": "offers_acceptance",
 903                  "label": "I would like to receive news and offers."
 904                },
 905                {
 906                  "type": "Footer",
 907                  "label": "Continue",
 908                  "on-click-action": {
 909                    "name": "data_exchange",
 910                    "payload": {
 911                      "first_name": "${form.first_name}",
 912                      "last_name": "${form.last_name}",
 913                      "email": "${form.email}",
 914                      "password": "${form.password}",
 915                      "confirm_password": "${form.confirm_password}",
 916                      "terms_agreement": "${form.terms_agreement}",
 917                      "offers_acceptance": "${form.offers_acceptance}"
 918                    }
 919                  }
 920                }
 921              ]
 922            }
 923          ]
 924        }
 925      },
 926      {
 927        "id": "FORGOT_PASSWORD",
 928        "title": "Forgot password",
 929        "terminal": true,
 930        "data": {
 931          "body": {
 932            "type": "string",
 933            "__example__": "Enter your email address for your account and we'll send a reset link. The single-use link will expire after 24 hours."
 934          }
 935        },
 936        "layout": {
 937          "type": "SingleColumnLayout",
 938          "children": [
 939            {
 940              "type": "Form",
 941              "name": "forgot_password_form",
 942              "children": [
 943                {
 944                  "type": "TextBody",
 945                  "text": "${data.body}"
 946                },
 947                {
 948                  "type": "TextInput",
 949                  "required": true,
 950                  "label": "Email address",
 951                  "name": "email",
 952                  "input-type": "email"
 953                },
 954                {
 955                  "type": "Footer",
 956                  "label": "Sign in",
 957                  "on-click-action": {
 958                    "name": "data_exchange",
 959                    "payload": {
 960                      "email": "${form.email}"
 961                    }
 962                  }
 963                }
 964              ]
 965            }
 966          ]
 967        }
 968      },
 969      {
 970        "id": "TERMS_AND_CONDITIONS",
 971        "title": "Terms and conditions",
 972        "data": {},
 973        "layout": {
 974          "type": "SingleColumnLayout",
 975          "children": [
 976            {
 977              "type": "TextHeading",
 978              "text": "Our Terms"
 979            },
 980            {
 981              "type": "TextSubheading",
 982              "text": "Data usage"
 983            },
 984            {
 985              "type": "TextBody",
 986              "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
 987            },
 988            {
 989              "type": "TextSubheading",
 990              "text": "Privacy policy"
 991            },
 992            {
 993              "type": "TextBody",
 994              "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
 995            }
 996          ]
 997        }
 998      }
 999    ]
1000  },
1001  "register": {
1002    "version": "2.1",
1003    "data_api_version": "3.0",
1004    "data_channel_uri": "https://example.com",
1005    "routing_model": {
1006      "REGISTER": [
1007        "TERMS_AND_CONDITIONS"
1008      ],
1009      "TERMS_AND_CONDITIONS": []
1010    },
1011    "screens": [
1012      {
1013        "id": "REGISTER",
1014        "title": "Register for an account",
1015        "terminal": true,
1016        "data": {
1017          "error_messages": {
1018            "type": "object",
1019            "properties": {
1020              "confirm_password": {
1021                "type": "string"
1022              }
1023            },
1024            "__example__": {
1025              "confirm_password": "Passwords don't match."
1026            }
1027          }
1028        },
1029        "layout": {
1030          "type": "SingleColumnLayout",
1031          "children": [
1032            {
1033              "type": "Form",
1034              "name": "register_form",
1035              "error-messages": "${data.error_messages}",
1036              "children": [
1037                {
1038                  "type": "TextInput",
1039                  "required": true,
1040                  "label": "First name",
1041                  "name": "first_name",
1042                  "input-type": "text"
1043                },
1044                {
1045                  "type": "TextInput",
1046                  "required": true,
1047                  "label": "Last name",
1048                  "name": "last_name",
1049                  "input-type": "text"
1050                },
1051                {
1052                  "type": "TextInput",
1053                  "required": true,
1054                  "label": "Email address",
1055                  "name": "email",
1056                  "input-type": "email"
1057                },
1058                {
1059                  "type": "TextInput",
1060                  "required": true,
1061                  "label": "Set password",
1062                  "name": "password",
1063                  "input-type": "password"
1064                },
1065                {
1066                  "type": "TextInput",
1067                  "required": true,
1068                  "label": "Confirm password",
1069                  "name": "confirm_password",
1070                  "input-type": "password"
1071                },
1072                {
1073                  "type": "OptIn",
1074                  "name": "terms_agreement",
1075                  "label": "I agree with the terms.",
1076                  "required": true,
1077                  "on-click-action": {
1078                    "name": "navigate",
1079                    "next": {
1080                      "type": "screen",
1081                      "name": "TERMS_AND_CONDITIONS"
1082                    },
1083                    "payload": {}
1084                  }
1085                },
1086                {
1087                  "type": "OptIn",
1088                  "name": "offers_acceptance",
1089                  "label": "I would like to receive news and offers."
1090                },
1091                {
1092                  "type": "Footer",
1093                  "label": "Continue",
1094                  "on-click-action": {
1095                    "name": "data_exchange",
1096                    "payload": {
1097                      "first_name": "${form.first_name}",
1098                      "last_name": "${form.last_name}",
1099                      "email": "${form.email}",
1100                      "password": "${form.password}",
1101                      "confirm_password": "${form.confirm_password}",
1102                      "terms_agreement": "${form.terms_agreement}",
1103                      "offers_acceptance": "${form.offers_acceptance}"
1104                    }
1105                  }
1106                }
1107              ]
1108            }
1109          ]
1110        }
1111      },
1112      {
1113        "id": "TERMS_AND_CONDITIONS",
1114        "title": "Terms and conditions",
1115        "data": {},
1116        "layout": {
1117          "type": "SingleColumnLayout",
1118          "children": [
1119            {
1120              "type": "TextHeading",
1121              "text": "Our Terms"
1122            },
1123            {
1124              "type": "TextSubheading",
1125              "text": "Data usage"
1126            },
1127            {
1128              "type": "TextBody",
1129              "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
1130            },
1131            {
1132              "type": "TextSubheading",
1133              "text": "Privacy policy"
1134            },
1135            {
1136              "type": "TextBody",
1137              "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
1138            }
1139          ]
1140        }
1141      }
1142    ]
1143  },
1144  "book_a_table": {
1145    "version": "2.1",
1146    "data_api_version": "3.0",
1147    "data_channel_uri": "https://example.com",
1148    "routing_model": {
1149      "BOOK_TABLE": [
1150        "BOOKING_DETAILS"
1151      ],
1152      "BOOKING_DETAILS": [
1153        "BOOKING_CONFIRMATION"
1154      ],
1155      "BOOKING_CONFIRMATION": [
1156        "TERMS_AND_CONDITIONS"
1157      ],
1158      "TERMS_AND_CONDITIONS": []
1159    },
1160    "screens": [
1161      {
1162        "id": "BOOK_TABLE",
1163        "title": "Book a table",
1164        "data": {
1165          "min_date": {
1166            "type": "string",
1167            "__example__": "1696892400000"
1168          },
1169          "max_date": {
1170            "type": "string",
1171            "__example__": "1760050800000"
1172          },
1173          "unavailable_dates": {
1174            "type": "array",
1175            "items": {
1176              "type": "string"
1177            },
1178            "__example__": [
1179              "1760310000000"
1180            ]
1181          },
1182          "time": {
1183            "type": "array",
1184            "items": {
1185              "type": "object",
1186              "properties": {
1187                "id": {
1188                  "type": "string"
1189                },
1190                "title": {
1191                  "type": "string"
1192                }
1193              }
1194            },
1195            "__example__": [
1196              {
1197                "id": "1",
1198                "title": "12:30"
1199              },
1200              {
1201                "id": "2",
1202                "title": "13:30"
1203              },
1204              {
1205                "id": "3",
1206                "title": "18:30"
1207              },
1208              {
1209                "id": "4",
1210                "title": "19:30"
1211              },
1212              {
1213                "id": "5",
1214                "title": "20:30"
1215              }
1216            ]
1217          },
1218          "people": {
1219            "type": "array",
1220            "items": {
1221              "type": "object",
1222              "properties": {
1223                "id": {
1224                  "type": "string"
1225                },
1226                "title": {
1227                  "type": "string"
1228                }
1229              }
1230            },
1231            "__example__": [
1232              {
1233                "id": "1",
1234                "title": "1"
1235              },
1236              {
1237                "id": "2",
1238                "title": "2"
1239              },
1240              {
1241                "id": "3",
1242                "title": "3"
1243              },
1244              {
1245                "id": "4",
1246                "title": "4"
1247              },
1248              {
1249                "id": "5",
1250                "title": "5"
1251              },
1252              {
1253                "id": "6",
1254                "title": "6"
1255              },
1256              {
1257                "id": "7+",
1258                "title": "7+"
1259              }
1260            ]
1261          },
1262          "location": {
1263            "type": "array",
1264            "items": {
1265              "type": "object",
1266              "properties": {
1267                "id": {
1268                  "type": "string"
1269                },
1270                "title": {
1271                  "type": "string"
1272                }
1273              }
1274            },
1275            "__example__": [
1276              {
1277                "id": "1",
1278                "title": "Shorty Heights, Light City, 59923"
1279              }
1280            ]
1281          }
1282        },
1283        "layout": {
1284          "type": "SingleColumnLayout",
1285          "children": [
1286            {
1287              "type": "Form",
1288              "name": "book_table_form",
1289              "children": [
1290                {
1291                  "type": "Dropdown",
1292                  "label": "Location",
1293                  "name": "location",
1294                  "data-source": "${data.location}",
1295                  "required": true,
1296                  "on-select-action": {
1297                    "name": "data_exchange",
1298                    "payload": {
1299                      "location": "${form.location}"
1300                    }
1301                  }
1302                },
1303                {
1304                  "type": "Dropdown",
1305                  "label": "People",
1306                  "name": "people",
1307                  "data-source": "${data.people}",
1308                  "required": true,
1309                  "on-select-action": {
1310                    "name": "data_exchange",
1311                    "payload": {
1312                      "people": "${form.people}"
1313                    }
1314                  }
1315                },
1316                {
1317                  "type": "DatePicker",
1318                  "name": "date",
1319                  "label": "Date",
1320                  "min-date": "${data.min_date}",
1321                  "max-date": "${data.max_date}",
1322                  "unavailable-dates": "${data.unavailable_dates}",
1323                  "required": true,
1324                  "on-select-action": {
1325                    "name": "data_exchange",
1326                    "payload": {
1327                      "date": "${form.date}"
1328                    }
1329                  }
1330                },
1331                {
1332                  "type": "Dropdown",
1333                  "label": "Time",
1334                  "name": "time",
1335                  "data-source": "${data.time}",
1336                  "required": true
1337                },
1338                {
1339                  "type": "Footer",
1340                  "label": "Continue",
1341                  "on-click-action": {
1342                    "name": "navigate",
1343                    "next": {
1344                      "type": "screen",
1345                      "name": "BOOKING_DETAILS"
1346                    },
1347                    "payload": {}
1348                  }
1349                }
1350              ]
1351            }
1352          ]
1353        }
1354      },
1355      {
1356        "id": "BOOKING_DETAILS",
1357        "title": "Booking details",
1358        "data": {},
1359        "layout": {
1360          "type": "SingleColumnLayout",
1361          "children": [
1362            {
1363              "type": "Form",
1364              "name": "booking_details_form",
1365              "children": [
1366                {
1367                  "type": "TextInput",
1368                  "label": "Name",
1369                  "name": "name",
1370                  "required": true
1371                },
1372                {
1373                  "type": "Dropdown",
1374                  "label": "Special occasion",
1375                  "name": "special_occasion",
1376                  "data-source": [
1377                    {
1378                      "id": "1",
1379                      "title": "Birthday"
1380                    },
1381                    {
1382                      "id": "2",
1383                      "title": "Anniversary"
1384                    },
1385                    {
1386                      "id": "3",
1387                      "title": "Engagement"
1388                    },
1389                    {
1390                      "id": "4",
1391                      "title": "Graduation"
1392                    },
1393                    {
1394                      "id": "5",
1395                      "title": "Other"
1396                    }
1397                  ],
1398                  "required": false
1399                },
1400                {
1401                  "type": "TextArea",
1402                  "label": "Requirements",
1403                  "name": "requirements",
1404                  "helper-text": "e.g. Dietary or accessibility",
1405                  "required": false
1406                },
1407                {
1408                  "type": "Footer",
1409                  "label": "Continue",
1410                  "on-click-action": {
1411                    "name": "data_exchange",
1412                    "payload": {
1413                      "name": "${form.name}",
1414                      "special_occasion": "${form.special_occasion}",
1415                      "requirements": "${form.requirements}"
1416                    }
1417                  }
1418                }
1419              ]
1420            }
1421          ]
1422        }
1423      },
1424      {
1425        "id": "BOOKING_CONFIRMATION",
1426        "title": "Booking confirmation",
1427        "terminal": true,
1428        "data": {
1429          "date": {
1430            "type": "string",
1431            "__example__": "Date: Saturday, June 7 2023"
1432          },
1433          "time": {
1434            "type": "string",
1435            "__example__": "Time: 19:30"
1436          },
1437          "people": {
1438            "type": "string",
1439            "__example__": "People: 4"
1440          },
1441          "location": {
1442            "type": "string",
1443            "__example__": "Location: Shorty Heights, Light City, 59923"
1444          },
1445          "name": {
1446            "type": "string",
1447            "__example__": "Name: John Doe"
1448          },
1449          "special_occasion": {
1450            "type": "string",
1451            "__example__": "Special Occasion: Birthday"
1452          }
1453        },
1454        "layout": {
1455          "type": "SingleColumnLayout",
1456          "children": [
1457            {
1458              "type": "Form",
1459              "name": "confirmation_form",
1460              "children": [
1461                {
1462                  "type": "TextBody",
1463                  "text": "${data.date}"
1464                },
1465                {
1466                  "type": "TextBody",
1467                  "text": "${data.time}"
1468                },
1469                {
1470                  "type": "TextBody",
1471                  "text": "${data.people}"
1472                },
1473                {
1474                  "type": "TextBody",
1475                  "text": "${data.location}"
1476                },
1477                {
1478                  "type": "TextBody",
1479                  "text": "${data.name}"
1480                },
1481                {
1482                  "type": "TextBody",
1483                  "text": "${data.special_occasion}"
1484                },
1485                {
1486                  "type": "OptIn",
1487                  "name": "privacy_policy",
1488                  "label": "Accept our Privacy Policy",
1489                  "required": true,
1490                  "on-click-action": {
1491                    "name": "navigate",
1492                    "next": {
1493                      "type": "screen",
1494                      "name": "TERMS_AND_CONDITIONS"
1495                    },
1496                    "payload": {}
1497                  }
1498                },
1499                {
1500                  "type": "Footer",
1501                  "label": "Confirm booking",
1502                  "on-click-action": {
1503                    "name": "data_exchange",
1504                    "payload": {}
1505                  }
1506                }
1507              ]
1508            }
1509          ]
1510        }
1511      },
1512      {
1513        "id": "TERMS_AND_CONDITIONS",
1514        "title": "Terms and conditions",
1515        "data": {},
1516        "layout": {
1517          "type": "SingleColumnLayout",
1518          "children": [
1519            {
1520              "type": "TextHeading",
1521              "text": "Our Terms"
1522            },
1523            {
1524              "type": "TextSubheading",
1525              "text": "Data usage"
1526            },
1527            {
1528              "type": "TextBody",
1529              "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
1530            },
1531            {
1532              "type": "TextSubheading",
1533              "text": "Privacy policy"
1534            },
1535            {
1536              "type": "TextBody",
1537              "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
1538            }
1539          ]
1540        }
1541      }
1542    ]
1543  },
1544  "get_a_quote": {
1545    "version": "2.1",
1546    "data_api_version": "3.0",
1547    "data_channel_uri": "https://example.com",
1548    "routing_model": {
1549      "DETAILS": [
1550        "COVER"
1551      ],
1552      "COVER": [
1553        "QUOTE"
1554      ],
1555      "QUOTE": [
1556        "TERMS_AND_CONDITIONS"
1557      ],
1558      "TERMS_AND_CONDITIONS": []
1559    },
1560    "screens": [
1561      {
1562        "id": "DETAILS",
1563        "title": "Your details",
1564        "data": {
1565          "city": {
1566            "type": "array",
1567            "items": {
1568              "type": "object",
1569              "properties": {
1570                "id": {
1571                  "type": "string"
1572                },
1573                "title": {
1574                  "type": "string"
1575                }
1576              }
1577            },
1578            "__example__": [
1579              {
1580                "id": "1",
1581                "title": "Light City, SO"
1582              }
1583            ]
1584          }
1585        },
1586        "layout": {
1587          "type": "SingleColumnLayout",
1588          "children": [
1589            {
1590              "type": "Form",
1591              "name": "details_form",
1592              "children": [
1593                {
1594                  "type": "TextInput",
1595                  "label": "Your name",
1596                  "input-type": "text",
1597                  "name": "name",
1598                  "required": true
1599                },
1600                {
1601                  "type": "TextInput",
1602                  "label": "Street address",
1603                  "input-type": "text",
1604                  "name": "address",
1605                  "required": true
1606                },
1607                {
1608                  "type": "Dropdown",
1609                  "label": "City, State",
1610                  "name": "city",
1611                  "data-source": "${data.city}",
1612                  "required": true
1613                },
1614                {
1615                  "type": "TextInput",
1616                  "label": "Zip code",
1617                  "input-type": "text",
1618                  "name": "zip_code",
1619                  "required": true
1620                },
1621                {
1622                  "type": "TextInput",
1623                  "label": "Country/Region",
1624                  "input-type": "text",
1625                  "name": "country_region",
1626                  "required": true
1627                },
1628                {
1629                  "type": "Footer",
1630                  "label": "Continue",
1631                  "on-click-action": {
1632                    "name": "data_exchange",
1633                    "payload": {
1634                      "name": "${form.name}",
1635                      "address": "${form.address}",
1636                      "city": "${form.city}",
1637                      "zip_code": "${form.zip_code}",
1638                      "country_region": "${form.country_region}"
1639                    }
1640                  }
1641                }
1642              ]
1643            }
1644          ]
1645        }
1646      },
1647      {
1648        "id": "COVER",
1649        "title": "Your cover",
1650        "data": {
1651          "options": {
1652            "type": "array",
1653            "items": {
1654              "type": "object",
1655              "properties": {
1656                "id": {
1657                  "type": "string"
1658                },
1659                "title": {
1660                  "type": "string"
1661                },
1662                "description": {
1663                  "type": "string"
1664                }
1665              }
1666            },
1667            "__example__": [
1668              {
1669                "id": "1",
1670                "title": "Fire and theft",
1671                "description": "Cover your home against incidents of theft or accidental fires"
1672              },
1673              {
1674                "id": "2",
1675                "title": "Natural disaster",
1676                "description": "Protect your home against disasters including earthquakes, floods and storms"
1677              },
1678              {
1679                "id": "3",
1680                "title": "Liability",
1681                "description": "Protect yourself from legal liabilities that occur from accidents on your property"
1682              }
1683            ]
1684          }
1685        },
1686        "layout": {
1687          "type": "SingleColumnLayout",
1688          "children": [
1689            {
1690              "type": "Form",
1691              "name": "cover_form",
1692              "children": [
1693                {
1694                  "type": "CheckboxGroup",
1695                  "name": "options",
1696                  "data-source": "${data.options}",
1697                  "label": "Options",
1698                  "required": true
1699                },
1700                {
1701                  "type": "Footer",
1702                  "label": "Continue",
1703                  "on-click-action": {
1704                    "name": "data_exchange",
1705                    "payload": {
1706                      "options": "${form.options}"
1707                    }
1708                  }
1709                }
1710              ]
1711            }
1712          ]
1713        }
1714      },
1715      {
1716        "id": "QUOTE",
1717        "title": "Your quote",
1718        "terminal": true,
1719        "data": {
1720          "excess": {
1721            "type": "array",
1722            "items": {
1723              "type": "object",
1724              "properties": {
1725                "id": {
1726                  "type": "string"
1727                },
1728                "title": {
1729                  "type": "string"
1730                }
1731              }
1732            },
1733            "__example__": [
1734              {
1735                "id": "1",
1736                "title": "$250"
1737              }
1738            ]
1739          },
1740          "total": {
1741            "type": "string",
1742            "__example__": "$47.98 per month"
1743          }
1744        },
1745        "layout": {
1746          "type": "SingleColumnLayout",
1747          "children": [
1748            {
1749              "type": "Form",
1750              "name": "quote_form",
1751              "init-values": {
1752                "payment_options": "1"
1753              },
1754              "children": [
1755                {
1756                  "type": "Dropdown",
1757                  "label": "Excess",
1758                  "name": "excess",
1759                  "data-source": "${data.excess}",
1760                  "on-select-action": {
1761                    "name": "data_exchange",
1762                    "payload": {
1763                      "excess": "${form.excess}"
1764                    }
1765                  },
1766                  "required": true
1767                },
1768                {
1769                  "type": "RadioButtonsGroup",
1770                  "data-source": [
1771                    {
1772                      "id": "1",
1773                      "title": "Monthly"
1774                    },
1775                    {
1776                      "id": "2",
1777                      "title": "Annually (Save $115)"
1778                    }
1779                  ],
1780                  "name": "payment_options",
1781                  "label": "Payment options",
1782                  "on-select-action": {
1783                    "name": "data_exchange",
1784                    "payload": {
1785                      "payment_options": "${form.payment_options}"
1786                    }
1787                  },
1788                  "required": true
1789                },
1790                {
1791                  "type": "TextHeading",
1792                  "text": "${data.total}"
1793                },
1794                {
1795                  "type": "OptIn",
1796                  "name": "privacy_policy",
1797                  "label": "Accept our Privacy Policy",
1798                  "required": true,
1799                  "on-click-action": {
1800                    "name": "navigate",
1801                    "next": {
1802                      "type": "screen",
1803                      "name": "TERMS_AND_CONDITIONS"
1804                    },
1805                    "payload": {}
1806                  }
1807                },
1808                {
1809                  "type": "Footer",
1810                  "label": "Choose quote",
1811                  "on-click-action": {
1812                    "name": "data_exchange",
1813                    "payload": {
1814                      "privacy_policy": "${form.privacy_policy}"
1815                    }
1816                  }
1817                }
1818              ]
1819            }
1820          ]
1821        }
1822      },
1823      {
1824        "id": "TERMS_AND_CONDITIONS",
1825        "title": "Terms and conditions",
1826        "data": {},
1827        "layout": {
1828          "type": "SingleColumnLayout",
1829          "children": [
1830            {
1831              "type": "TextHeading",
1832              "text": "Our Terms"
1833            },
1834            {
1835              "type": "TextSubheading",
1836              "text": "Data usage"
1837            },
1838            {
1839              "type": "TextBody",
1840              "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
1841            },
1842            {
1843              "type": "TextSubheading",
1844              "text": "Privacy policy"
1845            },
1846            {
1847              "type": "TextBody",
1848              "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae odio dui. Praesent ut nulla tincidunt, scelerisque augue malesuada, volutpat lorem. Aliquam iaculis ex at diam posuere mollis. Suspendisse eget purus ac tellus interdum pharetra. In quis dolor turpis. Fusce in porttitor enim, vitae efficitur nunc. Fusce dapibus finibus volutpat. Fusce velit mi, ullamcorper ac gravida vitae, blandit quis ex. Fusce ultrices diam et justo blandit, quis consequat nisl euismod. Vestibulum pretium est sem, vitae convallis justo sollicitudin non. Morbi bibendum purus mattis quam condimentum, a scelerisque erat bibendum. Nullam sit amet bibendum lectus."
1849            }
1850          ]
1851        }
1852      }
1853    ]
1854  }
1855}