rasa-pro 3.13.1a5__py3-none-any.whl → 3.13.1a7__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.
- rasa/cli/project_templates/finance/actions/action_add_payee.py +47 -0
- rasa/cli/project_templates/finance/actions/action_ask_account.py +50 -0
- rasa/cli/project_templates/finance/actions/action_ask_account_from.py +50 -0
- rasa/cli/project_templates/finance/actions/action_ask_card.py +47 -0
- rasa/cli/project_templates/finance/actions/action_check_balance.py +40 -0
- rasa/cli/project_templates/finance/actions/action_check_card_existence.py +35 -0
- rasa/cli/project_templates/finance/actions/action_check_payee_existence.py +40 -0
- rasa/cli/project_templates/finance/actions/action_check_sufficient_funds.py +41 -0
- rasa/cli/project_templates/finance/actions/action_list_payees.py +45 -0
- rasa/cli/project_templates/finance/actions/action_process_immediate_payment.py +18 -0
- rasa/cli/project_templates/finance/actions/action_remove_payee.py +49 -0
- rasa/cli/project_templates/finance/actions/action_schedule_payment.py +19 -0
- rasa/cli/project_templates/finance/actions/action_session_start.py +69 -0
- rasa/cli/project_templates/finance/actions/action_update_card_status.py +45 -0
- rasa/cli/project_templates/finance/actions/action_validate_payment_date.py +36 -0
- rasa/cli/project_templates/finance/actions/database.py +276 -0
- rasa/cli/project_templates/finance/config.yml +16 -1
- rasa/cli/project_templates/finance/csvs/accounts.csv +8 -0
- rasa/cli/project_templates/finance/csvs/advisors.csv +7 -0
- rasa/cli/project_templates/finance/csvs/appointments.csv +211 -0
- rasa/cli/project_templates/finance/csvs/branches.csv +10 -0
- rasa/cli/project_templates/finance/csvs/cards.csv +11 -0
- rasa/cli/project_templates/finance/csvs/payees.csv +10 -0
- rasa/cli/project_templates/finance/csvs/transactions.csv +71 -0
- rasa/cli/project_templates/finance/csvs/users.csv +4 -0
- rasa/cli/project_templates/finance/data/flows/add_payee.yml +29 -0
- rasa/cli/project_templates/finance/data/flows/block_card.yml +66 -0
- rasa/cli/project_templates/finance/data/flows/check_balance.yml +9 -0
- rasa/cli/project_templates/finance/data/flows/list_payees.yml +5 -0
- rasa/cli/project_templates/finance/data/flows/remove_payee.yml +21 -0
- rasa/cli/project_templates/finance/data/flows/select_card.yml +12 -0
- rasa/cli/project_templates/finance/data/flows/transfer_money.yml +64 -2
- rasa/cli/project_templates/finance/data/flows/welcome.yml +14 -0
- rasa/cli/project_templates/finance/data/nlu.yml +29 -0
- rasa/cli/project_templates/finance/data/patterns/pattern_chitchat.yml +7 -0
- rasa/cli/project_templates/finance/data/patterns/pattern_completed.yml +6 -0
- rasa/cli/project_templates/finance/data/patterns/pattern_search.yml +5 -0
- rasa/cli/project_templates/finance/data/patterns/pattern_session_start.yml +5 -3
- rasa/cli/project_templates/finance/data/source/accounts.json +51 -0
- rasa/cli/project_templates/finance/data/source/advisors.json +44 -0
- rasa/cli/project_templates/finance/data/source/appointments.json +1474 -0
- rasa/cli/project_templates/finance/data/source/branches.json +47 -0
- rasa/cli/project_templates/finance/data/source/cards.json +72 -0
- rasa/cli/project_templates/finance/data/source/payees.json +74 -0
- rasa/cli/project_templates/finance/data/source/transactions.json +492 -0
- rasa/cli/project_templates/finance/data/source/users.json +29 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/consequences_of_blocking_card.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/reasons_to_block_card.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/recovering_from_card_fraud.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/tips_for_card_security.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/what_to_do_if_card_is_lost.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/account_balance_security.txt +7 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/common_balance_inquiries.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/methods_to_check_balance.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/understanding_balance_updates.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/what_to_do_if_balance_is_incorrect.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/benefits_of_authorised_payees.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/common_issues_with_payees.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/general_payee_information.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/payee_management_tips.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/understanding_payee_types.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/common_transfer_errors.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/fees_for_transfers.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/general_transfer_information.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/security_tips_for_transfers.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/transfer_processing_times.txt +8 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part1.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part10.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part11.txt +48 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part12.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part13.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part14.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part15.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part16.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part17.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part18.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part19.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part2.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part20.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part21.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part22.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part23.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part24.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part25.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part26.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part27.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part28.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part29.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part3.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part30.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part31.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part32.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part33.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part34.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part35.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part36.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part37.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part38.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part39.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part4.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part40.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part41.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part42.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part43.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part44.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part45.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part46.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part47.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part48.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part49.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part5.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part50.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part51.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part52.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part53.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part54.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part55.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part56.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part57.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part58.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part59.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part6.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part60.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part61.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part7.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part8.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part9.txt +47 -0
- rasa/cli/project_templates/finance/domain/add_payee.yml +47 -0
- rasa/cli/project_templates/finance/domain/block_card.yml +101 -0
- rasa/cli/project_templates/finance/domain/check_balance.yml +9 -0
- rasa/cli/project_templates/finance/domain/default_actions.yml +16 -0
- rasa/cli/project_templates/finance/domain/default_flows.yml +33 -0
- rasa/cli/project_templates/finance/domain/list_payees.yml +4 -0
- rasa/cli/project_templates/finance/domain/remove_payee.yml +16 -0
- rasa/cli/project_templates/finance/domain/select_card.yml +12 -0
- rasa/cli/project_templates/finance/domain/transfer_money.yml +79 -0
- rasa/cli/project_templates/finance/endpoints.yml +6 -2
- rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +19 -0
- rasa/cli/project_templates/finance/tests/conversation_repair/cancellations.yml +12 -0
- rasa/cli/project_templates/finance/tests/conversation_repair/cannot_handle.yml +7 -0
- rasa/cli/project_templates/finance/tests/conversation_repair/chitchat.yml +7 -0
- rasa/cli/project_templates/finance/tests/conversation_repair/clarification.yml +9 -0
- rasa/cli/project_templates/finance/tests/conversation_repair/completion.yml +18 -0
- rasa/cli/project_templates/finance/tests/conversation_repair/corrections.yml +17 -0
- rasa/cli/project_templates/finance/tests/conversation_repair/digressions.yml +32 -0
- rasa/cli/project_templates/finance/tests/conversation_repair/human_handoff.yml +21 -0
- rasa/cli/project_templates/finance/tests/conversation_repair/skipping_collect_steps.yml +16 -0
- rasa/cli/project_templates/finance/tests/demo_scripts/main.yml +16 -0
- rasa/cli/project_templates/finance/tests/happy_paths/balance_verification.yml +15 -0
- rasa/cli/project_templates/finance/tests/happy_paths/banking_questions.yml +12 -0
- rasa/cli/project_templates/finance/tests/happy_paths/card_blocking.yml +52 -0
- rasa/cli/project_templates/finance/tests/happy_paths/money_transfer.yml +136 -0
- rasa/cli/project_templates/finance/tests/happy_paths/payee_management.yml +27 -0
- rasa/cli/project_templates/finance/tests/happy_paths/user_greeted.yml +5 -0
- rasa/cli/project_templates/plain/domain.yml +1 -1
- rasa/cli/project_templates/telco/actions/actions_billing.py +196 -0
- rasa/cli/project_templates/telco/actions/actions_get_data_from_db.py +42 -0
- rasa/cli/project_templates/telco/prompts/command-generator.jinja2 +57 -0
- rasa/cli/scaffold.py +1 -1
- rasa/core/policies/enterprise_search_policy.py +1 -1
- rasa/dialogue_understanding/generator/flow_retrieval.py +10 -9
- rasa/version.py +1 -1
- {rasa_pro-3.13.1a5.dist-info → rasa_pro-3.13.1a7.dist-info}/METADATA +1 -1
- {rasa_pro-3.13.1a5.dist-info → rasa_pro-3.13.1a7.dist-info}/RECORD +201 -51
- rasa/cli/project_templates/finance/domain.yml +0 -7
- rasa/cli/project_templates/teleco/actions/actions_billing.py +0 -151
- rasa/cli/project_templates/teleco/actions/actions_get_data_from_db.py +0 -27
- /rasa/cli/project_templates/{teleco → finance}/prompts/command-generator.jinja2 +0 -0
- /rasa/cli/project_templates/{teleco → telco}/actions/actions_run_diagnostics.py +0 -0
- /rasa/cli/project_templates/{teleco → telco}/actions/actions_session_start.py +0 -0
- /rasa/cli/project_templates/{teleco → telco}/config.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/credentials.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/csvs/billing.csv +0 -0
- /rasa/cli/project_templates/{teleco → telco}/csvs/customers.csv +0 -0
- /rasa/cli/project_templates/{teleco → telco}/data/flows/flow_global.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/data/flows/flow_reboot_router.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/data/flows/flow_reset_router.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/data/flows/flow_solve_internet_issue.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/data/flows/flow_undertand_bill.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/data/patterns/pattern_completed.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/data/patterns/pattern_human_handoff.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/data/patterns/pattern_search.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/data/patterns/pattern_session_start.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/docs/reset_vs_rboot_router.txt +0 -0
- /rasa/cli/project_templates/{teleco → telco}/docs/restart_router.txt +0 -0
- /rasa/cli/project_templates/{teleco → telco}/docs/run_speed_test.txt +0 -0
- /rasa/cli/project_templates/{teleco → telco}/domain/domain_global.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/domain/domain_patterns.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/domain/domain_reboot_router.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/domain/domain_reset_router.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/domain/domain_run_speed_test.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/domain/domain_solve_internet_issue.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/domain/domain_undertand_bill.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/endpoints.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/tests/e2e_results_failed.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/tests/e2e_results_passed.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/tests/e2e_test_cases/billing_test_cases.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/tests/e2e_test_cases/global_test_cases.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/tests/e2e_test_cases/internet_slow_test_case.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/tests/e2e_test_cases/out_of_scope_test_case.yml +0 -0
- /rasa/cli/project_templates/{teleco → telco}/tests/e2e_test_cases/patterns_test_cases.yml +0 -0
- {rasa_pro-3.13.1a5.dist-info → rasa_pro-3.13.1a7.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.1a5.dist-info → rasa_pro-3.13.1a7.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.1a5.dist-info → rasa_pro-3.13.1a7.dist-info}/entry_points.txt +0 -0
|
@@ -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
|
+
]
|