In my custom action, i have created a list of button with custom values(taken from a database). I want to set slot case_id with value of one of these button. Using dispatcher.utter_message(), my buttons is display but when i click on any of these, there nothing change with value of slot case_id. Its value still None. can anyone help me out ?
ActionSetSlotCaseID(Action):
def name(self):
return "action_set_slot_case_id"
def run(self, dispatcher, tracker, domain):
ma_thu_tuc = tracker.get_slot('ma_thu_tuc')
statement = 'SELECT C2.MA_CHI_TIET_TRUONG_HOP, C2.TEN_CHI_TIET_TRUONG_HOP FROM CHATBOT_CHI_TIET_THU_TUC C1 JOIN CHATBOT_CHI_TIET_TRUONG_HOP C2 ON C1.MA_CHI_TIET_THU_TUC = C2.MA_CHI_TIET_THU_TUC WHERE C1.MA_CHI_TIET_THU_TUC = :ma_thu_tuc'
cur = con.cursor()
cur.execute(statement, ma_thu_tuc = ma_thu_tuc)
res = cur.fetchall()
button_list = []
for id, name in res:
title = name
payload = "/inform{\"case_id\": \"" + str(id) + "\"}"
button_list.append({ "title": title, "payload": payload })
dispatcher.utter_message(text = "Thủ tục bạn tìm kiếm có các trường hợp sau: ", buttons = button_list)
cur.close()
return []