-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
Copy pathactions.py
30 lines (22 loc) · 881 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
from typing import Dict, Text, List
from rasa_sdk import Tracker
from rasa_sdk.events import EventType
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk import Action
from rasa_sdk.events import SlotSet
class ActionSwitchFAQ(Action):
def name(self) -> Text:
return "action_switch_faq"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
return [SlotSet("detailed_faq", not tracker.get_slot("detailed_faq"))]
class ValidateSlots(Action):
def name(self) -> Text:
"""Unique identifier of the form"""
return "action_validate_loop_q_form"
def run(
self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
dispatcher.utter_message("validate_some_slot")
return [SlotSet("some_slot", "sdk")]