Issue of actions.py do not know get_weather in rasa x

my nlu.md contains

intent:greeting

  • hey

  • hello

  • hi

  • heya

intent:how_are_you

  • how are you

  • how is it going

  • how is life

intent:bye

  • bye

  • good bye

intent:my_name_is

intent:get_weather

  • what’s the weather

  • what’s the weather in Czech Republic

  • what is the weather

  • what is the weather in New Zealand

  • whats the weather

synonym:Prague

  • Czech Republic

  • Czechia

  • CR

  • CZ

synonym:Auckland

  • New Zealand

  • NZ

  • Zealand my stories.md

greeting

  • greeting
    • utter_greeting

how are you

  • how_are_you
    • utter_how_i_am

good bye

  • bye
    • utter_bye

my name is

  • my_name_is
    • utter_its_nice_to_meet_you

dialogue about myself

  • who_are_you
    • utter_introduction
  • tell_me_more
    • utter_more_personal_information

dialogue about turtles

  • do_you_like_turtles
    • utter_i_love_turtles
  • tell_me_more
    • utter_list_of_favorite_turtles

get weather

  • get_weather
    • action_get_weather my config file anguage: en

pipeline:

  • name: nlp_spacy

  • name: tokenizer_spacy

  • name: intent_entity_featurizer_regex

  • name: intent_featurizer_spacy

  • name: ner_crf

  • name: ner_spacy

  • name: ner_synonyms

  • name: intent_classifier_sklearn

policies:

  • batch_size: 50

epochs: 200

max_training_samples: 300

name: KerasPolicy

  • fallback_action_name: action_default_fallback

name: FallbackPolicy

  • max_history: 5

name: MemoizationPolicy

  • name: FormPolicy

  • name: MappingPolicy my actions.py from future import absolute_import from future import division from future import print_function from future import unicode_literals

from rasa_core.actions.action import Action

weather-api · PyPI

from weather import Weather, Unit

class ActionGetWeather(Action): def name(self): return ‘action_get_weather’

def run(self, dispatcher, tracker, domain):
    weather = Weather(unit=Unit.CELSIUS)
    gpe = ('Auckland', tracker.get_slot('GPE'))[bool(tracker.get_slot('GPE'))]
    result = weather.lookup_by_location(gpe)
    if result:
        condition = result.condition
        city = result.location.city
        country = result.location.country
        dispatcher.utter_message('It\'s ' + condition.text + ' and ' + condition.temp + '°C in ' +
                                 city + ', ' + country + '.')
    else:
        dispatcher.utter_message('We did not find any weather information for ' + gpe + '. Search by a city name.')
    return

when I run rasa train Cannot access action ‘action_get_weather’, as that name is not a registered action for this domain. Available actions are: - action_listen - action_restart - action_default_fallback - action_deactivate_form - action_revert_fallback_events - action_default_ask_affirmation - action_default_ask_rephrase - action_back - actions.weather.ActionGetWeather - utter_bye - utter_greeting - utter_how_i_am - utter_its_nice_to_meet_you

Hi @hajoura

could you please check if your domain file containts “action_get_weather” as action?

Regards

my domain file contain

actions:

  • utter_greeting
  • utter_how_i_am
  • utter_bye
  • utter_its_nice_to_meet_you
  • actions.weather.ActionGetWeather

Hmm - could you please change

* actions.weather.ActionGetWeather

to

action_get_weather

and try it again?

1 Like

thank you so much it has been fix but when I ask my bot on weather it does not display anythings how can I fix it ?

Is the action properly executed? Is there any verbose output you could post please?

Change

return

to

return []

Even if I assume that this won’t fix your problem.