我已经创建了多个按钮响应,现在如何通过单击此按钮单击来获取操作
class ActionSearchCat(Action):
def name(self):
return "action_search_cat"
def run(self, dispatcher, tracker, domain):
buttons = []
resp = requests.get('http://localhost:3001/api/categoryList/0')
if resp.status_code != 200:
# This means something went wrong.
raise ApiError('GET /tasks/ {}'.format(resp.status_code))
msg = resp.json().get('category_list').get('text')
for list in resp.json().get('category_list').get('choices').items():
for title, value in list.items():
buttons.append({"title": title, "payload": "/"+value})
dispatcher.utter_button_template(msg,buttons)
return []