rasa-pro 3.13.1a4__py3-none-any.whl → 3.13.1a6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rasa-pro might be problematic. Click here for more details.

Files changed (191) hide show
  1. rasa/builder/project_generator.py +6 -1
  2. rasa/cli/project_templates/finance/actions/__init__.py +0 -0
  3. rasa/cli/project_templates/finance/actions/action_add_payee.py +47 -0
  4. rasa/cli/project_templates/finance/actions/action_ask_account.py +50 -0
  5. rasa/cli/project_templates/finance/actions/action_ask_account_from.py +50 -0
  6. rasa/cli/project_templates/finance/actions/action_ask_card.py +47 -0
  7. rasa/cli/project_templates/finance/actions/action_check_balance.py +40 -0
  8. rasa/cli/project_templates/finance/actions/action_check_card_existence.py +35 -0
  9. rasa/cli/project_templates/finance/actions/action_check_payee_existence.py +40 -0
  10. rasa/cli/project_templates/finance/actions/action_check_sufficient_funds.py +41 -0
  11. rasa/cli/project_templates/finance/actions/action_list_payees.py +45 -0
  12. rasa/cli/project_templates/finance/actions/action_process_immediate_payment.py +18 -0
  13. rasa/cli/project_templates/finance/actions/action_remove_payee.py +49 -0
  14. rasa/cli/project_templates/finance/actions/action_schedule_payment.py +19 -0
  15. rasa/cli/project_templates/finance/actions/action_session_start.py +69 -0
  16. rasa/cli/project_templates/finance/actions/action_update_card_status.py +45 -0
  17. rasa/cli/project_templates/finance/actions/action_validate_payment_date.py +36 -0
  18. rasa/cli/project_templates/finance/actions/database.py +233 -0
  19. rasa/cli/project_templates/finance/config.yml +16 -1
  20. rasa/cli/project_templates/finance/csvs/accounts.csv +8 -0
  21. rasa/cli/project_templates/finance/csvs/advisors.csv +7 -0
  22. rasa/cli/project_templates/finance/csvs/appointments.csv +211 -0
  23. rasa/cli/project_templates/finance/csvs/branches.csv +10 -0
  24. rasa/cli/project_templates/finance/csvs/cards.csv +11 -0
  25. rasa/cli/project_templates/finance/csvs/payees.csv +10 -0
  26. rasa/cli/project_templates/finance/csvs/transactions.csv +71 -0
  27. rasa/cli/project_templates/finance/csvs/users.csv +4 -0
  28. rasa/cli/project_templates/finance/data/flows/add_payee.yml +29 -0
  29. rasa/cli/project_templates/finance/data/flows/block_card.yml +66 -0
  30. rasa/cli/project_templates/finance/data/flows/check_balance.yml +9 -0
  31. rasa/cli/project_templates/finance/data/flows/list_payees.yml +5 -0
  32. rasa/cli/project_templates/finance/data/flows/remove_payee.yml +21 -0
  33. rasa/cli/project_templates/finance/data/flows/select_card.yml +12 -0
  34. rasa/cli/project_templates/finance/data/flows/transfer_money.yml +64 -2
  35. rasa/cli/project_templates/finance/data/flows/welcome.yml +14 -0
  36. rasa/cli/project_templates/finance/data/nlu.yml +29 -0
  37. rasa/cli/project_templates/finance/data/patterns/pattern_chitchat.yml +7 -0
  38. rasa/cli/project_templates/finance/data/patterns/pattern_completed.yml +6 -0
  39. rasa/cli/project_templates/finance/data/patterns/pattern_search.yml +5 -0
  40. rasa/cli/project_templates/finance/data/patterns/pattern_session_start.yml +5 -3
  41. rasa/cli/project_templates/finance/data/source/accounts.json +51 -0
  42. rasa/cli/project_templates/finance/data/source/advisors.json +44 -0
  43. rasa/cli/project_templates/finance/data/source/appointments.json +1474 -0
  44. rasa/cli/project_templates/finance/data/source/branches.json +47 -0
  45. rasa/cli/project_templates/finance/data/source/cards.json +72 -0
  46. rasa/cli/project_templates/finance/data/source/payees.json +74 -0
  47. rasa/cli/project_templates/finance/data/source/transactions.json +492 -0
  48. rasa/cli/project_templates/finance/data/source/users.json +29 -0
  49. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/consequences_of_blocking_card.txt +8 -0
  50. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/reasons_to_block_card.txt +8 -0
  51. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/recovering_from_card_fraud.txt +8 -0
  52. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/tips_for_card_security.txt +8 -0
  53. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/what_to_do_if_card_is_lost.txt +8 -0
  54. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/account_balance_security.txt +7 -0
  55. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/common_balance_inquiries.txt +8 -0
  56. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/methods_to_check_balance.txt +8 -0
  57. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/understanding_balance_updates.txt +8 -0
  58. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/what_to_do_if_balance_is_incorrect.txt +8 -0
  59. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/benefits_of_authorised_payees.txt +8 -0
  60. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/common_issues_with_payees.txt +8 -0
  61. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/general_payee_information.txt +8 -0
  62. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/payee_management_tips.txt +8 -0
  63. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/understanding_payee_types.txt +8 -0
  64. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/common_transfer_errors.txt +8 -0
  65. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/fees_for_transfers.txt +8 -0
  66. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/general_transfer_information.txt +8 -0
  67. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/security_tips_for_transfers.txt +8 -0
  68. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/transfer_processing_times.txt +8 -0
  69. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part1.txt +50 -0
  70. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part10.txt +50 -0
  71. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part11.txt +48 -0
  72. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part12.txt +50 -0
  73. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part13.txt +50 -0
  74. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part14.txt +47 -0
  75. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part15.txt +50 -0
  76. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part16.txt +50 -0
  77. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part17.txt +47 -0
  78. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part18.txt +50 -0
  79. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part19.txt +50 -0
  80. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part2.txt +50 -0
  81. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part20.txt +47 -0
  82. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part21.txt +50 -0
  83. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part22.txt +50 -0
  84. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part23.txt +47 -0
  85. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part24.txt +50 -0
  86. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part25.txt +50 -0
  87. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part26.txt +47 -0
  88. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part27.txt +50 -0
  89. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part28.txt +50 -0
  90. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part29.txt +47 -0
  91. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part3.txt +47 -0
  92. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part30.txt +50 -0
  93. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part31.txt +50 -0
  94. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part32.txt +47 -0
  95. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part33.txt +50 -0
  96. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part34.txt +50 -0
  97. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part35.txt +47 -0
  98. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part36.txt +50 -0
  99. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part37.txt +50 -0
  100. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part38.txt +47 -0
  101. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part39.txt +50 -0
  102. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part4.txt +50 -0
  103. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part40.txt +50 -0
  104. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part41.txt +47 -0
  105. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part42.txt +50 -0
  106. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part43.txt +50 -0
  107. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part44.txt +47 -0
  108. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part45.txt +50 -0
  109. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part46.txt +50 -0
  110. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part47.txt +47 -0
  111. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part48.txt +50 -0
  112. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part49.txt +50 -0
  113. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part5.txt +50 -0
  114. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part50.txt +47 -0
  115. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part51.txt +50 -0
  116. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part52.txt +50 -0
  117. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part53.txt +47 -0
  118. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part54.txt +50 -0
  119. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part55.txt +50 -0
  120. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part56.txt +47 -0
  121. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part57.txt +50 -0
  122. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part58.txt +50 -0
  123. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part59.txt +47 -0
  124. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part6.txt +47 -0
  125. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part60.txt +50 -0
  126. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part61.txt +50 -0
  127. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part7.txt +50 -0
  128. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part8.txt +50 -0
  129. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part9.txt +47 -0
  130. rasa/cli/project_templates/finance/domain/add_payee.yml +47 -0
  131. rasa/cli/project_templates/finance/domain/block_card.yml +101 -0
  132. rasa/cli/project_templates/finance/domain/check_balance.yml +9 -0
  133. rasa/cli/project_templates/finance/domain/default_actions.yml +16 -0
  134. rasa/cli/project_templates/finance/domain/default_flows.yml +33 -0
  135. rasa/cli/project_templates/finance/domain/list_payees.yml +4 -0
  136. rasa/cli/project_templates/finance/domain/remove_payee.yml +16 -0
  137. rasa/cli/project_templates/finance/domain/select_card.yml +12 -0
  138. rasa/cli/project_templates/finance/domain/transfer_money.yml +79 -0
  139. rasa/cli/project_templates/finance/endpoints.yml +6 -2
  140. rasa/cli/project_templates/finance/prompts/command-generator.jinja2 +57 -0
  141. rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +19 -0
  142. rasa/cli/project_templates/finance/requirements.txt +1 -0
  143. rasa/cli/project_templates/plain/actions/__init__.py +0 -0
  144. rasa/cli/project_templates/telco/actions/actions_billing.py +151 -0
  145. rasa/cli/project_templates/telco/actions/actions_get_data_from_db.py +27 -0
  146. rasa/cli/project_templates/telco/actions/actions_run_diagnostics.py +23 -0
  147. rasa/cli/project_templates/telco/actions/actions_session_start.py +13 -0
  148. rasa/cli/project_templates/{telecom → telco}/config.yml +9 -1
  149. rasa/cli/project_templates/telco/csvs/billing.csv +10 -0
  150. rasa/cli/project_templates/telco/csvs/customers.csv +5 -0
  151. rasa/cli/project_templates/telco/data/flows/flow_global.yml +5 -0
  152. rasa/cli/project_templates/telco/data/flows/flow_reboot_router.yml +8 -0
  153. rasa/cli/project_templates/telco/data/flows/flow_reset_router.yml +7 -0
  154. rasa/cli/project_templates/telco/data/flows/flow_solve_internet_issue.yml +73 -0
  155. rasa/cli/project_templates/telco/data/flows/flow_undertand_bill.yml +45 -0
  156. rasa/cli/project_templates/telco/data/patterns/pattern_completed.yml +7 -0
  157. rasa/cli/project_templates/telco/data/patterns/pattern_human_handoff.yml +6 -0
  158. rasa/cli/project_templates/telco/data/patterns/pattern_search.yml +7 -0
  159. rasa/cli/project_templates/telco/data/patterns/pattern_session_start.yml +9 -0
  160. rasa/cli/project_templates/telco/docs/reset_vs_rboot_router.txt +1 -0
  161. rasa/cli/project_templates/telco/docs/restart_router.txt +6 -0
  162. rasa/cli/project_templates/telco/docs/run_speed_test.txt +6 -0
  163. rasa/cli/project_templates/telco/domain/domain_global.yml +29 -0
  164. rasa/cli/project_templates/telco/domain/domain_patterns.yml +17 -0
  165. rasa/cli/project_templates/telco/domain/domain_reboot_router.yml +20 -0
  166. rasa/cli/project_templates/telco/domain/domain_reset_router.yml +11 -0
  167. rasa/cli/project_templates/telco/domain/domain_run_speed_test.yml +24 -0
  168. rasa/cli/project_templates/telco/domain/domain_solve_internet_issue.yml +74 -0
  169. rasa/cli/project_templates/telco/domain/domain_undertand_bill.yml +102 -0
  170. rasa/cli/project_templates/{telecom → telco}/endpoints.yml +4 -2
  171. rasa/cli/project_templates/telco/prompts/command-generator.jinja2 +57 -0
  172. rasa/cli/project_templates/telco/tests/e2e_results_failed.yml +62 -0
  173. rasa/cli/project_templates/telco/tests/e2e_results_passed.yml +130 -0
  174. rasa/cli/project_templates/telco/tests/e2e_test_cases/billing_test_cases.yml +68 -0
  175. rasa/cli/project_templates/telco/tests/e2e_test_cases/global_test_cases.yml +13 -0
  176. rasa/cli/project_templates/telco/tests/e2e_test_cases/internet_slow_test_case.yml +47 -0
  177. rasa/cli/project_templates/telco/tests/e2e_test_cases/out_of_scope_test_case.yml +21 -0
  178. rasa/cli/project_templates/telco/tests/e2e_test_cases/patterns_test_cases.yml +15 -0
  179. rasa/cli/scaffold.py +1 -1
  180. rasa/core/channels/studio_chat.py +1 -0
  181. rasa/version.py +1 -1
  182. {rasa_pro-3.13.1a4.dist-info → rasa_pro-3.13.1a6.dist-info}/METADATA +1 -1
  183. {rasa_pro-3.13.1a4.dist-info → rasa_pro-3.13.1a6.dist-info}/RECORD +187 -20
  184. rasa/cli/project_templates/finance/domain.yml +0 -7
  185. rasa/cli/project_templates/telecom/data/flows/upgrade_contract.yml +0 -5
  186. rasa/cli/project_templates/telecom/data/patterns/pattern_session_start.yml +0 -7
  187. rasa/cli/project_templates/telecom/domain.yml +0 -7
  188. /rasa/cli/project_templates/{telecom → telco}/credentials.yml +0 -0
  189. {rasa_pro-3.13.1a4.dist-info → rasa_pro-3.13.1a6.dist-info}/NOTICE +0 -0
  190. {rasa_pro-3.13.1a4.dist-info → rasa_pro-3.13.1a6.dist-info}/WHEEL +0 -0
  191. {rasa_pro-3.13.1a4.dist-info → rasa_pro-3.13.1a6.dist-info}/entry_points.txt +0 -0
