Skip to content
Snippets Groups Projects
actions.py 1.72 KiB
Newer Older
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
Jonas Wolff's avatar
Jonas Wolff committed

class ActionSearchBirthplace(Action):
    def name(self):
        return 'action_search_birthplace'

    def run(self, dispatcher, tracker, domain):
        #import csv
        #dispatcher.utter_message("Searching for Birthplace")
        #person = tracker.get_slot('physicist')
        #actualBirthplace = None
        #with open('birthplace.csv', newLine='') as csvfile:
        #    spamreader = csv.DictReader(csvfile, delimiter=',')
        #    for row in spamreader:
        #        if row['Name'] == person:
        #            actualBirthplace = row['Birthplace']
        #if actualBirthplace is None:
        #    dispatcher.utter_message("DIE SCHEIßE FUNKTIONIERT NICHT!")
Jonas Wolff's avatar
Jonas Wolff committed
        #dispatcher.utter_message(actualBirthplace)
        #return [SlotSet('matches', actualBirthplace if actualBirthplace is not None else[])]
        #return [SlotSet('matches', ])]
Jonas Wolff's avatar
Jonas Wolff committed
        
class ActionSayBirthplace(Action):
    def name(self):
        return 'action_say_birthplace'

    def run(self, dispatcher, tracker, domain):
        dispatcher.utter_message("Here is the Birthplace I found:")
        dispatcher.utter_message(tracker.get_slot("matches"))
        return []

class ActionTest(Action):
    def name(self):
        return 'action_test'

    def run(self, dispatcher, tracker, domain):
        dispatcher.utter_message("This is a test")
        SlotSet('testSlot', 'This is a test')
        return []

class ActionTestOut(Action):
    def name(self):
        return 'action_test_out'
    
    def run(self, dispatcher, tracker, domain):
        dispatcher.utter_message("This is a second test")
        dispatcher.utter_message(tracker.get_slot('testSlot'))
        return []