{
  "version": "7.1",
  "data_api_version": "3.0",
  "routing_model": {
    "SEARCH": [
      "RESULTS"
    ],
    "RESULTS": []
  },
  "screens": [
    {
      "id": "SEARCH",
      "title": "Quatrohaus Shopping",
      "data": {
        "categories": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              }
            }
          },
          "__example__": [
            {
              "id": "all",
              "title": "All products"
            }
          ]
        },
        "message": {
          "type": "string",
          "__example__": ""
        },
        "featured": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "enabled": {
                "type": "boolean"
              },
              "image": {
                "type": "string"
              },
              "alt-text": {
                "type": "string"
              }
            }
          },
          "__example__": [
            {
              "id": "product-id",
              "title": "Milk 1L",
              "description": "USD 1.60 \u00b7 In stock",
              "enabled": true,
              "image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jRZkAAAAASUVORK5CYII=",
              "alt-text": "Milk 1L"
            }
          ]
        },
        "has_featured": {
          "type": "boolean",
          "__example__": true
        },
        "selected_categories": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "__example__": [
            "all"
          ]
        }
      },
      "layout": {
        "type": "SingleColumnLayout",
        "children": [
          {
            "type": "Form",
            "name": "form",
            "children": [
              {
                "type": "TextHeading",
                "text": "What are you looking for?"
              },
              {
                "type": "TextBody",
                "text": "Search for products or choose a category. You can also select a featured product below."
              },
              {
                "type": "TextBody",
                "text": "${data.message}"
              },
              {
                "type": "TextInput",
                "name": "query",
                "label": "Search products",
                "input-type": "text",
                "max-chars": 100,
                "helper-text": "Enter a product name or SKU."
              },
              {
                "type": "ChipsSelector",
                "name": "category",
                "label": "Categories",
                "data-source": "${data.categories}",
                "max-selected-items": 1,
                "on-select-action": {
                  "name": "data_exchange",
                  "payload": {
                    "action": "category_change",
                    "category": "${form.category}"
                  }
                }
              },
              {
                "type": "TextSubheading",
                "text": "Products",
                "visible": "${data.has_featured}"
              },
              {
                "type": "RadioButtonsGroup",
                "name": "featured",
                "label": "Choose a product",
                "data-source": "${data.featured}",
                "required": false,
                "visible": "${data.has_featured}"
              },
              {
                "type": "Footer",
                "label": "Continue",
                "on-click-action": {
                  "name": "data_exchange",
                  "payload": {
                    "query": "${form.query}",
                    "category": "${form.category}",
                    "featured": "${form.featured}"
                  }
                }
              }
            ],
            "init-values": {
              "category": "${data.selected_categories}"
            }
          }
        ]
      }
    },
    {
      "id": "RESULTS",
      "title": "Products",
      "data": {
        "products": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "enabled": {
                "type": "boolean"
              },
              "image": {
                "type": "string"
              },
              "alt-text": {
                "type": "string"
              }
            }
          },
          "__example__": [
            {
              "id": "product-id",
              "title": "Milk 1L",
              "description": "USD 1.60 \u00b7 In stock",
              "enabled": true,
              "image": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+jRZkAAAAASUVORK5CYII=",
              "alt-text": "Milk 1L"
            }
          ]
        },
        "message": {
          "type": "string",
          "__example__": "Showing up to 20 results."
        }
      },
      "layout": {
        "type": "SingleColumnLayout",
        "children": [
          {
            "type": "Form",
            "name": "form",
            "children": [
              {
                "type": "TextBody",
                "text": "${data.message}"
              },
              {
                "type": "RadioButtonsGroup",
                "name": "product",
                "label": "Choose a product",
                "required": true,
                "data-source": "${data.products}"
              },
              {
                "type": "Footer",
                "label": "Continue in chat",
                "on-click-action": {
                  "name": "data_exchange",
                  "payload": {
                    "product": "${form.product}"
                  }
                }
              }
            ]
          }
        ]
      },
      "terminal": true,
      "success": true
    }
  ]
}
