@@ -1 +0,0 @@ | |||||
{"py/object": "rasa.core.featurizers.tracker_featurizers.MaxHistoryTrackerFeaturizer", "state_featurizer": null, "max_history": null, "remove_duplicates": true} |
@@ -1,33 +0,0 @@ | |||||
{ | |||||
"lookup": { | |||||
"eJyLrq6NBQAEOAGx": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohJzWxOLW2NhYA6ZsbeA==": "utter_lease", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohJzWxOLWWgBmlJSWpRfEQpbhMiAUAPa80cA==": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohv7QkPj8tvjg5vyC1tjYWALYRHnM=": "utter_default", | |||||
"eJyFjMEJwCAMAFfJAJ3AVUoJohEEm4gm/Yi7V2j//u7guHPMA0Zt9KAPmoUdjA+Q/U0Ofim5K/FqrVNbTeal6kBMURL2IJXmZmWq1DBS8lZ0t7pe19c7QQ==": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohOT+3ID8PyIx3qq2NBQCW6h3i": "utter_component_B", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohOT+3ID8PyIx3qiVgUmlJSWpRPLIG/KbFAgBBpzuu": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEqhuDSpODOlMt6xtjYWAFvNHRE=": "utter_subsidy_A", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEqhuDSpODOlMt6xloA5pSUlqUXxCOX4TIoFANwHOTs=": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohNSczPTMpJzXeubY2FgB3lR1N": "utter_eligible_C", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohNSczPTMpJzXeuZaAQaUlJalF8Ujq8ZoVCwB2Njnv": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohOT+3ID8PyIx3rK2NBQCW5h3h": "utter_component_A", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohOT+3ID8PyIx3rCVgUmlJSWpRPLIG/KbFAgBBMDur": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohNSczPTMpJzXeqbY2FgB3kR1M": "utter_eligible_B", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohNSczPTMpJzXeqZaAQaUlJalF8Ujq8ZoVCwB1wjns": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohLTMvMS85MzGntjYWAFr6HRM=": "utter_financial", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohLTMvMS85MzGnloA5pSUlqUXxCOX4TIoFANpYOUE=": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEqhODkjNTe1tjYWAAWTG+M=": "utter_scheme", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEqhODkjNTe1loAhpSUlqUXxULU4zYgFAOF7NbE=": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohNSc1uaQoMzmzpLK2NhYAlxweDw==": "utter_electricity", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohNSc1uaQoMzmzpLKWgEmlJSWpRfHIGvCbFgsAVQw8NQ==": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEqhuDSpODOlMt6ptjYWAFvRHRI=": "utter_subsidy_B", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEqhuDSpODOlMt6ploA5pSUlqUXxCOX4TIoFANx4OT4=": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohOT+3ID8PyIx3rq2NBQCW7h3j": "utter_component_C", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohOT+3ID8PyIx3riVgUmlJSWpRPLIG/KbFAgBCHjux": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohNSczPTMpJzXesbY2FgB3jR1L": "utter_eligible_A", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohNSczPTMpJzXesZaAQaUlJalF8Ujq8ZoVCwB1Tjnp": "action_listen", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohMy8tvyg3EaSmtjYWAJevHhQ=": "utter_information", | |||||
"eJyLrq7VUaguKEoti09MLsnMz7NSqIYw4vMSc1OtFKCcnMziktQ8oNrS4tQioJrMPCC3xEohMy8tvyg3EaSmloBJpSUlqUXxyBrwmxYLAFjcPEQ=": "action_listen" | |||||
} | |||||
} |
@@ -1 +0,0 @@ | |||||
{"py/object": "rasa.core.featurizers.tracker_featurizers.MaxHistoryTrackerFeaturizer", "state_featurizer": null, "max_history": null, "remove_duplicates": true} |
@@ -1,4 +0,0 @@ | |||||
{ | |||||
"rule_only_slots": [], | |||||
"rule_only_loops": [] | |||||
} |
@@ -1,30 +0,0 @@ | |||||
{ | |||||
"lookup": { | |||||
"rules": { | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"greet\"}}]": "utter_greet", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"greet\"}}, {\"prev_action\": {\"action_name\": \"utter_greet\"}, \"user\": {\"intent\": \"greet\"}}]": "action_listen", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"bot_challenge\"}}]": "utter_iamabot", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"bot_challenge\"}}, {\"prev_action\": {\"action_name\": \"utter_iamabot\"}, \"user\": {\"intent\": \"bot_challenge\"}}]": "action_listen", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"goodbye\"}}]": "utter_goodbye", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"goodbye\"}}, {\"prev_action\": {\"action_name\": \"utter_goodbye\"}, \"user\": {\"intent\": \"goodbye\"}}]": "action_listen", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"thanking\"}}]": "utter_your_welcome", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"thanking\"}}, {\"prev_action\": {\"action_name\": \"utter_your_welcome\"}, \"user\": {\"intent\": \"thanking\"}}]": "action_listen" | |||||
}, | |||||
"rule_only_slots": [], | |||||
"rule_only_loops": [], | |||||
"rules_for_loop_unhappy_path": {}, | |||||
"rules_not_in_stories": [ | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"goodbye\"}}]", | |||||
"predicting default action with intent session_start", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"thanking\"}}]", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"thanking\"}}, {\"prev_action\": {\"action_name\": \"utter_your_welcome\"}, \"user\": {\"intent\": \"thanking\"}}]", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"bot_challenge\"}}]", | |||||
"predicting default action with intent back", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"greet\"}}]", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"bot_challenge\"}}, {\"prev_action\": {\"action_name\": \"utter_iamabot\"}, \"user\": {\"intent\": \"bot_challenge\"}}]", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"goodbye\"}}, {\"prev_action\": {\"action_name\": \"utter_goodbye\"}, \"user\": {\"intent\": \"goodbye\"}}]", | |||||
"[{\"prev_action\": {\"action_name\": \"action_listen\"}, \"user\": {\"intent\": \"greet\"}}, {\"prev_action\": {\"action_name\": \"utter_greet\"}, \"user\": {\"intent\": \"greet\"}}]", | |||||
"predicting default action with intent restart" | |||||
] | |||||
} | |||||
} |
@@ -1 +0,0 @@ | |||||
[] |
@@ -1 +0,0 @@ | |||||
{"0": "bot_challenge", "1": "component_A", "2": "component_B", "3": "component_C", "4": "electricity", "5": "eligible_A", "6": "eligible_B", "7": "eligible_C", "8": "financial", "9": "goodbye", "10": "greet", "11": "information", "12": "lease", "13": "out_of_scope", "14": "scheme", "15": "start", "16": "subsidy_A", "17": "subsidy_B", "18": "thanking"} |
@@ -1,2 +0,0 @@ | |||||
model_checkpoint_path: "DIETClassifier.tf_model" | |||||
all_model_checkpoint_paths: "DIETClassifier.tf_model" |
@@ -1 +0,0 @@ | |||||
{"json://{\"py/tuple\": [0, \"low\"]}": {"False": 0, "True": 1}, "json://{\"py/tuple\": [0, \"title\"]}": {"False": 2, "True": 3}, "json://{\"py/tuple\": [0, \"upper\"]}": {"False": 4, "True": 5}, "json://{\"py/tuple\": [1, \"BOS\"]}": {"False": 6, "True": 7}, "json://{\"py/tuple\": [1, \"EOS\"]}": {"False": 8, "True": 9}, "json://{\"py/tuple\": [1, \"digit\"]}": {"False": 10, "True": 11}, "json://{\"py/tuple\": [1, \"low\"]}": {"False": 12, "True": 13}, "json://{\"py/tuple\": [1, \"title\"]}": {"False": 14, "True": 15}, "json://{\"py/tuple\": [1, \"upper\"]}": {"False": 16, "True": 17}, "json://{\"py/tuple\": [2, \"low\"]}": {"False": 18, "True": 19}, "json://{\"py/tuple\": [2, \"title\"]}": {"False": 20, "True": 21}, "json://{\"py/tuple\": [2, \"upper\"]}": {"False": 22, "True": 23}} |
@@ -1 +0,0 @@ | |||||
[] |
@@ -1,2 +0,0 @@ | |||||
model_checkpoint_path: "ted_policy.tf_model" | |||||
all_model_checkpoint_paths: "ted_policy.tf_model" |
@@ -1 +0,0 @@ | |||||
{"py/object": "rasa.core.featurizers.tracker_featurizers.MaxHistoryTrackerFeaturizer", "state_featurizer": {"py/object": "rasa.core.featurizers.single_state_featurizer.SingleStateFeaturizer", "_default_feature_states": {"intent": {"back": 0, "bot_challenge": 1, "component_A": 2, "component_B": 3, "component_C": 4, "electricity": 5, "eligible_A": 6, "eligible_B": 7, "eligible_C": 8, "financial": 9, "goodbye": 10, "greet": 11, "information": 12, "lease": 13, "nlu_fallback": 14, "out_of_scope": 15, "restart": 16, "scheme": 17, "session_start": 18, "start": 19, "subsidy_A": 20, "subsidy_B": 21, "thanking": 22}, "action_name": {"action_listen": 0, "action_restart": 1, "action_session_start": 2, "action_default_fallback": 3, "action_deactivate_loop": 4, "action_revert_fallback_events": 5, "action_default_ask_affirmation": 6, "action_default_ask_rephrase": 7, "action_two_stage_fallback": 8, "action_unlikely_intent": 9, "action_back": 10, "...": 11, "action_extract_slots": 12, "utter_component_A": 13, "utter_component_B": 14, "utter_component_C": 15, "utter_default": 16, "utter_electricity": 17, "utter_eligible_A": 18, "utter_eligible_B": 19, "utter_eligible_C": 20, "utter_email": 21, "utter_financial": 22, "utter_goodbye": 23, "utter_greet": 24, "utter_iamabot": 25, "utter_information": 26, "utter_lease": 27, "utter_name": 28, "utter_scheme": 29, "utter_subsidy_A": 30, "utter_subsidy_B": 31, "utter_your_welcome": 32}, "entities": {}, "slots": {}, "active_loop": {}}, "action_texts": [], "entity_tag_specs": null}, "max_history": 5, "remove_duplicates": true} |
@@ -1 +0,0 @@ | |||||
[] |
@@ -1 +0,0 @@ | |||||
1 |
@@ -1 +0,0 @@ | |||||
[] |
@@ -1 +0,0 @@ | |||||
{"text": {"scheme": 78, "what": 103, "are": 7, "the": 95, "different": 27, "kind": 56, "of": 67, "systems": 90, "supported": 89, "under": 100, "pm": 71, "kusum": 57, "is": 55, "tell": 92, "me": 61, "about": 2, "give": 40, "some": 84, "information": 52, "highlights": 47, "component": 22, "a": 1, "can": 19, "i": 50, "get": 39, "informaton": 53, "comp": 21, "details": 25, "eligible": 30, "who": 105, "eligibility": 29, "apply": 6, "for": 36, "will": 107, "purchase": 75, "generated": 38, "electricity": 28, "buy": 15, "be": 11, "bought": 14, "by": 16, "whom": 106, "farmers": 33, "lease": 60, "their": 96, "land": 58, "development": 26, "renewable": 76, "energy": 31, "power": 72, "plant": 69, "financial": 34, "support": 88, "available": 9, "b": 10, "inform": 51, "there": 97, "any": 5, "subsidy": 87, "installation": 54, "solar": 82, "pump": 74, "c": 18, "criteria": 23, "solarisation": 83, "where": 104, "more": 62, "hey": 45, "hello": 44, "hi": 46, "good": 41, "morning": 63, "evening": 32, "afternoon": 3, "night": 66, "bye": 17, "goodbye": 42, "have": 43, "nice": 65, "day": 24, "see": 79, "you": 108, "around": 8, "later": 59, "bot": 13, "human": 48, "am": 4, "talking": 91, "to": 98, "want": 102, "order": 68, "food": 35, "__number__": 0, "s": 77, "us": 101, "president": 73, "book": 12, "car": 20, "play": 70, "something": 85, "show": 80, "games": 37, "hungry": 49, "thank": 93, "thanks": 94, "so": 81, "much": 64, "u": 99, "start": 86}, "intent": {"scheme": 14, "component_a": 1, "eligible_a": 5, "electricity": 4, "lease": 12, "financial": 8, "component_b": 2, "eligible_b": 6, "subsidy_a": 16, "component_c": 3, "eligible_c": 7, "subsidy_b": 17, "information": 11, "greet": 10, "goodbye": 9, "bot_challenge": 0, "out_of_scope": 13, "thanking": 18, "start": 15}, "response": null, "action_name": {"action_listen": 6, "action_restart": 7, "action_session_start": 9, "action_default_fallback": 4, "action_deactivate_loop": 1, "action_revert_fallback_events": 8, "action_default_ask_affirmation": 2, "action_default_ask_rephrase": 3, "action_two_stage_fallback": 10, "action_unlikely_intent": 11, "action_back": 0, "action_extract_slots": 5, "utter_component_a": 12, "utter_component_b": 13, "utter_component_c": 14, "utter_default": 15, "utter_electricity": 16, "utter_eligible_a": 17, "utter_eligible_b": 18, "utter_eligible_c": 19, "utter_financial": 20, "utter_goodbye": 21, "utter_greet": 22, "utter_iamabot": 23, "utter_information": 24, "utter_lease": 25, "utter_scheme": 26, "utter_subsidy_a": 27, "utter_subsidy_b": 28, "utter_your_welcome": 29}, "action_text": null, "intent_response_key": null} |
@@ -1,2 +0,0 @@ | |||||
model_checkpoint_path: "unexpected_intent_policy.tf_model" | |||||
all_model_checkpoint_paths: "unexpected_intent_policy.tf_model" |
@@ -1 +0,0 @@ | |||||
{"py/object": "rasa.core.featurizers.tracker_featurizers.IntentMaxHistoryTrackerFeaturizer", "state_featurizer": {"py/object": "rasa.core.featurizers.single_state_featurizer.IntentTokenizerSingleStateFeaturizer", "_default_feature_states": {"intent": {"back": 0, "bot_challenge": 1, "component_A": 2, "component_B": 3, "component_C": 4, "electricity": 5, "eligible_A": 6, "eligible_B": 7, "eligible_C": 8, "financial": 9, "goodbye": 10, "greet": 11, "information": 12, "lease": 13, "nlu_fallback": 14, "out_of_scope": 15, "restart": 16, "scheme": 17, "session_start": 18, "start": 19, "subsidy_A": 20, "subsidy_B": 21, "thanking": 22}, "action_name": {"action_listen": 0, "action_restart": 1, "action_session_start": 2, "action_default_fallback": 3, "action_deactivate_loop": 4, "action_revert_fallback_events": 5, "action_default_ask_affirmation": 6, "action_default_ask_rephrase": 7, "action_two_stage_fallback": 8, "action_unlikely_intent": 9, "action_back": 10, "...": 11, "action_extract_slots": 12, "utter_component_A": 13, "utter_component_B": 14, "utter_component_C": 15, "utter_default": 16, "utter_electricity": 17, "utter_eligible_A": 18, "utter_eligible_B": 19, "utter_eligible_C": 20, "utter_email": 21, "utter_financial": 22, "utter_goodbye": 23, "utter_greet": 24, "utter_iamabot": 25, "utter_information": 26, "utter_lease": 27, "utter_name": 28, "utter_scheme": 29, "utter_subsidy_A": 30, "utter_subsidy_B": 31, "utter_your_welcome": 32}, "entities": {}, "slots": {}, "active_loop": {}}, "action_texts": [], "entity_tag_specs": null}, "max_history": 5, "remove_duplicates": true} |
@@ -1 +0,0 @@ | |||||
[] |
@@ -1 +0,0 @@ | |||||
2 |
@@ -1 +0,0 @@ | |||||
[] |
@@ -11,7 +11,7 @@ from typing import Any, Text, Dict, List | |||||
from rasa_sdk import Action, Tracker | from rasa_sdk import Action, Tracker | ||||
from rasa_sdk.executor import CollectingDispatcher | from rasa_sdk.executor import CollectingDispatcher | ||||
from database_connectivity import DataUpdate | |||||
from connect_to_database import UpdateData | |||||
import datetime | import datetime | ||||
# | # | ||||
# | # | ||||
@@ -28,22 +28,30 @@ import datetime | |||||
# | # | ||||
# return [] | # return [] | ||||
# class ActionHelloWorld(Action): | |||||
#FOR GETTING THE USER'S BROWSER AND DEVICE INFORMATION THROUGH CUSTOM DATA. | |||||
# class ActionGetData(Action): | |||||
# def name(self) -> Text: | # def name(self) -> Text: | ||||
# return "action_hello_world" | |||||
# return "action_get_data" | |||||
# def run(self, dispatcher: CollectingDispatcher, | # def run(self, dispatcher: CollectingDispatcher, | ||||
# tracker: Tracker, | # tracker: Tracker, | ||||
# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: | # domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: | ||||
# dispatcher.utter_message(text="Hello World!") | |||||
# events = tracker.current_state()['events'] | |||||
# user_events = [] | |||||
# for e in events: | |||||
# if e['event'] == 'user': | |||||
# user_events.append(e) | |||||
# return [] | |||||
# custom_data = user_events[-1]['metadata'] | |||||
# print(custom_data) | |||||
# return [] | |||||
#FOR DATABASE CONNECTIVITY AND UPDATION. | |||||
#FOR DATABASE CONNECTIVITY AND UPDATION (NAME, EMAIL, DATE, SESSION ID). | |||||
# class ActionSubmit(Action): | # class ActionSubmit(Action): | ||||
# def name(self) -> Text: | # def name(self) -> Text: | ||||
# return "action_submit" | # return "action_submit" | ||||
@@ -55,4 +63,26 @@ import datetime | |||||
# current_time = str(datetime.datetime.now()) | # current_time = str(datetime.datetime.now()) | ||||
# current_time = current_time.split(":") | # current_time = current_time.split(":") | ||||
# current_time = current_time[0] + ":" + current_time[1] | # current_time = current_time[0] + ":" + current_time[1] | ||||
# DataUpdate(tracker.get_slot("name"),tracker.get_slot("email"), current_time, tracker.sender_id) | |||||
# DataUpdate(tracker.get_slot("name"),tracker.get_slot("email"), current_time, tracker.sender_id) | |||||
#GET THE USER'S BROWSER AND DEVICE INFORMATION THROUGH INIT PAYLOAD AND UPDATE THE TABLE USER_DEVICE_IMFORMATION. | |||||
class ActionUpdateData(Action): | |||||
def name(self) -> Text: | |||||
return "action_update_data" | |||||
def run(self, dispatcher: CollectingDispatcher, | |||||
tracker: Tracker, | |||||
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: | |||||
device = tracker.get_slot("device_and_browser").split(",")[0].capitalize() | |||||
browser = tracker.get_slot("device_and_browser").split(",")[1].capitalize() | |||||
current_time = str(datetime.datetime.now()) | |||||
current_time = current_time.split(":") | |||||
current_time = current_time[0] + ":" + current_time[1] | |||||
current_time = datetime.datetime.strptime(current_time, "%Y-%m-%d %H:%M") | |||||
UpdateData(device, browser, current_time, tracker.sender_id) | |||||
@@ -1,6 +1,6 @@ | |||||
import mysql.connector | import mysql.connector | ||||
def DataUpdate(name, email, date, session_id): | |||||
def UpdateData(device, browser, date, session_id): | |||||
mydb = mysql.connector.connect( | mydb = mysql.connector.connect( | ||||
host = "localhost", | host = "localhost", | ||||
user = "root", | user = "root", | ||||
@@ -11,13 +11,10 @@ def DataUpdate(name, email, date, session_id): | |||||
mycursor = mydb.cursor() | mycursor = mydb.cursor() | ||||
#sql = "CREATE TABLE user_information (Name VARCHAR(255), Email VARCHAR(255), Date VARCHAR(255), Session ID VARCHAR(255));" | #sql = "CREATE TABLE user_information (Name VARCHAR(255), Email VARCHAR(255), Date VARCHAR(255), Session ID VARCHAR(255));" | ||||
sql = 'INSERT INTO user_data (Name, Email, Date, Session_ID) VALUES ("{}", "{}", "{}", "{}");'.format(name, email, date, session_id) | |||||
sql = 'INSERT INTO user_device_information VALUES ("{}", "{}", "{}", "{}");'.format(device, browser, date, session_id) | |||||
mycursor.execute(sql) | mycursor.execute(sql) | ||||
mydb.commit() | mydb.commit() | ||||
print("Successful!") | |||||
#if __name__ == "__main__": | |||||
#DataUpdate("siddharth", "siddharth@gmail.com") | |||||
print("Successful!") |
@@ -22,6 +22,11 @@ socketio: | |||||
bot_message_evt: bot_uttered | bot_message_evt: bot_uttered | ||||
session_persistence: true | session_persistence: true | ||||
# socketChannel.SocketIOInput: | |||||
# user_message_evt: user_uttered | |||||
# bot_message_evt: bot_uttered | |||||
# session_persistence: true | |||||
#mattermost: | #mattermost: | ||||
# url: "https://<mattermost instance>/api/v4" | # url: "https://<mattermost instance>/api/v4" | ||||
# token: "<bot token>" | # token: "<bot token>" | ||||
@@ -6,6 +6,7 @@ rules: | |||||
steps: | steps: | ||||
- intent: greet | - intent: greet | ||||
- action: utter_greet | - action: utter_greet | ||||
- action: action_update_data | |||||
- rule: Say goodbye anytime the user says goodbye | - rule: Say goodbye anytime the user says goodbye | ||||
steps: | steps: | ||||
@@ -35,6 +35,16 @@ intents: | |||||
# - type: from_text | # - type: from_text | ||||
# intent: email | # intent: email | ||||
entities: | |||||
- device_and_browser | |||||
slots: | |||||
device_and_browser: | |||||
type: text | |||||
mappings: | |||||
- type: from_entity | |||||
entity: device_and_browser | |||||
responses: | responses: | ||||
utter_eligible_A: | utter_eligible_A: | ||||
- text: "Individual farmers/group of farmers/cooperatives/panchayats/Farmer Producer Organisations (FPO)/Water User associations (WUA). Land on which the project is proposed to be installed should be within 5 km from the nearest electricity sub-station." | - text: "Individual farmers/group of farmers/cooperatives/panchayats/Farmer Producer Organisations (FPO)/Water User associations (WUA). Land on which the project is proposed to be installed should be within 5 km from the nearest electricity sub-station." | ||||
@@ -194,8 +204,8 @@ responses: | |||||
utter_email: | utter_email: | ||||
- text: "Enter your email ID: " | - text: "Enter your email ID: " | ||||
# actions: | |||||
# - action_submit | |||||
actions: | |||||
- action_update_data | |||||
session_config: | session_config: | ||||
session_expiration_time: 60 | session_expiration_time: 60 |
@@ -1,180 +0,0 @@ | |||||
<html> | |||||
<head> | |||||
<style> | |||||
/* Some miscellenous widget manipulation */ | |||||
.rw-launcher { | |||||
-webkit-animation-delay: 0; | |||||
-webkit-animation-duration: 0.5s; | |||||
-webkit-animation-name: slide-in; | |||||
-webkit-animation-fill-mode: forwards; | |||||
-moz-animation-delay: 0; | |||||
-moz-animation-duration: 0.5s; | |||||
-moz-animation-name: slide-in; | |||||
-moz-animation-fill-mode: forwards; | |||||
animation-delay: 0; | |||||
animation-duration: 0.5s; | |||||
animation-name: slide-in; | |||||
animation-fill-mode: forwards; | |||||
display: flex; | |||||
align-items: center !important; | |||||
justify-content: center; | |||||
background-color: white !important; | |||||
border: 0 !important; | |||||
box-shadow: 0 2px 10px 1px white!important; | |||||
height: 125px !important; | |||||
margin: 0; | |||||
width: 125px !important; | |||||
box-sizing:border-box | |||||
} | |||||
/* Resizing the widget */ | |||||
.rw-launcher img { | |||||
width: 125 !important; | |||||
max-height: 125 !important; | |||||
object-fit: contain !important; | |||||
} | |||||
/* Getting rid of the rotation animation of the widget while closing */ | |||||
.rw-close-launcher { | |||||
-webkit-animation-delay: 0; | |||||
-webkit-animation-duration: 0s !important; | |||||
-webkit-animation-name: rotation-lr !important; | |||||
-webkit-animation-fill-mode: forwards; | |||||
-moz-animation-delay: 0; | |||||
-moz-animation-duration: 0s !important; | |||||
-moz-animation-name: rotation-lr !important; | |||||
-moz-animation-fill-mode: forwards; | |||||
animation-delay: 0; | |||||
animation-duration: 0s !important; | |||||
animation-name: rotation-lr !important; | |||||
animation-fill-mode: forwards; | |||||
} | |||||
/* Getting rid of the rotation animation of the widget while opening */ | |||||
.rw-open-launcher { | |||||
-webkit-animation-delay: 0; | |||||
-webkit-animation-duration: 0.5s; | |||||
-webkit-animation-name: rotation-rl; | |||||
-webkit-animation-fill-mode: forwards; | |||||
-moz-animation-delay: 0; | |||||
-moz-animation-duration: .5s; | |||||
-moz-animation-name: rotation-rl; | |||||
-moz-animation-fill-mode: forwards; | |||||
animation-delay: 0; | |||||
animation-duration: 0s !important; | |||||
animation-name: rotation-rl; | |||||
animation-fill-mode: forwards; | |||||
} | |||||
</style> | |||||
</head> | |||||
<body> | |||||
<style> | |||||
/* Background color for the header */ | |||||
.rw-conversation-container .rw-header{background-color: #233e80;} | |||||
/* Correction of the shadow for the chat window */ | |||||
.rw-conversation-container { | |||||
-webkit-animation-delay: 0; | |||||
-webkit-animation-duration: .5s; | |||||
-webkit-animation-name: slide-in; | |||||
-webkit-animation-fill-mode: forwards; | |||||
-moz-animation-delay: 0; | |||||
-moz-animation-duration: .5s; | |||||
-moz-animation-name: slide-in; | |||||
-moz-animation-fill-mode: forwards; | |||||
animation-delay: 0; | |||||
animation-duration: .5s; | |||||
animation-name: slide-in; | |||||
animation-fill-mode: forwards; | |||||
border-radius: 10px; | |||||
box-shadow: 0px -20px 12px 0px hsl(0deg 14% 89% / 0%), inset 4px -7px 3.7px -1px rgb(0 0 0 / 7%), 0 5px 7px -1px hsl(0deg 0% 0% / 9%), 2px -8px 12.5px -1px rgb(84 25 25 / 10%), 2px -6px 23.4px 0px rgb(255 0 0 / 12%), inset -3px -5px 56px 0px rgb(237 0 0 / 17%); | |||||
overflow: hidden; | |||||
width: 370px; | |||||
} | |||||
/* Resizing avatar (to the left of replies) */ | |||||
.rw-conversation-container .rw-avatar { | |||||
width: 55px; | |||||
height: 55px; | |||||
border-radius: 100%; | |||||
margin-right: -3px; | |||||
/* position: relative; */ | |||||
bottom: 0px; | |||||
} | |||||
/* Positioning the avatar to the left of replies rather than at the top*/ | |||||
.rw-conversation-container .rw-message { | |||||
margin: 10px; | |||||
font-size: 16px; | |||||
line-height: 20px; | |||||
display: flex; | |||||
font-family: Inter,sans-serif; | |||||
flex-wrap: unset !important; | |||||
position: relative; | |||||
} | |||||
/* Header avatar resizing */ | |||||
.rw-conversation-container .rw-header .rw-avatar { | |||||
all: initial; | |||||
height: 57px; | |||||
width: 57px; | |||||
position: absolute; | |||||
top: 4px; | |||||
left: 0px; | |||||
} | |||||
/* Color box for buttons (payload) */ | |||||
.rw-conversation-container .rw-reply { | |||||
-webkit-transition: box-shadow .3s ease,top .3s ease; | |||||
-moz-transition: box-shadow .3s ease,top .3s ease; | |||||
-o-transition: box-shadow .3s ease,top .3s ease; | |||||
transition: box-shadow .3s ease,top .3s ease; | |||||
display: -webkit-box; | |||||
display: -webkit-flex; | |||||
display: -moz-box; | |||||
display: -ms-flexbox; | |||||
display: flex; | |||||
-webkit-flex-align: center; | |||||
-ms-flex-align: center; | |||||
-webkit-align-items: center; | |||||
align-items: center; | |||||
background-color: #fafafa; | |||||
border: 1px solid #135afe; | |||||
border-radius: 15px; | |||||
color: #233e80; | |||||
padding: 4px 8px; | |||||
max-width: 215px; | |||||
min-height: 1.7em; | |||||
font-weight: 500; | |||||
text-align: center; | |||||
font-family: Inter,sans-serif; | |||||
cursor: pointer; | |||||
margin: 0.25em; | |||||
text-decoration: unset; | |||||
box-shadow: unset !important/*0 .2px .7px -7pxrgba(0,0,0,.277),0 .5px 1.8px -7pxrgba(0,0,0,.369),0 1.2px 3.8px -7pxrgba(0,0,0,.442),0 4px 13px -7pxrgba(0,0,0,.64);*/ | |||||
} | |||||
</style> | |||||
<script>!(function () { | |||||
let e = document.createElement("script"), | |||||
t = document.head || document.getElementsByTagName("head")[0]; | |||||
(e.src = | |||||
"https://cdn.jsdelivr.net/npm/rasa-webchat@1.x.x/lib/index.js"), | |||||
// Replace 1.x.x with the version that you want | |||||
(e.async = !0), | |||||
(e.onload = () => { | |||||
window.localStorage.clear() | |||||
window.WebChat.default( | |||||
{ | |||||
initPayload: '/greet', | |||||
customData: { language: "en" }, | |||||
socketUrl: "http://localhost:5005", | |||||
profileAvatar: "./assets/bot_widget-removebg-preview.png", | |||||
openLauncherImage: "./assets/robo_small.gif", | |||||
closeImage: "./assets/robo_small.gif", | |||||
title: "PM-KUSUM", | |||||
inputTextFieldHint: "Start a conversation", | |||||
connectingText: 'Waiting for server...', | |||||
showCloseButton: true | |||||
// add other props here | |||||
}, | |||||
null | |||||
); | |||||
}), | |||||
t.insertBefore(e, t.firstChild); | |||||
})(); | |||||
</script> | |||||
</body> | |||||
</html> |
@@ -0,0 +1,197 @@ | |||||
from importlib.metadata import metadata | |||||
import logging | |||||
import warnings | |||||
import uuid | |||||
from sanic import Blueprint, response | |||||
from sanic.request import Request | |||||
from sanic.response import HTTPResponse | |||||
from socketio import AsyncServer | |||||
from typing import Optional, Text, Any, List, Dict, Iterable, Callable, Awaitable | |||||
from rasa.core.channels.channel import InputChannel | |||||
from rasa.core.channels.channel import UserMessage, OutputChannel | |||||
logger = logging.getLogger(__name__) | |||||
class SocketBlueprint(Blueprint): | |||||
def __init__(self, sio: AsyncServer, socketio_path, *args, **kwargs): | |||||
self.sio = sio | |||||
self.socketio_path = socketio_path | |||||
super().__init__(*args, **kwargs) | |||||
def register(self, app, options): | |||||
self.sio.attach(app, self.socketio_path) | |||||
super().register(app, options) | |||||
class SocketIOOutput(OutputChannel): | |||||
@classmethod | |||||
def name(cls): | |||||
return "socketio" | |||||
def __init__(self, sio, sid, bot_message_evt): | |||||
self.sio = sio | |||||
self.sid = sid | |||||
self.bot_message_evt = bot_message_evt | |||||
async def _send_message(self, socket_id: Text, response: Any) -> None: | |||||
"""Sends a message to the recipient using the bot event.""" | |||||
await self.sio.emit(self.bot_message_evt, response, room=socket_id) | |||||
async def send_text_message( | |||||
self, recipient_id: Text, text: Text, **kwargs: Any | |||||
) -> None: | |||||
"""Send a message through this channel.""" | |||||
await self._send_message(self.sid, {"text": text}) | |||||
async def send_image_url( | |||||
self, recipient_id: Text, image: Text, **kwargs: Any | |||||
) -> None: | |||||
"""Sends an image to the output""" | |||||
message = {"attachment": {"type": "image", "payload": {"src": image}}} | |||||
await self._send_message(self.sid, message) | |||||
async def send_text_with_buttons( | |||||
self, | |||||
recipient_id: Text, | |||||
text: Text, | |||||
buttons: List[Dict[Text, Any]], | |||||
**kwargs: Any, | |||||
) -> None: | |||||
"""Sends buttons to the output.""" | |||||
message = {"text": text, "quick_replies": []} | |||||
for button in buttons: | |||||
message["quick_replies"].append( | |||||
{ | |||||
"content_type": "text", | |||||
"title": button["title"], | |||||
"payload": button["payload"], | |||||
} | |||||
) | |||||
await self._send_message(self.sid, message) | |||||
async def send_elements( | |||||
self, recipient_id: Text, elements: Iterable[Dict[Text, Any]], **kwargs: Any | |||||
) -> None: | |||||
"""Sends elements to the output.""" | |||||
for element in elements: | |||||
message = { | |||||
"attachment": { | |||||
"type": "template", | |||||
"payload": {"template_type": "generic", "elements": element}, | |||||
} | |||||
} | |||||
await self._send_message(self.sid, message) | |||||
async def send_custom_json( | |||||
self, recipient_id: Text, json_message: Dict[Text, Any], **kwargs: Any | |||||
) -> None: | |||||
"""Sends custom json to the output""" | |||||
json_message.setdefault("room", self.sid) | |||||
await self.sio.emit(self.bot_message_evt, **json_message) | |||||
async def send_attachment( | |||||
self, recipient_id: Text, attachment: Dict[Text, Any], **kwargs: Any | |||||
) -> None: | |||||
"""Sends an attachment to the user.""" | |||||
await self._send_message(self.sid, {"attachment": attachment}) | |||||
class SocketIOInput(InputChannel): | |||||
"""A socket.io input channel.""" | |||||
@classmethod | |||||
def name(cls) -> Text: | |||||
return "socketio" | |||||
@classmethod | |||||
def from_credentials(cls, credentials: Optional[Dict[Text, Any]]) -> InputChannel: | |||||
credentials = credentials or {} | |||||
return cls( | |||||
credentials.get("user_message_evt", "user_uttered"), | |||||
credentials.get("bot_message_evt", "bot_uttered"), | |||||
credentials.get("namespace"), | |||||
credentials.get("session_persistence", False), | |||||
credentials.get("socketio_path", "/socket.io"), | |||||
) | |||||
def __init__( | |||||
self, | |||||
user_message_evt: Text = "user_uttered", | |||||
bot_message_evt: Text = "bot_uttered", | |||||
namespace: Optional[Text] = None, | |||||
session_persistence: bool = False, | |||||
socketio_path: Optional[Text] = "/socket.io", | |||||
): | |||||
self.bot_message_evt = bot_message_evt | |||||
self.session_persistence = session_persistence | |||||
self.user_message_evt = user_message_evt | |||||
self.namespace = namespace | |||||
self.socketio_path = socketio_path | |||||
def blueprint( | |||||
self, on_new_message: Callable[[UserMessage], Awaitable[Any]] | |||||
) -> Blueprint: | |||||
# Workaround so that socketio works with requests from other origins. | |||||
sio = AsyncServer(async_mode="sanic", cors_allowed_origins=[]) | |||||
socketio_webhook = SocketBlueprint( | |||||
sio, self.socketio_path, "socketio_webhook", __name__ | |||||
) | |||||
@socketio_webhook.route("/", methods=["GET"]) | |||||
async def health(_: Request) -> HTTPResponse: | |||||
return response.json({"status": "ok"}) | |||||
@sio.on("connect", namespace=self.namespace) | |||||
async def connect(sid: Text, _) -> None: | |||||
logger.debug(f"User {sid} connected to socketIO endpoint.") | |||||
@sio.on("disconnect", namespace=self.namespace) | |||||
async def disconnect(sid: Text) -> None: | |||||
logger.debug(f"User {sid} disconnected from socketIO endpoint.") | |||||
@sio.on("session_request", namespace=self.namespace) | |||||
async def session_request(sid: Text, data: Optional[Dict]): | |||||
if data is None: | |||||
data = {} | |||||
if "session_id" not in data or data["session_id"] is None: | |||||
data["session_id"] = uuid.uuid4().hex | |||||
await sio.emit("session_confirm", data["session_id"], room=sid) | |||||
logger.debug(f"User {sid} connected to socketIO endpoint.") | |||||
@sio.on(self.user_message_evt, namespace=self.namespace) | |||||
async def handle_message(sid: Text, data: Dict) -> Any: | |||||
output_channel = SocketIOOutput(sio, sid, self.bot_message_evt) | |||||
if self.session_persistence: | |||||
if not data.get("session_id"): | |||||
warnings.warn( | |||||
"A message without a valid sender_id " | |||||
"was received. This message will be " | |||||
"ignored. Make sure to set a proper " | |||||
"session id using the " | |||||
"`session_request` socketIO event." | |||||
) | |||||
return | |||||
sender_id = data["session_id"] | |||||
else: | |||||
sender_id = sid | |||||
message = UserMessage( | |||||
data["message"], output_channel, sender_id, input_channel=self.name(), | |||||
metadata = data['customData'] | |||||
) | |||||
await on_new_message(message) | |||||
return socketio_webhook |
@@ -1,10 +0,0 @@ | |||||
# name = 'Siddharth' | |||||
# email = 'siddharthsrivastava77@gmail.com' | |||||
# print('INSERT INTO users (name, email) VALUES ("{}", "{}");'.format(name, email)) | |||||
import datetime | |||||
# using now() to get current time | |||||
current_time = str(datetime.datetime.now()) | |||||
current_time = current_time.split(":") | |||||
print(current_time[0] + ":" + current_time[1]) |