-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.py
79 lines (58 loc) · 2.2 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- coding: utf-8 -*-
#from future import absolute_import
#from future import division
#from future import unicode_literals
from typing import Dict, Text, Any, List, Union, Optional
from rasa_sdk import Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction
class AccountForm(FormAction):
def name(self) -> Text:
# unique form name for account opening
return "account_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
# list of all the fields from readme.
return ["accountname", "industry", "turnover", "employee_no"]
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
return {
"accountname": [self.from_entity(entity="accountname", intent="inform")],
"industry": [self.from_entity(entity="industry", intent=["inform"])],
"turnover": [self.from_entity(entity="turnover"),self.from_intent(intent="inform", value=True)],
"employee_no": [self.from_entity(entity="employee_no"),self.from_intent(intent="inform", value=True)]
}
def submit(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict]:
# utter submit template
dispatcher.utter_template("utter_submit", tracker)
return []
class AccountForm_one(FormAction):
def name(self) -> Text:
# unique form name for account opening
return "account_form_one"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
# list of all the fields from readme.
return ["contactname", "phone", "mobile", "email", "department", "designation"]
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
return {
"contactname": [self.from_entity(entity="contactname", intent="inform")],
"phone": [self.from_entity(entity="phone", intent=["inform"])],
"mobile": [self.from_entity(entity="mobile")],
"email": [self.from_entity(entity="email")],
"department": [self.from_entity(entity="department")],
"designation": [self.from_entity(entity="designation")]
}
def submit(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict]:
# utter submit template
dispatcher.utter_template("utter_submit", tracker)
return []