-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.py
30 lines (20 loc) · 853 Bytes
/
actions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# This files contains your custom actions which can be used to run
# custom Python code.
#
# See this guide on how to implement these action:
# https://rasa.com/docs/rasa/core/actions/#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
from weather import Weather
class ActionHelloWorld(Action):
def name(self) -> Text:
return "action_weather_api"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
city=tracker.latest_message['text']
Temp=(Weather(city)['temp']-273)
dispatcher.utter_template('utter_temp',tracker,temp=Temp)
return []