How to get API response into list, so that user can select any one of them

api

(Priyanshu shukla) #1

I got the response data from API through GET method. I got multiple records into json format. Now i want to select some specific items so that user can select any one of them by clicking on it.
(As we give multiple items in list.)
For Ex:
From the below API Response, i want to put all the “description” in one list. & all the descriptions should be clickable.

{
  "statusCode": 200,
  "body": {
    "result": [
      {
        "number": "INC0000060",
        "sys_created_on": "2016-12-12 15:19:57",
        "resolved_at": "2016-12-13 21:43:14",
        "subcategory": "email",
        "short_description": "Unable to connect to email",
        "description": "mobile",
        "calendar_duration": "1970-01-02 04:23:17",
        "close_notes": "This incident is resolved.",
        "notify": "1",
        "sys_class_name": "incident"
      },
      { 
        "number": "INC0000065",
        "sys_created_on": "2016-12-12 15:19:57",
        "resolved_at": "2016-12-13 21:43:14",
        "subcategory": "hardware",
        "short_description": "mouse not working properly",
        "description": "mouse issue",
        "calendar_duration": "1970-01-02 04:23:17",
        "close_notes": "This incident is resolved.",
        "notify": "1",
        "sys_class_name": "incident"
      },
      {
        "number": "INC0000072",
        "sys_created_on": "2016-12-25 15:19:57",
        "resolved_at": "2016-12-27 21:43:14",
        "subcategory": "login",
        "short_description": "forgot password",
        "description": "login issue",
        "calendar_duration": "1970-01-02 04:23:17",
        "close_notes": "This incident is resolved.",
        "notify": "1",
        "sys_class_name": "incident"
      },
      {
        "number": "INC0000079",
        "sys_created_on": "2016-12-12 15:19:57",
        "resolved_at": "2016-12-13 21:43:14",
        "subcategory": "email",
        "short_description": "Unable to connect to email",
        "description": "mobile",
        "calendar_duration": "1970-01-02 04:23:17",
        "close_notes": "This incident is resolved.",
        "notify": "1",
        "sys_class_name": "incident"
      },
      {
        "number": "INC0000088",
        "sys_created_on": "2016-12-27 15:19:57",
        "resolved_at": "2016-12-28 21:43:14",
        "subcategory": "update mobile",
        "short_description": "want to update my mobile no.",
        "description": "update mobile",
        "calendar_duration": "1970-01-02 04:23:17",
        "close_notes": "This incident is resolved.",
        "notify": "1",
        "sys_class_name": "incident"
      }
    ]
  },
  "headers": {
    "x-is-logged-in": "true",
    "x-transaction-id": "645d815adbde",
    "link": "<https://dev82648.service-now.com/api/now/table/incident"
    "x-total-count": "127",
    "content-type": "application/json;charset=UTF-8",
    "transfer-encoding": "chunked",
    "date": "Tue, 14 Jan 2020 12:43:52 GMT",
    "server": "ServiceNow",
    "connection": "close",
    "strict-transport-security": "max-age=63072000; includeSubDomains"
  }
}

(Swagata Sengupta) #2

We will leave the programming (getting “descriptions” iteratively from JSON array) on you. :slight_smile:

Once you have the list, use a button template/ quick reply template in message node so that you can have them clickable. Please see relevant documentation on templates.
https://developer.kore.ai/docs/bots/sdks/message-templates/


(Subrahmanyam Donepudi) #3

@priyanshuwwg Use the entity type List of items enumerated to present the list to users. Please check if the below configuration could help.
image

image

image

image

image

image

image

image


(Priyanshu shukla) #4

Thanks for your help. I have followed your step & got the items into list. The output is showing like this…MicrosoftTeams-image

But it is showing only 5 items as clickable buttons. But in result it is more than 5.
So how to show all values in list?


(Subrahmanyam Donepudi) #5

Well the template presented should be based on the number of items you have in the list. For instance, if the list contains more than 10 items , a text template is presented and if the list contains only 2 or 3 items in it, may be a button template and so on.

Post your service response body here and I’ll have it looked into.