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)
actions.py (3.2 KB)
weather.py (652 Bytes)
actions.py
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]]:
loc=tracker.get_slot('location')
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)
else:
dispatcher.utter_message(template="utter_invalid")
return [SlotSet('location',loc)]
Thanks
nik202
(NiK202)
August 27, 2021, 7:57am
2
@manoj_kumarM
Please see this video series of weather API
Calling Weather API in Rasa | Part - 1 | - YouTube
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:
@manoj_kumarM Its your second ID Manoj?
I hope this will solve you query. Good luck!
Thanks @nik202 , I have gone through this video and I tried to implement
nik202
(NiK202)
August 27, 2021, 8:06am
4
@manoj_kumarM what is your current output bot showing after incorrect location enter by user?
nik202
(NiK202)
August 27, 2021, 8:07am
5
@manoj_kumarM Why you created second ID?
This is my personal one @nik202 .
Is get any problem if have two accounts in rasa forum? Should only have one?
ChrisRahme
(Chris Rahmé)
August 27, 2021, 8:23am
7
Look at this code example (Line 1364).
nik202
(NiK202)
August 27, 2021, 8:33am
8
@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 But welcome to the forum.
1 Like
Ohh Thanks! @nik202
Its showing noting in output
nik202
(NiK202)
August 27, 2021, 8:58am
10
@manoj_kumarM weather.py file and action.py file also upload in first post
nik202
(NiK202)
August 27, 2021, 9:01am
12
@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.
nik202
(NiK202)
August 27, 2021, 9:14am
14
@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?
nik202
(NiK202)
August 27, 2021, 9:26am
16
@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 weather.py giving location name as london it is getting an output.
Is there any wrong with my slots or form and actions.py
nik202
(NiK202)
August 27, 2021, 9:34am
18
@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.
@nik202
Is another way to get the entity and pass it to api apart from lookup table
nik202
(NiK202)
August 30, 2021, 11:39am
20
@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.