How Location identification?

Hi, I am new to rasa. I am trying to implementing weather bot using openweather api. Can anyone help me out to identify location name and if user enter incorrect location name & the bot need to reply “Please mention a valid location name”

I have seen in some forum that using spacy entity extractor, but getting confused how implement.

stories.yml (548 Bytes) nlu.yml (1.8 KB) rules.yml (561 Bytes) domain.yml (1.1 KB) credentials.yml (980 Bytes) (3.2 KB) (652 Bytes)

class ActionWeather(Action):

def name(self) -> Text:
    return "action_weather"

def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    temp = int(Weather(loc)['temp']-273)
    hum =  int(Weather(loc)['humidity'])
    cond = Weather_Condition()[0]['description']
    if loc is not None:
        dispatcher.utter_message(template="utter_temp", LOC=loc, temp=temp, hum=hum, condition=cond)
    return [SlotSet('location',loc)]


@manoj_kumarM Please see this video series of weather API

  1. Calling Weather API in Rasa | Part - 1 | - YouTube
  2. Calling Weather API in Rasa | Part - 2 - YouTube

@manoj_kumarM If you got any issue do let us know.

Welcome to Rasa Family Manoj Kumar M:slight_smile: :handshake:

@manoj_kumarM Its your second ID Manoj? :flushed::thinking:

I hope this will solve you query. Good luck!

Thanks @nik202, I have gone through this video and I tried to implement

@manoj_kumarM what is your current output bot showing after incorrect location enter by user?

@manoj_kumarM Why you created second ID?

This is my personal one @nik202.

Is get any problem if have two accounts in rasa forum? :worried: Should only have one?

Look at this code example (Line 1364).

@manoj_kumarM no no made as much as you need to handle, but its good to made only one specific and dedicated ID, I got you :stuck_out_tongue: But welcome to the forum.

1 Like

Ohh Thanks! @nik202

Its showing noting in output

@manoj_kumarM file and file also upload in first post

Yes, uploaded

@manoj_kumarM meanwhile try change this in rules

- slot_was_set:
    - requested_slot: null
- slot_was_set:
    - requested_slot: location

@manoj_kumarM is this code is working? are you getting any result or output whilst entering any city name? I guess no?or yes?

Yes @nik202 , if give correct location name its giving proper output.

@manoj_kumarM the weather API issue is this when you mention the location or city in the intent it will show you the result as you mentioned Goa it was in the intent example, and when you mention Berlin it will not show, but as you mention Berline in intent example it will show you result.

Please try this first, and let me know is this what I said happening or not?

If give London it is not giving any output?

@manoj_kumarM London is in intent example? check your intent weather. Did you read my above post?

there is no london in intent. if mention any name in weather intent then it is giving an output.

if I execute giving location name as london it is getting an output.


Is there any wrong with my slots or form and

@manoj_kumarM because you passing manually that’s why Weather("london")

@manoj_kumarM you need to provide all city or location name or try the concept of lookup table.

Is another way to get the entity and pass it to api apart from lookup table

@manoj_kumarM I only know these 2, but where you required this project? or its just for getting understanding?

@manoj_kumarM If you understand the concept with the help of suggestions, I’d request to close this thread for others. Thanks.