@@ -161,9 +161,14 @@ class ProjectGenerator:
161
161
  def _create_importer(self) -> TrainingDataImporter:
162
162
  """Create a training data importer from the current bot files."""
163
163
  try:
164
+ if (self.project_folder / "domain.yml").exists():
165
+ domain_path = self.project_folder / "domain.yml"
166
+ else:
167
+ domain_path = self.project_folder / "domain"
168
+
164
169
  return TrainingDataImporter.load_from_config(
165
170
  config_path=self.project_folder / "config.yml",
166
- domain_path=self.project_folder / "domain.yml",
171
+ domain_path=domain_path,
167
172
  training_data_paths=[
168
173
  self.project_folder / "data",
169
174
  ],
File without changes
@@ -0,0 +1,47 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.events import SlotSet
5
+ from rasa_sdk.executor import CollectingDispatcher
6
+
7
+ from actions.database import Database
8
+
9
+
10
+ class ActionAddPayee(Action):
11
+ def name(self) -> Text:
12
+ return "action_add_payee"
13
+
14
+ def run(
15
+ self,
16
+ dispatcher: CollectingDispatcher,
17
+ tracker: Tracker,
18
+ domain: Dict[Text, Any],
19
+ ) -> List[Dict[Text, Any]]:
20
+ username = tracker.get_slot("username")
21
+ payee_name = tracker.get_slot("payee_name")
22
+ account_number = tracker.get_slot("account_number")
23
+ sort_code = tracker.get_slot("sort_code")
24
+ payee_type = tracker.get_slot("payee_type")
25
+ reference = tracker.get_slot("reference") or ""
26
+
27
+ db = Database()
28
+
29
+ # Get user information
30
+ user = db.get_user_by_name(username)
31
+ if not user:
32
+ dispatcher.utter_message(text="User not found.")
33
+ return []
34
+
35
+ # Add the payee
36
+ success = db.add_payee(
37
+ user["id"], payee_name, sort_code, account_number, payee_type, reference
38
+ )
39
+
40
+ if success:
41
+ dispatcher.utter_message(
42
+ text=f"Payee {payee_name} has been added successfully."
43
+ )
44
+ return [SlotSet("payee_added", True)]
45
+ else:
46
+ dispatcher.utter_message(text="Failed to add payee. Please try again.")
47
+ return [SlotSet("payee_added", False)]
@@ -0,0 +1,50 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.events import SlotSet
5
+ from rasa_sdk.executor import CollectingDispatcher
6
+
7
+ from actions.database import Database
8
+
9
+
10
+ class ActionAskAccount(Action):
11
+ def name(self) -> Text:
12
+ return "action_ask_account"
13
+
14
+ def run(
15
+ self,
16
+ dispatcher: CollectingDispatcher,
17
+ tracker: Tracker,
18
+ domain: Dict[Text, Any],
19
+ ) -> List[Dict[Text, Any]]:
20
+ username = tracker.get_slot("username")
21
+
22
+ db = Database()
23
+
24
+ # Get user information
25
+ user = db.get_user_by_name(username)
26
+ if not user:
27
+ dispatcher.utter_message(text="User not found.")
28
+ return []
29
+
30
+ # Get all accounts for the user
31
+ accounts = db.get_accounts_by_user(user["id"])
32
+
33
+ if not accounts:
34
+ dispatcher.utter_message(text="No accounts found for this user.")
35
+ return []
36
+
37
+ buttons = [
38
+ {
39
+ "content_type": "text",
40
+ "title": f"{account['number']} ({account['type'].title()})",
41
+ "payload": str(account["number"]),
42
+ }
43
+ for account in accounts
44
+ ]
45
+ message = "Which account would you like the balance for?"
46
+ dispatcher.utter_message(text=message, buttons=buttons)
47
+
48
+ selected_account = tracker.get_slot("account")
49
+
50
+ return [SlotSet("account", selected_account)]
@@ -0,0 +1,50 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.executor import CollectingDispatcher
5
+
6
+ from actions.database import Database
7
+
8
+
9
+ class ActionAskAccountFrom(Action):
10
+ def name(self) -> Text:
11
+ return "action_ask_account_from"
12
+
13
+ def run(
14
+ self,
15
+ dispatcher: CollectingDispatcher,
16
+ tracker: Tracker,
17
+ domain: Dict[Text, Any],
18
+ ) -> List[Dict[Text, Any]]:
19
+ username = tracker.get_slot("username")
20
+
21
+ db = Database()
22
+
23
+ # Get user information
24
+ user = db.get_user_by_name(username)
25
+ if not user:
26
+ dispatcher.utter_message(text="User not found.")
27
+ return []
28
+
29
+ # Get all accounts for the user
30
+ accounts = db.get_accounts_by_user(user["id"])
31
+
32
+ if not accounts:
33
+ dispatcher.utter_message(text="No accounts found for this user.")
34
+ return []
35
+
36
+ buttons = [
37
+ {
38
+ "content_type": "text",
39
+ "title": (
40
+ f"{account['type'].title()} (Balance: "
41
+ f"${float(account['balance']):.2f})"
42
+ ),
43
+ "payload": str(account["number"]),
44
+ }
45
+ for account in accounts
46
+ ]
47
+ message = "Which account would you like to transfer money from?"
48
+ dispatcher.utter_message(text=message, buttons=buttons)
49
+
50
+ return []
@@ -0,0 +1,47 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.executor import CollectingDispatcher
5
+
6
+ from actions.database import Database
7
+
8
+
9
+ class ActionAskCard(Action):
10
+ def name(self) -> Text:
11
+ return "action_ask_card"
12
+
13
+ def run(
14
+ self,
15
+ dispatcher: CollectingDispatcher,
16
+ tracker: Tracker,
17
+ domain: Dict[Text, Any],
18
+ ) -> List[Dict[Text, Any]]:
19
+ username = tracker.get_slot("username")
20
+
21
+ db = Database()
22
+
23
+ # Get user information
24
+ user = db.get_user_by_name(username)
25
+ if not user:
26
+ dispatcher.utter_message(text="User not found.")
27
+ return []
28
+
29
+ # Get all cards for the user
30
+ cards = db.get_cards_by_user(user["id"])
31
+
32
+ if not cards:
33
+ dispatcher.utter_message(text="No cards found for this user.")
34
+ return []
35
+
36
+ buttons = [
37
+ {
38
+ "content_type": "text",
39
+ "title": f"{i + 1}: x{card['number'][-4:]} ({card['type'].title()})",
40
+ "payload": f"/SetSlots(card_selection={card['number']!s})",
41
+ }
42
+ for i, card in enumerate(cards)
43
+ ]
44
+ message = "Select the card you require assistance with:"
45
+ dispatcher.utter_message(text=message, buttons=buttons)
46
+
47
+ return []
@@ -0,0 +1,40 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.executor import CollectingDispatcher
5
+
6
+ from actions.database import Database
7
+
8
+
9
+ class ActionCheckBalance(Action):
10
+ def name(self) -> Text:
11
+ return "action_check_balance"
12
+
13
+ def run(
14
+ self,
15
+ dispatcher: CollectingDispatcher,
16
+ tracker: Tracker,
17
+ domain: Dict[Text, Any],
18
+ ) -> List[Dict[Text, Any]]:
19
+ username = tracker.get_slot("username")
20
+ account_number = tracker.get_slot("account")
21
+
22
+ db = Database()
23
+
24
+ # Get user information
25
+ user = db.get_user_by_name(username)
26
+ if not user:
27
+ dispatcher.utter_message(text="User not found.")
28
+ return []
29
+
30
+ # Get account information
31
+ account = db.get_account_by_user_and_number(user["id"], account_number)
32
+ if not account:
33
+ dispatcher.utter_message(text="Account not found.")
34
+ return []
35
+
36
+ current_balance = float(account["balance"])
37
+
38
+ message = f"The balance is: ${current_balance}"
39
+ dispatcher.utter_message(text=message)
40
+ return []
@@ -0,0 +1,35 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.events import SlotSet
5
+ from rasa_sdk.executor import CollectingDispatcher
6
+
7
+ from actions.database import Database
8
+
9
+
10
+ class ActionCheckCardExistence(Action):
11
+ def name(self) -> str:
12
+ return "action_check_card_existence"
13
+
14
+ def run(
15
+ self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[str, Any]
16
+ ) -> List[Dict[Text, Any]]:
17
+ username = tracker.get_slot("username")
18
+ card_number = tracker.get_slot("card_number")
19
+
20
+ db = Database()
21
+
22
+ # Get user information
23
+ user = db.get_user_by_name(username)
24
+ if not user:
25
+ dispatcher.utter_message(text="User not found.")
26
+ return []
27
+
28
+ # Get all cards for the user
29
+ cards = db.get_cards_by_user(user["id"])
30
+ card_numbers = [card["number"] for card in cards]
31
+
32
+ if card_number in card_numbers:
33
+ return [SlotSet("card_found", True)]
34
+ else:
35
+ return [SlotSet("card_found", False)]
@@ -0,0 +1,40 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.events import SlotSet
5
+ from rasa_sdk.executor import CollectingDispatcher
6
+
7
+ from actions.database import Database
8
+
9
+
10
+ class ActionCheckPayeeExistence(Action):
11
+ def name(self) -> Text:
12
+ return "action_check_payee_existence"
13
+
14
+ def run(
15
+ self,
16
+ dispatcher: CollectingDispatcher,
17
+ tracker: Tracker,
18
+ domain: Dict[Text, Any],
19
+ ) -> List[Dict[Text, Any]]:
20
+ username = tracker.get_slot("username")
21
+ payee_name = tracker.get_slot("payee_name")
22
+
23
+ db = Database()
24
+
25
+ # Get user information
26
+ user = db.get_user_by_name(username)
27
+ if not user:
28
+ dispatcher.utter_message(text="User not found.")
29
+ return []
30
+
31
+ # Check if payee exists
32
+ payee = db.get_payee_by_name_and_user(payee_name, user["id"])
33
+
34
+ if payee:
35
+ return [SlotSet("payee_exists", True)]
36
+
37
+ dispatcher.utter_message(
38
+ text=f"{payee_name} is not an authorised payee. Let's add them!"
39
+ )
40
+ return [SlotSet("payee_exists", False)]
@@ -0,0 +1,41 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.events import SlotSet
5
+ from rasa_sdk.executor import CollectingDispatcher
6
+
7
+ from actions.database import Database
8
+
9
+
10
+ class ActionCheckSufficientFunds(Action):
11
+ def name(self) -> Text:
12
+ return "action_check_sufficient_funds"
13
+
14
+ def run(
15
+ self,
16
+ dispatcher: CollectingDispatcher,
17
+ tracker: Tracker,
18
+ domain: Dict[Text, Any],
19
+ ) -> List[Dict[Text, Any]]:
20
+ username = tracker.get_slot("username")
21
+ account_from = tracker.get_slot("account_from")
22
+ amount = float(tracker.get_slot("amount"))
23
+
24
+ db = Database()
25
+
26
+ # Get user information
27
+ user = db.get_user_by_name(username)
28
+ if not user:
29
+ dispatcher.utter_message(text="User not found.")
30
+ return []
31
+
32
+ # Check if user has sufficient funds
33
+ has_sufficient_funds = db.check_sufficient_funds(
34
+ user["id"], account_from, amount
35
+ )
36
+
37
+ if has_sufficient_funds:
38
+ return [SlotSet("sufficient_funds", True)]
39
+ else:
40
+ dispatcher.utter_message(text="Insufficient funds for this transaction.")
41
+ return [SlotSet("sufficient_funds", False)]
@@ -0,0 +1,45 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.executor import CollectingDispatcher
5
+
6
+ from actions.database import Database
7
+
8
+
9
+ class ActionListPayees(Action):
10
+ def name(self) -> Text:
11
+ return "action_list_payees"
12
+
13
+ def run(
14
+ self,
15
+ dispatcher: CollectingDispatcher,
16
+ tracker: Tracker,
17
+ domain: Dict[Text, Any],
18
+ ) -> List[Dict[Text, Any]]:
19
+ username = tracker.get_slot("username")
20
+
21
+ db = Database()
22
+
23
+ # Get user information
24
+ user = db.get_user_by_name(username)
25
+ if not user:
26
+ dispatcher.utter_message(text="User not found.")
27
+ return []
28
+
29
+ # Get payees for the user
30
+ payees = db.get_payees_by_user(user["id"])
31
+
32
+ if not payees:
33
+ dispatcher.utter_message(text="You have no payees set up.")
34
+ return []
35
+
36
+ payee_names = [payee["name"] for payee in payees]
37
+ if len(payee_names) > 1:
38
+ payees_list = ", ".join(payee_names[:-1]) + " and " + payee_names[-1]
39
+ else:
40
+ payees_list = payee_names[0]
41
+
42
+ message = f"You are authorised to transfer money to: {payees_list}"
43
+ dispatcher.utter_message(text=message)
44
+
45
+ return []
@@ -0,0 +1,18 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.events import SlotSet
5
+ from rasa_sdk.executor import CollectingDispatcher
6
+
7
+
8
+ class ActionProcessImmediatePayment(Action):
9
+ def name(self) -> Text:
10
+ return "action_process_immediate_payment"
11
+
12
+ def run(
13
+ self,
14
+ dispatcher: CollectingDispatcher,
15
+ tracker: Tracker,
16
+ domain: Dict[Text, Any],
17
+ ) -> List[Dict[Text, Any]]:
18
+ return [SlotSet("payment_processed", True)]
@@ -0,0 +1,49 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.events import SlotSet
5
+ from rasa_sdk.executor import CollectingDispatcher
6
+
7
+ from actions.database import Database
8
+
9
+
10
+ class ActionRemovePayee(Action):
11
+ def name(self) -> Text:
12
+ return "action_remove_payee"
13
+
14
+ def run(
15
+ self,
16
+ dispatcher: CollectingDispatcher,
17
+ tracker: Tracker,
18
+ domain: Dict[Text, Any],
19
+ ) -> List[Dict[Text, Any]]:
20
+ username = tracker.get_slot("username")
21
+ payee_name = tracker.get_slot("payee_name")
22
+
23
+ db = Database()
24
+
25
+ # Get user information
26
+ user = db.get_user_by_name(username)
27
+ if not user:
28
+ dispatcher.utter_message(text="User not found.")
29
+ return []
30
+
31
+ # Check if payee exists
32
+ payee = db.get_payee_by_name_and_user(payee_name, user["id"])
33
+ if not payee:
34
+ dispatcher.utter_message(
35
+ text=f"I'm sorry, but I couldn't find a payee named '{payee_name}'"
36
+ )
37
+ return [SlotSet("payee_removed", False)]
38
+
39
+ # Remove the payee
40
+ success = db.remove_payee(payee_name, user["id"])
41
+
42
+ if success:
43
+ dispatcher.utter_message(
44
+ text=f"Payee {payee_name} has been removed successfully."
45
+ )
46
+ return [SlotSet("payee_removed", True)]
47
+ else:
48
+ dispatcher.utter_message(text="Failed to remove payee. Please try again.")
49
+ return [SlotSet("payee_removed", False)]
@@ -0,0 +1,19 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.events import SlotSet
5
+ from rasa_sdk.executor import CollectingDispatcher
6
+
7
+
8
+ class ActionSchedulePayment(Action):
9
+ def name(self) -> Text:
10
+ return "action_schedule_payment"
11
+
12
+ def run(
13
+ self,
14
+ dispatcher: CollectingDispatcher,
15
+ tracker: Tracker,
16
+ domain: Dict[Text, Any],
17
+ ) -> List[Dict[Text, Any]]:
18
+ # TODO: Should this add the payment to a scheduled_payment table?
19
+ return [SlotSet("payment_scheduled", True)]
@@ -0,0 +1,69 @@
1
+ from datetime import datetime
2
+ from typing import Any, Dict, List, Text
3
+
4
+ from rasa_sdk import Action, Tracker
5
+ from rasa_sdk.events import ActionExecuted, SlotSet
6
+
7
+ from actions.database import Database
8
+
9
+
10
+ class ActionSessionStart(Action):
11
+ def name(self) -> Text:
12
+ return "action_session_start"
13
+
14
+ def set_current_date(self) -> List[Dict[Text, Any]]:
15
+ current_date = datetime.now().strftime("%d/%m/%Y")
16
+ return [SlotSet("current_date", current_date)]
17
+
18
+ def set_user_profile(self, username: str) -> List[Dict[Text, Any]]:
19
+ db = Database()
20
+
21
+ # Get user information
22
+ user = db.get_user_by_name(username)
23
+
24
+ if user:
25
+ return [
26
+ SlotSet("username", user["name"]),
27
+ SlotSet("segment", user["segment"]),
28
+ SlotSet("email_address", user["email"]),
29
+ SlotSet("physical_address", user["address"]),
30
+ ]
31
+ else:
32
+ return []
33
+
34
+ def run(
35
+ self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]
36
+ ) -> List[Dict[Text, Any]]:
37
+ current_date_events = self.set_current_date()
38
+
39
+ # Advanced option: It is possible to enable the chatbot with multiple
40
+ # user profiles.
41
+ # This option influences the interactions with the assistant.
42
+ # The bot randomly assigns a user profile at the start of each session.
43
+ # With this advance option: The demo bot will include three user profiles
44
+ # with different payees:
45
+ # John Smith: Payees: Robert (friend), James (son), Food Market (groceries)
46
+ # Mary Brown: Payees: Richard (business partner), Susan (friend),
47
+ # Electric Company (utilities)
48
+ # Dan Young: Payees: Amy (colleague), Fitness Gym (gym), William (friend)
49
+ #
50
+ # The default profile is John Smith
51
+ #
52
+ # Each profile also has its own accounts—Current (Checking), Savings,
53
+ # and Business
54
+ #
55
+ # Intructions: Just toggle the comments of the following 2 lines.
56
+ username = "John Smith"
57
+ # username = random.choice(["John Smith", "Mary Brown", "Dan Young"])
58
+
59
+ user_profile_events = self.set_user_profile(username)
60
+
61
+ events = (
62
+ current_date_events
63
+ + user_profile_events
64
+ + [
65
+ ActionExecuted("action_listen"),
66
+ ]
67
+ )
68
+
69
+ return events
@@ -0,0 +1,45 @@
1
+ from typing import Any, Dict, List, Text
2
+
3
+ from rasa_sdk import Action, Tracker
4
+ from rasa_sdk.events import SlotSet
5
+ from rasa_sdk.executor import CollectingDispatcher
6
+
7
+ from actions.database import Database
8
+
9
+
10
+ class ActionUpdateCardStatus(Action):
11
+ def name(self) -> str:
12
+ return "action_update_card_status"
13
+
14
+ def run(
15
+ self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[str, Any]
16
+ ) -> List[Dict[Text, Any]]:
17
+ username = tracker.get_slot("username")
18
+ card_number = tracker.get_slot("card_number")
19
+ new_status = "inactive"
20
+
21
+ db = Database()
22
+
23
+ # Get user information
24
+ user = db.get_user_by_name(username)
25
+ if not user:
26
+ dispatcher.utter_message(text="User not found.")
27
+ return []
28
+
29
+ # Get card information to verify it belongs to the user
30
+ card = db.get_card_by_number(card_number)
31
+ if not card or card["user_id"] != user["id"]:
32
+ dispatcher.utter_message(text="Card not found or does not belong to you.")
33
+ return []
34
+
35
+ # Update card status
36
+ success = db.update_card_status(card_number, new_status)
37
+
38
+ if success:
39
+ dispatcher.utter_message(text=f"Card status updated to {new_status}.")
40
+ return [SlotSet("card_status", new_status)]
41
+ else:
42
+ dispatcher.utter_message(
43
+ text="Failed to update card status. Please try again."
44
+ )
45
+ return []
@@ -0,0 +1,36 @@
1
+ from datetime import datetime
2
+ from typing import Any, Dict, List, Text
3
+
4
+ from rasa_sdk import Action, Tracker
5
+ from rasa_sdk.events import SlotSet
6
+ from rasa_sdk.executor import CollectingDispatcher
7
+
8
+
9
+ class ActionValidatePaymentDate(Action):
10
+ def name(self) -> Text:
11
+ return "action_validate_payment_date"
12
+
13
+ def is_future_date(self, payment_date_str: str, current_date_str: str) -> bool:
14
+ current_date = datetime.strptime(current_date_str, "%d/%m/%Y").date()
15
+ payment_date = datetime.strptime(payment_date_str, "%d/%m/%Y").date()
16
+ return payment_date > current_date
17
+
18
+ def run(
19
+ self,
20
+ dispatcher: CollectingDispatcher,
21
+ tracker: Tracker,
22
+ domain: Dict[Text, Any],
23
+ ) -> List[Dict[Text, Any]]:
24
+ current_date = tracker.get_slot("current_date")
25
+ payment_date = tracker.get_slot("payment_date")
26
+
27
+ if self.is_future_date(payment_date, current_date):
28
+ return [
29
+ SlotSet("valid_payment_date", True),
30
+ SlotSet("future_payment_date", True),
31
+ ]
32
+ else:
33
+ return [
34
+ SlotSet("valid_payment_date", True),
35
+ SlotSet("future_payment_date", False),
36
+ ]