Hi! I’m new to Rasa! and I have a few questions.
This is one of my intent, I would like to train my bot to understand the entity location, but everytime I type something other than these location mentions below, rasa is not getting any entity.Am I not giving it enough data?Do I need to include entities below the examples?thanks! This is my intent.
- intent: weather
examples: |
- what is the weather [today]{“entity”: “date”}?
- what is the weather like in [New York]{“entity”: “location”} [today]{“entity”: “date”}?
- what will be the temperature in [London]{“entity”: “location”} [tomorrow]{“entity”: “date”}?
- is it going to rain in [San Francisco]{“entity”: “location”} [this weekend]{“entity”: “date”}?
- is the weather good [tomorrow]{“entity”: “date”}?
- how is the weather [tomorrow]{“entity”: “date”}?
This is my stories
- story: ask_weather
steps:
- intent: weather
entities:
- location: “New York”
- date: “today”
- action: “check_weather”
- intent: weather
entities:
This is my domain
version: ‘3.1’
intents:
-
affirm
-
bot_challenge
-
deny
-
goodbye
-
greet
-
mood_great
-
mood_unhappy
-
question_name
-
question_name_from
-
question_about_me
-
joke
-
weather
entities:
-
date
-
location
responses:
utter_greet:
- text: Good day, sir. How can I assist you today?
utter_cheer_up:
- text: ‘Here is something to cheer you up:’ image: https://i.imgur.com/nGF1K8f.jpg utter_did_that_help:
- text: Did that help you?
utter_joke:
- text: Of course, sir. Why did the tomato turn red? Because it saw the salad dressing! session_config: session_expiration_time: 60 carry_over_slots_to_new_session: true actions:
- check_weather
This is my actions
This files contains your custom actions which can be used to run
custom Python code.
See this guide on how to implement these action:
Custom Actions
This is a simple example for a custom action which utters “Hello World!”
from typing import Any, Text, Dict, List from rasa_sdk import Action, Tracker from rasa_sdk.executor import CollectingDispatcher
class GetWeather(Action): def name(self) → Text: return “check_weather”
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
entities = tracker.latest_message['entities']
date = None
location = None
for entity in entities:
if entity['entity'] == 'location':
location = entity['value']
elif entity['entity'] == 'date':
date = entity['value']
dispatcher.utter_message(text=f"The location is {location} and the date is {date}.")
return []
everytime I input location that not in the intent, I got location is none.Thank you in advance!