cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

chatbot table format - result element

former_member715858
Participant
0 Kudos
1,190

Good Day,

would be possible to format/design the chat-bot to display results data from the json data source as table row and have one of them as hyberlink

can we use the CSS by any chance,

-----------------------------------------------------------------------------------------------------

https://sampleserver5.arcgisonline.com/arcgis/rest/services/AGP/Census/MapServer/3/query?where=STATE...

Hawaii STATE_NAME 15 STATE_FIPS Pacific SUB_REGION HI STATE_ABBR 1211537 POP2000 1299555 POP2007 189.9 POP00_SQMI 203.7 POP07_SQMI 294102 WHITE 22003 BLACK 3535 AMERI_ES 503868 ASIAN 113539 HAWN_PI 15147 OTHER 259343 MULT_RACE 87699 HISPANIC 608671 MALES 602866 FEMALES 78163 AGE_UNDER5 217604 AGE_5_17 65456 AGE_18_21 133437 AGE_22_29 183094 AGE_30_39 185646 AGE_40_49 187536 AGE_50_64 160601 AGE_65_UP 36.2 MED_AGE 35.1 MED_AGE_M 37.4 MED_AGE_F 403240 HOUSEHOLDS 2.92 AVE_HH_SZ 43253 HSEHLD_1_M 44900 HSEHLD_1_F 96758 MARHH_CHD 119319 MARHH_NO_C 8945 MHH_CHILD 23619 FHH_CHILD 287068 FAMILIES 3.42 AVE_FAM_SZ 460542 HSE_UNITS 57302 VACANT 227888 OWNER_OCC 175352 RENTER_OCC 5473 NO_FARMS97 263 AVG_SIZE97 292107 CROP_ACR97 90.8 AVG_SALE97 6381 SQMI 11.952786902763334 Shape_Length 1.429288927291385 Shape_Area 11.952786902763334 Shape_Length 1.429288927 Shape_Area

View Entire Topic
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

I am able to return the attribute called STATE_NAME ("Hawaii") with this:

{{api_service_response.default.body.features[0].attributes.STATE_NAME}}

If you want to create a list of the attributes (it is not an array but you can iterate ver an object's properties), so I used something like this:

{
  "type": "list",
  "delay": "",
  "content": {
    "title": "Items",
    "subtitle": "With Price",
    "imageUrl": "",
    "total": "30",
    "upperBoundText": "Too many options to display",
    "buttons": [
      {{#eachJoin api_service_response.default.body.features.[0].attributes}}
      {
        "title": "{{@key}}",
        "value": "{{this}}",
        "type": "postback"
      }
      {{/eachJoin}}
    ],
    "elements": [
       {{#eachJoin api_service_response.default.body.features.[0].attributes}}
      {
        "title": "{{@key}}",
        "subtitle": "{{this}}",
        "imageUrl": "",
        "status": "available",
        "statusState": "success",
        "description": "Food",
        "buttons": [
          {
            "title": "Buy",
            "value": "Buy",
            "type": "postback"
          }
        ]
      }
      {{/eachJoin}}
    ]
  }
}

The dot before the index of the array (features.[0]) is important. Not sure this code is resilient because it hardcodes taking the first element of the features array, but you will have to adjust based on use cases and how the API works.

former_member715858
Participant
0 Kudos

Thank you Dan , so much appreciate your support.