class ActionCity(Action):
city_key = 0
def name(self):
return 'action_city'
def run(self,dispatcher, tracker,domain):
city_response = "http://165.227.69.207:9001/api/country/get"
city_response_json = requests.get(city_response).json()
print(city_response_json)
print("--------cityid--------------------")
city_namee = tracker.get_slot('city_name')
if city_namee == None:
print("city not coming")
else:
print("city coming " + city_namee)
city_res = ""
city_ls = {}
for i in range(0, len(city_response_json["data"][0]["cities"])):
city_id = city_response_json["data"][0]["cities"][i]["_id"]
city_name = city_response_json["data"][0]["cities"][i]["city_name"]
city_ls.update({city_name: city_id})
print(city_namee)
city_ls = {k.lower():v for k, v in city_ls.items()}
for key, value in city_ls.items():
if city_namee in key:
print(city_namee)
print(key, value)
city_key = value
return city_key
# print(key,value)
if city_namee in city_ls:
print(city_namee)
response = "The city exists in our application".format(city_namee)
print(response)
else:
print("not exists")
response = "The city doesnt exists in our application"
print(response)
dispatcher.utter_message(response)
return [SlotSet('city_name',city_namee)]
---------- i am returning city_key and i want this key in another custom_action named as ActionCategory, what should i do, I have made the object too but when i make the object of run() method, it will ask me four parameters to give.