Custome action with api

while exccuting i am getting error , i am not getting where is the problem

Hi @sunilskn! If you have not stood up your action server, you will want to do that. Make sure to run pip install rasa-sdk , if you have not already done this. Then, please make sure you have specified in endpoints.yml that your action sever uses:

  url: "http://localhost:5055/webhook"

Finally, you can run rasa run actions in a separate window, while you are running rasa . You will find more information here and here . Please let me know if this did not solve your issue!

Thanks,i will try it

still i am facing same problem

@sunilskn Can you share the code for your action?

from future import absolute_import from future import division from future import unicode_literals

from rasa_core_sdk import Action from import SlotSet

class ActionWeather(Action): def name(self): return ‘action_weather’

def run(self, dispatcher, tracker, domain):
	from apixu.client import ApixuClient
	api_key = 'c114ca4223754c68bc583834191907' #your apixu key
	client = ApixuClient(api_key)
	loc = tracker.get_slot('location')
	current = client.getcurrent(q=loc)
	country = current['location']['country']
	city = current['location']['name']
	condition = current['current']['condition']['text']
	temperature_c = current['current']['temp_c']
	humidity = current['current']['humidity']
	wind_mph = current['current']['wind_mph']

	response = """It is currently {} in {} at the moment. The temperature is {} degrees, the humidity is {}% and the wind speed is {} mph.""".format(condition, city, temperature_c, humidity, wind_mph)

	return [SlotSet('location',loc)]

when i run the custom action in the server i am getting error

@sunilskn The forums are public, so you might want to remove your api_key.

I figured out the issue. The ApixuClient has changed their method for getting the current weather. If you change current = client.getcurrent(q=loc) to current = client.current(q=loc), it works!

Thank you so much it is working now

1 Like