tracker.get_slot cann’t output values of entity. How make it works?
import logging
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet, UserUtteranceReverted,
ConversationPaused
from apixu.client import ApixuClient, ApixuException
logger = logging.getLogger(name)
class ActionWeather(Action):
def name(self):
return ‘action_weather’
def run(self, dispatcher, tracker, domain):
#from apixu.client import ApixuClient
api_key = 'xxx211' # your apixu key
client = ApixuClient(api_key)
loc = tracker.get_slot('location')
current = client.getCurrentWeather(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)
dispatcher.utter_message(response)
return [SlotSet('location', loc)]
@desims I see a familiar weatherbot example here! Does it happen for generic examples like ‘What’s the weather in London?’ The most probable reason why your slot doesn’t return the value is because the entity wasn’t extracted correctly. The weatherbot tutorial has tiny amount of training examples and it’s likely that the bot will make mistakes when extracting entities. I would suggest you addig more training data to nlu examples.
? The bot wants to run ‘utter_greet’, correct? Yes
ERROR:rasa_core.server:Can not access action ‘None’, as that name is not a registered action for this domain. Available actions are:
- action_listen
- action_restart
- action_default_fallback
- action_deactivate_form
- utter_greet
- utter_goodbye
- utter_ask_room
- utter_ask_day
- utter_ask_hour_start
- utter_ask_duration
- action_room