├── .DS_Store ├── Full Code ├── README.md ├── actions.py ├── config_spacy.json ├── data │ ├── data.json │ └── stories.md ├── dialogue_management_model.py ├── models │ ├── dialogue │ │ ├── domain.json │ │ ├── domain.yml │ │ ├── featurizer.json │ │ ├── keras_arch.json │ │ ├── keras_policy.json │ │ ├── keras_weights.h5 │ │ ├── memorized_turns.json │ │ └── policy_metadata.json │ └── nlu │ │ └── default │ │ └── weathernlu │ │ ├── crf_model.pkl │ │ ├── intent_classifier.pkl │ │ ├── metadata.json │ │ └── training_data.json ├── nlu_model.py ├── rasa_slack_connector.py ├── requirements.txt ├── run_app.py ├── stories.md ├── train_init.py ├── train_online.py └── weather_domain.yml ├── Full_Code_Latest ├── .DS_Store ├── README.md ├── __pycache__ │ └── actions.cpython-36.pyc ├── actions.py ├── config.yml ├── credentials.yml ├── data │ ├── data.json │ └── stories.md ├── domain.yml ├── endpoints.yml ├── models │ ├── 20190717-171515.tar.gz │ ├── 20200421-110137.tar.gz │ ├── dialogue │ │ ├── domain.json │ │ ├── domain.yml │ │ ├── policy_0_MemoizationPolicy │ │ │ ├── featurizer.json │ │ │ └── memorized_turns.json │ │ ├── policy_1_KerasPolicy │ │ │ ├── featurizer.json │ │ │ ├── keras_model.h5 │ │ │ └── keras_policy.json │ │ └── policy_metadata.json │ └── nlu │ │ └── default │ │ └── weathernlu │ │ ├── crf_model.pkl │ │ ├── intent_classifier.pkl │ │ ├── intent_classifier_sklearn.pkl │ │ ├── metadata.json │ │ ├── regex_featurizer.json │ │ └── training_data.json ├── rasa_core.log └── requirements.txt ├── README.md └── Video files ├── README.md ├── data ├── data.json └── stories.md ├── requirements.txt ├── train_init.py └── train_online.py /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/.DS_Store -------------------------------------------------------------------------------- /Full Code/README.md: -------------------------------------------------------------------------------- 1 | # Weatherbot Tutorial (original video code) 2 | 3 | This directory contains the full code of Weatherbot tutorial. You can use this code, modify it if you want, or you can test the models by simply loading the agent (run dialogue_management_model.py file). 4 | Since this tutorial was recorded back in February 2018, it is using slightly older version of Rasa NLU and Rasa Core. If you prefer using the latest releases of these libraries check out 5 | [this](https://github.com/JustinaPetr/Weatherbot_Tutorial/tree/master/Full%20Code%20%5BLatest%20release%20of%20Rasa%20NLU%20and%20Rasa%20Core%5D) directory - it contains Weatherbot code and models compatible with the latest releases of Rasa NLU and Rasa Core (keep in mind that in some places the code will slightly differ from the one shown in the video). 6 | 7 | Library versions used in the tutorial: 8 | 9 | Rasa NLU version: 0.11.4 10 | 11 | Rasa Core version: 0.8.2 -------------------------------------------------------------------------------- /Full Code/actions.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import unicode_literals 4 | 5 | from rasa_core.actions.action import Action 6 | from rasa_core.events import SlotSet 7 | 8 | class ActionWeather(Action): 9 | def name(self): 10 | return 'action_weather' 11 | 12 | def run(self, dispatcher, tracker, domain): 13 | from apixu.client import ApixuClient 14 | api_key = '...' #your apixu key 15 | client = ApixuClient(api_key) 16 | 17 | loc = tracker.get_slot('location') 18 | current = client.getcurrent(q=loc) 19 | 20 | country = current['location']['country'] 21 | city = current['location']['name'] 22 | condition = current['current']['condition']['text'] 23 | temperature_c = current['current']['temp_c'] 24 | humidity = current['current']['humidity'] 25 | wind_mph = current['current']['wind_mph'] 26 | 27 | response = """It is currently {} in {} at the moment. The temperature is {} degrees, the humidity is {}% and the wind speed is {} mph.""".format(condition, city, temperature_c, humidity, wind_mph) 28 | 29 | dispatcher.utter_message(response) 30 | return [SlotSet('location',loc)] 31 | 32 | -------------------------------------------------------------------------------- /Full Code/config_spacy.json: -------------------------------------------------------------------------------- 1 | { 2 | "pipeline":"spacy_sklearn", 3 | "path":"./models/nlu", 4 | "data":"./data/data.json" 5 | } 6 | -------------------------------------------------------------------------------- /Full Code/data/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "rasa_nlu_data": { 3 | "common_examples": [ 4 | { 5 | "text": "Hello", 6 | "intent": "greet", 7 | "entities": [] 8 | }, 9 | { 10 | "text": "goodbye", 11 | "intent": "goodbye", 12 | "entities": [] 13 | }, 14 | { 15 | "text": "What's the weather in Berlin at the moment?", 16 | "intent": "inform", 17 | "entities": [ 18 | { 19 | "start": 22, 20 | "end": 28, 21 | "value": "Berlin", 22 | "entity": "location" 23 | } 24 | ] 25 | }, 26 | { 27 | "text": "hey", 28 | "intent": "greet", 29 | "entities": [] 30 | }, 31 | { 32 | "text": "hello", 33 | "intent": "greet", 34 | "entities": [] 35 | }, 36 | { 37 | "text": "hi", 38 | "intent": "greet", 39 | "entities": [] 40 | }, 41 | { 42 | "text": "heya", 43 | "intent": "greet", 44 | "entities": [] 45 | }, 46 | { 47 | "text": "howdy", 48 | "intent": "greet", 49 | "entities": [] 50 | }, 51 | { 52 | "text": "hey there", 53 | "intent": "greet", 54 | "entities": [] 55 | }, 56 | { 57 | "text": "bye", 58 | "intent": "goodbye", 59 | "entities": [] 60 | }, 61 | { 62 | "text": "goodbye", 63 | "intent": "goodbye", 64 | "entities": [] 65 | }, 66 | { 67 | "text": "bye bye", 68 | "intent": "goodbye", 69 | "entities": [] 70 | }, 71 | { 72 | "text": "see ya", 73 | "intent": "goodbye", 74 | "entities": [] 75 | }, 76 | { 77 | "text": "see you later", 78 | "intent": "goodbye", 79 | "entities": [] 80 | }, 81 | { 82 | "text": "What's the weather today?", 83 | "intent": "inform", 84 | "entities": [] 85 | }, 86 | { 87 | "text": "What's the weather in London today?", 88 | "intent": "inform", 89 | "entities": [ 90 | { 91 | "start": 22, 92 | "end": 28, 93 | "value": "London", 94 | "entity": "location" 95 | } 96 | ] 97 | }, 98 | { 99 | "text": "Show me what's the weather in Paris", 100 | "intent": "inform", 101 | "entities": [ 102 | { 103 | "start": 30, 104 | "end": 35, 105 | "value": "Paris", 106 | "entity": "location" 107 | } 108 | ] 109 | }, 110 | { 111 | "text": "I wonder what is the weather in Vilnius right now?", 112 | "intent": "inform", 113 | "entities": [ 114 | { 115 | "start": 32, 116 | "end": 39, 117 | "value": "Vilnius", 118 | "entity": "location" 119 | } 120 | ] 121 | }, 122 | { 123 | "text": "what is the weather?", 124 | "intent": "inform", 125 | "entities": [] 126 | }, 127 | { 128 | "text": "Tell me the weather", 129 | "intent": "inform", 130 | "entities": [] 131 | }, 132 | { 133 | "text": "Is the weather nice in Barcelona today?", 134 | "intent": "inform", 135 | "entities": [ 136 | { 137 | "start": 23, 138 | "end": 32, 139 | "value": "Barcelona", 140 | "entity": "location" 141 | } 142 | ] 143 | }, 144 | { 145 | "text": "I am going to London today and I wonder what is the weather out there?", 146 | "intent": "inform", 147 | "entities": [ 148 | { 149 | "start": 14, 150 | "end": 20, 151 | "value": "London", 152 | "entity": "location" 153 | } 154 | ] 155 | }, 156 | { 157 | "text": "I am planning my trip to Amsterdam. What is the weather out there?", 158 | "intent": "inform", 159 | "entities": [ 160 | { 161 | "start": 25, 162 | "end": 34, 163 | "value": "Amsterdam", 164 | "entity": "location" 165 | } 166 | ] 167 | }, 168 | { 169 | "text": "Show me the weather in Dublin, please", 170 | "intent": "inform", 171 | "entities": [ 172 | { 173 | "start": 23, 174 | "end": 29, 175 | "value": "Dublin", 176 | "entity": "location" 177 | } 178 | ] 179 | }, 180 | { 181 | "text": "in London", 182 | "intent": "inform", 183 | "entities": [ 184 | { 185 | "start": 3, 186 | "end": 9, 187 | "value": "London", 188 | "entity": "location" 189 | } 190 | ] 191 | }, 192 | { 193 | "text": "Lithuania", 194 | "intent": "inform", 195 | "entities": [ 196 | { 197 | "start": 0, 198 | "end": 9, 199 | "value": "Lithuania", 200 | "entity": "location" 201 | } 202 | ] 203 | }, 204 | { 205 | "text": "Oh, sorry, in Italy", 206 | "intent": "inform", 207 | "entities": [ 208 | { 209 | "start": 14, 210 | "end": 19, 211 | "value": "Italy", 212 | "entity": "location" 213 | } 214 | ] 215 | }, 216 | { 217 | "text": "Tell me the weather in Vilnius", 218 | "intent": "inform", 219 | "entities": [ 220 | { 221 | "start": 23, 222 | "end": 30, 223 | "value": "Vilnius", 224 | "entity": "location" 225 | } 226 | ] 227 | }, 228 | { 229 | "text": "The weather condition in Italy", 230 | "intent": "inform", 231 | "entities": [ 232 | { 233 | "start": 25, 234 | "end": 30, 235 | "value": "Italy", 236 | "entity": "location" 237 | } 238 | ] 239 | } 240 | ] 241 | } 242 | } -------------------------------------------------------------------------------- /Full Code/data/stories.md: -------------------------------------------------------------------------------- 1 | ## Generated Story 3320800183399695936 2 | * greet 3 | - utter_greet 4 | * inform 5 | - utter_ask_location 6 | * inform{"location": "italy"} 7 | - slot{"location": "italy"} 8 | - action_weather 9 | - slot{"location": "italy"} 10 | * goodbye 11 | - utter_goodbye 12 | - export 13 | ## Generated Story -3351152636827275381 14 | * greet 15 | - utter_greet 16 | * inform[location=London] 17 | - slot{"location": "London"} 18 | - action_weather 19 | * goodbye 20 | - utter_goodbye 21 | - export 22 | ## Generated Story 8921121480760034253 23 | * greet 24 | - utter_greet 25 | * inform 26 | - utter_ask_location 27 | * inform[location=London] 28 | - slot{"location": "London"} 29 | - action_weather 30 | * goodbye 31 | - utter_goodbye 32 | - export 33 | ## Generated Story -5208991511085841103 34 | - slot{"location": "London"} 35 | - action_weather 36 | * goodbye 37 | - utter_goodbye 38 | - export 39 | ## Generated Story -5208991511085841103 40 | - slot{"location": "London"} 41 | - action_weather 42 | * goodbye 43 | - utter_goodbye 44 | - export 45 | ## story_001 46 | * greet 47 | - utter_greet 48 | * inform 49 | - utter_ask_location 50 | * inform[location=London] 51 | - slot{"location": "London"} 52 | - action_weather 53 | * goodbye 54 | - utter_goodbye 55 | ## story_002 56 | * greet 57 | - utter_greet 58 | * inform[location=Paris] 59 | - slot{"location": "Paris"} 60 | - action_weather 61 | * goodbye 62 | - utter_goodbye 63 | ## story_003 64 | * greet 65 | - utter_greet 66 | * inform 67 | - utter_ask_location 68 | * inform[location=Vilnius] 69 | - slot{"location": "Vilnius"} 70 | - action_weather 71 | * goodbye 72 | - utter_goodbye 73 | ## story_004 74 | * greet 75 | - utter_greet 76 | * inform[location=Italy] 77 | - slot{"location": "Italy"} 78 | - action_weather 79 | * goodbye 80 | - utter_goodbye 81 | ## story_005 82 | * greet 83 | - utter_greet 84 | * inform 85 | - utter_ask_location 86 | * inform[location=Lithuania] 87 | - slot{"location": "Lithuania"} 88 | - action_weather 89 | * goodbye 90 | - utter_goodbye 91 | -------------------------------------------------------------------------------- /Full Code/dialogue_management_model.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | from __future__ import unicode_literals 5 | 6 | import logging 7 | 8 | from rasa_core.agent import Agent 9 | from rasa_core.channels.console import ConsoleInputChannel 10 | from rasa_core.interpreter import RegexInterpreter 11 | from rasa_core.policies.keras_policy import KerasPolicy 12 | from rasa_core.policies.memoization import MemoizationPolicy 13 | from rasa_core.interpreter import RasaNLUInterpreter 14 | 15 | logger = logging.getLogger(__name__) 16 | 17 | def train_dialogue(domain_file = 'weather_domain.yml', 18 | model_path = './models/dialogue', 19 | training_data_file = './data/stories.md'): 20 | 21 | agent = Agent(domain_file, policies = [MemoizationPolicy(), KerasPolicy()]) 22 | 23 | agent.train( 24 | training_data_file, 25 | max_history = 3, 26 | epochs = 300, 27 | batch_size = 50, 28 | validation_split = 0.2, 29 | augmentation_factor = 50) 30 | 31 | agent.persist(model_path) 32 | return agent 33 | 34 | def run_weather_bot(serve_forever=True): 35 | interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu') 36 | agent = Agent.load('./models/dialogue', interpreter = interpreter) 37 | 38 | if serve_forever: 39 | agent.handle_channel(ConsoleInputChannel()) 40 | 41 | return agent 42 | 43 | if __name__ == '__main__': 44 | train_dialogue() 45 | run_weather_bot() 46 | -------------------------------------------------------------------------------- /Full Code/models/dialogue/domain.json: -------------------------------------------------------------------------------- 1 | { 2 | "features": [ 3 | "intent_greet", 4 | "intent_goodbye", 5 | "intent_inform", 6 | "entity_location", 7 | "slot_location_0", 8 | "prev_action_listen", 9 | "prev_action_restart", 10 | "prev_utter_greet", 11 | "prev_utter_goodbye", 12 | "prev_utter_ask_location", 13 | "prev_action_weather" 14 | ] 15 | } -------------------------------------------------------------------------------- /Full Code/models/dialogue/domain.yml: -------------------------------------------------------------------------------- 1 | action_factory: null 2 | action_names: 3 | - utter_greet 4 | - utter_goodbye 5 | - utter_ask_location 6 | - action_weather 7 | actions: 8 | - utter_greet 9 | - utter_goodbye 10 | - utter_ask_location 11 | - actions.ActionWeather 12 | config: 13 | store_entities_as_slots: true 14 | entities: 15 | - location 16 | intents: 17 | - greet 18 | - goodbye 19 | - inform 20 | slots: 21 | location: 22 | initial_value: null 23 | type: rasa_core.slots.TextSlot 24 | templates: 25 | utter_ask_location: 26 | - text: In what location? 27 | utter_goodbye: 28 | - text: Talk to you later. 29 | - text: Bye bye :( 30 | utter_greet: 31 | - text: Hello! How can I help? 32 | topics: [] 33 | -------------------------------------------------------------------------------- /Full Code/models/dialogue/featurizer.json: -------------------------------------------------------------------------------- 1 | {"py/object": "rasa_core.featurizers.BinaryFeaturizer"} -------------------------------------------------------------------------------- /Full Code/models/dialogue/keras_arch.json: -------------------------------------------------------------------------------- 1 | {"class_name": "Sequential", "config": [{"class_name": "Masking", "config": {"name": "masking_1", "trainable": true, "batch_input_shape": [null, 3, 11], "dtype": "float32", "mask_value": -1}}, {"class_name": "LSTM", "config": {"name": "lstm_1", "trainable": true, "batch_input_shape": [null, 3, 11], "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "implementation": 0, "units": 32, "activation": "tanh", "recurrent_activation": "hard_sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.2, "recurrent_dropout": 0.0}}, {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "batch_input_shape": [null, 32], "dtype": "float32", "units": 6, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "VarianceScaling", "config": {"scale": 1.0, "mode": "fan_avg", "distribution": "uniform", "seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Activation", "config": {"name": "activation_1", "trainable": true, "activation": "softmax"}}], "keras_version": "2.0.8", "backend": "tensorflow"} -------------------------------------------------------------------------------- /Full Code/models/dialogue/keras_policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "arch": "keras_arch.json", 3 | "weights": "keras_weights.h5", 4 | "epochs": 300 5 | } -------------------------------------------------------------------------------- /Full Code/models/dialogue/keras_weights.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full Code/models/dialogue/keras_weights.h5 -------------------------------------------------------------------------------- /Full Code/models/dialogue/memorized_turns.json: -------------------------------------------------------------------------------- 1 | { 2 | "lookup": { 3 | "eJyLzivNydFRiI7OzCtJzSuJTy9KTS3RUTCMBYoVFKWWxScml2Tm58XnZBYD5UESsfhUl5aUpBYhhGNjAYn+IkY=": 0, 4 | "eJyLzivNydFRgJDR0Zl5Jal5JfHpRampJToKhrFAsYKi1LL40pKS1CKEcGwsAD4NFAM=": 0, 5 | "eJyLjo4uzskvic/JT04syczPizfQUTCMjdVRwCoOFC4oSi2LT0wGi5WnJpZkpBbBdWTmlaTmlcSn5+enJFWmQjUQNiYnsxioD2xKLACFjTMB": 3, 6 | "eJyLzivNydFRiI4uzskvic/JT04syczPizfQUTCMBQoXFKWWxScmg8XKU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UBgLNRNlyUyLwbg3ewKR04RWPJmLhU30Qzn/VuRvrgd8t5Fl17XAHbiUni1OY7LUnsZjj83wgXBphAXQ==": 5, 43 | "eJxNzFEKgCAMgOGrdAAf6jwiIrJisLaYM+j2iUj5+vHze65EbvEe2YAtHgpgbtlCs0vhjtUM9Ocwtci76DniBmhPJMnJUHhoIbHP4jqPU+5GWNqsr8ML+ZQyGg==": 5, 44 | "eJyLzivNydFRiI4uzskvic/JT04syczPizfQUTCMjcUhDhQuKEoti09MBouVpyaWZKQWgXXEAgCFhBxi": 0, 45 | "eJyLzivNydFRgJDR0cU5+SXxOfnJiSWZ+XnxBjoKhrFA4YKi1LL4xGSwWHlqYklGahFIJjYWAL4qFic=": 0, 46 | "eJyLzivNydFRQJCxAD3tBoI=": 0 47 | } 48 | } -------------------------------------------------------------------------------- /Full Code/models/dialogue/policy_metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "action_fingerprints": { 3 | "action_listen": { 4 | "slots": [ 5 | "location" 6 | ] 7 | }, 8 | "utter_goodbye": { 9 | "slots": [] 10 | }, 11 | "null": { 12 | "slots": [ 13 | "location" 14 | ] 15 | }, 16 | "action_weather": { 17 | "slots": [ 18 | "location" 19 | ] 20 | } 21 | }, 22 | "rasa_core": "0.8.0", 23 | "max_history": 3, 24 | "ensemble_name": "rasa_core.policies.ensemble.SimplePolicyEnsemble", 25 | "policy_names": [ 26 | "rasa_core.policies.memoization.MemoizationPolicy", 27 | "rasa_core.policies.keras_policy.KerasPolicy" 28 | ] 29 | } -------------------------------------------------------------------------------- /Full Code/models/nlu/default/weathernlu/crf_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full Code/models/nlu/default/weathernlu/crf_model.pkl -------------------------------------------------------------------------------- /Full Code/models/nlu/default/weathernlu/intent_classifier.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full Code/models/nlu/default/weathernlu/intent_classifier.pkl -------------------------------------------------------------------------------- /Full Code/models/nlu/default/weathernlu/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "en", 3 | "pipeline": [ 4 | "rasa_nlu.utils.spacy_utils.SpacyNLP", 5 | "rasa_nlu.tokenizers.spacy_tokenizer.SpacyTokenizer", 6 | "rasa_nlu.featurizers.spacy_featurizer.SpacyFeaturizer", 7 | "rasa_nlu.featurizers.regex_featurizer.RegexFeaturizer", 8 | "rasa_nlu.extractors.crf_entity_extractor.CRFEntityExtractor", 9 | "rasa_nlu.extractors.entity_synonyms.EntitySynonymMapper", 10 | "rasa_nlu.classifiers.sklearn_intent_classifier.SklearnIntentClassifier" 11 | ], 12 | "training_data": "training_data.json", 13 | "spacy_model_name": "en", 14 | "regex_featurizer": null, 15 | "entity_extractor_crf": { 16 | "model_file": "crf_model.pkl", 17 | "crf_features": [ 18 | [ 19 | "low", 20 | "title", 21 | "upper", 22 | "pos", 23 | "pos2" 24 | ], 25 | [ 26 | "bias", 27 | "low", 28 | "word3", 29 | "word2", 30 | "upper", 31 | "title", 32 | "digit", 33 | "pos", 34 | "pos2", 35 | "pattern" 36 | ], 37 | [ 38 | "low", 39 | "title", 40 | "upper", 41 | "pos", 42 | "pos2" 43 | ] 44 | ], 45 | "BILOU_flag": true, 46 | "version": 1 47 | }, 48 | "entity_synonyms": null, 49 | "intent_classifier_sklearn": "intent_classifier.pkl", 50 | "trained_at": "20180202-012840", 51 | "rasa_nlu_version": "0.11.0" 52 | } -------------------------------------------------------------------------------- /Full Code/models/nlu/default/weathernlu/training_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "rasa_nlu_data": { 3 | "common_examples": [ 4 | { 5 | "intent": "greet", 6 | "entities": [], 7 | "text": "Hello" 8 | }, 9 | { 10 | "intent": "goodbye", 11 | "entities": [], 12 | "text": "Goodbye" 13 | }, 14 | { 15 | "intent": "greet", 16 | "entities": [], 17 | "text": "hey" 18 | }, 19 | { 20 | "intent": "inform", 21 | "entities": [ 22 | { 23 | "start": 22, 24 | "end": 28, 25 | "value": "Berlin", 26 | "entity": "location" 27 | } 28 | ], 29 | "text": "What's the weather in Berlin?" 30 | }, 31 | { 32 | "intent": "greet", 33 | "entities": [], 34 | "text": "hey" 35 | }, 36 | { 37 | "intent": "greet", 38 | "entities": [], 39 | "text": "hello" 40 | }, 41 | { 42 | "intent": "greet", 43 | "entities": [], 44 | "text": "hi" 45 | }, 46 | { 47 | "intent": "greet", 48 | "entities": [], 49 | "text": "heya" 50 | }, 51 | { 52 | "intent": "greet", 53 | "entities": [], 54 | "text": "howdy" 55 | }, 56 | { 57 | "intent": "greet", 58 | "entities": [], 59 | "text": "hey there" 60 | }, 61 | { 62 | "intent": "goodbye", 63 | "entities": [], 64 | "text": "bye" 65 | }, 66 | { 67 | "intent": "goodbye", 68 | "entities": [], 69 | "text": "goodbye" 70 | }, 71 | { 72 | "intent": "goodbye", 73 | "entities": [], 74 | "text": "bye bye" 75 | }, 76 | { 77 | "intent": "goodbye", 78 | "entities": [], 79 | "text": "see ya" 80 | }, 81 | { 82 | "intent": "goodbye", 83 | "entities": [], 84 | "text": "see you later" 85 | }, 86 | { 87 | "intent": "inform", 88 | "entities": [], 89 | "text": "What's the weather today?" 90 | }, 91 | { 92 | "intent": "inform", 93 | "entities": [ 94 | { 95 | "start": 22, 96 | "end": 28, 97 | "value": "London", 98 | "entity": "location" 99 | } 100 | ], 101 | "text": "What's the weather in London today?" 102 | }, 103 | { 104 | "intent": "inform", 105 | "entities": [ 106 | { 107 | "start": 30, 108 | "end": 35, 109 | "value": "Paris", 110 | "entity": "location" 111 | } 112 | ], 113 | "text": "Show me what's the weather in Paris" 114 | }, 115 | { 116 | "intent": "inform", 117 | "entities": [ 118 | { 119 | "start": 32, 120 | "end": 39, 121 | "value": "Vilnius", 122 | "entity": "location" 123 | } 124 | ], 125 | "text": "I wonder what is the weather in Vilnius right now?" 126 | }, 127 | { 128 | "intent": "inform", 129 | "entities": [], 130 | "text": "what is the weather?" 131 | }, 132 | { 133 | "intent": "inform", 134 | "entities": [], 135 | "text": "Tell me the weather" 136 | }, 137 | { 138 | "intent": "inform", 139 | "entities": [ 140 | { 141 | "start": 23, 142 | "end": 32, 143 | "value": "Barcelona", 144 | "entity": "location" 145 | } 146 | ], 147 | "text": "Is the weather nice in Barcelona today?" 148 | }, 149 | { 150 | "intent": "inform", 151 | "entities": [ 152 | { 153 | "start": 14, 154 | "end": 20, 155 | "value": "London", 156 | "entity": "location" 157 | } 158 | ], 159 | "text": "I am going to London today and I wonder what is the weather out there?" 160 | }, 161 | { 162 | "intent": "inform", 163 | "entities": [ 164 | { 165 | "start": 25, 166 | "end": 34, 167 | "value": "Amsterdam", 168 | "entity": "location" 169 | } 170 | ], 171 | "text": "I am planning my trip to Amsterdam. What is the weather out there?" 172 | }, 173 | { 174 | "intent": "inform", 175 | "entities": [ 176 | { 177 | "start": 23, 178 | "end": 29, 179 | "value": "Dublin", 180 | "entity": "location" 181 | } 182 | ], 183 | "text": "Show me the weather in Dublin, please" 184 | }, 185 | { 186 | "intent": "inform", 187 | "entities": [ 188 | { 189 | "start": 3, 190 | "end": 9, 191 | "value": "London", 192 | "entity": "location" 193 | } 194 | ], 195 | "text": "in London" 196 | }, 197 | { 198 | "intent": "inform", 199 | "entities": [ 200 | { 201 | "start": 0, 202 | "end": 9, 203 | "value": "Lithuania", 204 | "entity": "location" 205 | } 206 | ], 207 | "text": "Lithuania" 208 | }, 209 | { 210 | "intent": "inform", 211 | "entities": [ 212 | { 213 | "start": 14, 214 | "end": 19, 215 | "value": "Italy", 216 | "entity": "location" 217 | } 218 | ], 219 | "text": "Oh, sorry, in Italy" 220 | }, 221 | { 222 | "intent": "inform", 223 | "entities": [ 224 | { 225 | "start": 23, 226 | "end": 30, 227 | "value": "Vilnius", 228 | "entity": "location" 229 | } 230 | ], 231 | "text": "Tell me the weather in Vilnius" 232 | }, 233 | { 234 | "intent": "inform", 235 | "entities": [ 236 | { 237 | "start": 25, 238 | "end": 30, 239 | "value": "Italy", 240 | "entity": "location" 241 | } 242 | ], 243 | "text": "The weather condition in Italy" 244 | } 245 | ], 246 | "regex_features": [], 247 | "entity_synonyms": [] 248 | } 249 | } -------------------------------------------------------------------------------- /Full Code/nlu_model.py: -------------------------------------------------------------------------------- 1 | from rasa_nlu.converters import load_data 2 | from rasa_nlu.config import RasaNLUConfig 3 | from rasa_nlu.model import Trainer 4 | from rasa_nlu.model import Metadata, Interpreter 5 | 6 | def train_nlu(data, config, model_dir): 7 | training_data = load_data(data) 8 | trainer = Trainer(RasaNLUConfig(config)) 9 | trainer.train(training_data) 10 | model_directory = trainer.persist(model_dir, fixed_model_name = 'weathernlu') 11 | 12 | def run_nlu(): 13 | interpreter = Interpreter.load('./models/nlu/default/weathernlu', RasaNLUConfig('config_spacy.json')) 14 | print(interpreter.parse("I am planning my holiday to Lithuania. I wonder what is the weather out there.")) 15 | 16 | if __name__ == '__main__': 17 | #train_nlu('./data/data.json', 'config_spacy.json', './models/nlu') 18 | run_nlu() 19 | -------------------------------------------------------------------------------- /Full Code/rasa_slack_connector.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | from __future__ import unicode_literals 5 | 6 | import logging 7 | 8 | from builtins import str 9 | from flask import Blueprint, request, jsonify 10 | 11 | from rasa_core.channels.channel import UserMessage, OutputChannel 12 | from rasa_core.channels.rest import HttpInputComponent 13 | 14 | logger = logging.getLogger(__name__) 15 | 16 | 17 | class SlackBot(OutputChannel): 18 | def __init__(self, slack_verification_token, channel): 19 | self.slack_verification_token = slack_verification_token 20 | self.channel = channel 21 | 22 | def send_text_message(self, recipient_id, message): 23 | from slackclient import SlackClient 24 | text = message 25 | recipient = recipient_id 26 | 27 | CLIENT = SlackClient(self.slack_verification_token) 28 | CLIENT.api_call('chat.postMessage', channel = self.channel, text = text, as_user = True) 29 | 30 | 31 | 32 | 33 | 34 | class SlackInput(HttpInputComponent): 35 | def __init__(self, slack_dev_token, slack_verification_token, slack_client, debug_mode): 36 | self.slack_dev_token = slack_dev_token 37 | self.debug_mode = debug_mode 38 | self.slack_client = slack_client 39 | self.slack_verification_token = slack_verification_token 40 | 41 | def blueprint(self, on_new_message): 42 | from flask import Flask, request, Response 43 | slack_webhook = Blueprint('slack_webhook', __name__) 44 | 45 | @slack_webhook.route('/', methods = ['GET']) 46 | def health(): 47 | return jsonify({'status':'ok'}) 48 | 49 | @slack_webhook.route('/slack/events', methods = ['POST']) 50 | def event(): 51 | if request.json.get('type') == 'url_verification': 52 | return request.json.get('challenge'), 200 53 | 54 | if request.json.get('token') == self.slack_client and request.json.get('type') == 'event_callback': 55 | data = request.json 56 | messaging_events = data.get('event') 57 | channel = messaging_events.get('channel') 58 | user = messaging_events.get('user') 59 | text = messaging_events.get('text') 60 | bot = messaging_events.get('bot_id') 61 | if bot == None: 62 | on_new_message(UserMessage(text, SlackBot(self.slack_verification_token, channel))) 63 | 64 | return Response(), 200 65 | 66 | return slack_webhook 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Full Code/requirements.txt: -------------------------------------------------------------------------------- 1 | ###rasa_nlu 2 | gevent==1.2.1 3 | Klein==17.2.0 4 | boto3==1.4.4 5 | typing==3.5.3.0 6 | future==0.16.0 7 | six==1.10.0 8 | jsonschema==2.6.0 9 | matplotlib==1.5.3 10 | requests==2.14.2 11 | tqdm==4.11.2 12 | numpy==1.13.1 13 | simplejson==3.11.1 14 | 15 | ### Sklearn 16 | spacy==1.8.2 17 | scikit-learn==0.19.1 18 | sklearn-crfsuite==0.3.5 19 | 20 | ###rasa_core 21 | apscheduler==3.3.1 22 | fakeredis==0.8.2 23 | graphviz==0.7.1 24 | h5py==2.7.0 25 | jsonpickle==0.9.4 26 | keras==2.0.8 27 | pandoc==1.0.0b2 28 | redis==2.10.5 29 | tensorflow 30 | networkx==1.11 31 | fbmessenger==4.3.1 32 | ConfigArgParse==0.12.0 33 | pykwalify==1.6.0 34 | coloredlogs==7.3 35 | ruamel.yaml==0.15.34 36 | flask==0.12 37 | rasa_nlu==0.11.4 38 | 39 | ###additional 40 | pypandoc 41 | slackclient 42 | rasa_core==0.8.2 43 | git+https://github.com/apixu/apixu-python.git -------------------------------------------------------------------------------- /Full Code/run_app.py: -------------------------------------------------------------------------------- 1 | from rasa_core.channels import HttpInputChannel 2 | from rasa_core.agent import Agent 3 | from rasa_core.interpreter import RasaNLUInterpreter 4 | from rasa_slack_connector import SlackInput 5 | 6 | 7 | nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu') 8 | agent = Agent.load('./models/dialogue', interpreter = nlu_interpreter) 9 | 10 | input_channel = SlackInput('xoxp...', #app verification token 11 | 'xoxb...', # bot verification token 12 | '...', # slack verification token 13 | True) 14 | 15 | agent.handle_channel(HttpInputChannel(5004, '/', input_channel)) -------------------------------------------------------------------------------- /Full Code/stories.md: -------------------------------------------------------------------------------- 1 | ## Generated Story 3320800183399695936 2 | * greet 3 | - utter_greet 4 | * inform 5 | - utter_ask_location 6 | * inform{"location": "italy"} 7 | - slot{"location": "italy"} 8 | - action_weather 9 | - slot{"location": "italy"} 10 | * goodbye 11 | - utter_goodbye 12 | - export 13 | ## Generated Story -3351152636827275381 14 | * greet 15 | - utter_greet 16 | * inform[location=London] 17 | - slot{"location": "London"} 18 | - action_weather 19 | * goodbye 20 | - utter_goodbye 21 | - export 22 | ## Generated Story 8921121480760034253 23 | * greet 24 | - utter_greet 25 | * inform 26 | - utter_ask_location 27 | * inform[location=London] 28 | - slot{"location": "London"} 29 | - action_weather 30 | * goodbye 31 | - utter_goodbye 32 | - export 33 | ## Generated Story -5208991511085841103 34 | - slot{"location": "London"} 35 | - action_weather 36 | * goodbye 37 | - utter_goodbye 38 | - export 39 | ## Generated Story -5208991511085841103 40 | - slot{"location": "London"} 41 | - action_weather 42 | * goodbye 43 | - utter_goodbye 44 | - export 45 | ## story_001 46 | * greet 47 | - utter_greet 48 | * inform 49 | - utter_ask_location 50 | * inform[location=London] 51 | - slot{"location": "London"} 52 | - action_weather 53 | * goodbye 54 | - utter_goodbye 55 | ## story_002 56 | * greet 57 | - utter_greet 58 | * inform[location=Paris] 59 | - slot{"location": "Paris"} 60 | - action_weather 61 | * goodbye 62 | - utter_goodbye 63 | ## story_003 64 | * greet 65 | - utter_greet 66 | * inform 67 | - utter_ask_location 68 | * inform[location=Vilnius] 69 | - slot{"location": "Vilnius"} 70 | - action_weather 71 | * goodbye 72 | - utter_goodbye 73 | ## story_004 74 | * greet 75 | - utter_greet 76 | * inform[location=Italy] 77 | - slot{"location": "Italy"} 78 | - action_weather 79 | * goodbye 80 | - utter_goodbye 81 | ## story_005 82 | * greet 83 | - utter_greet 84 | * inform 85 | - utter_ask_location 86 | * inform[location=Lithuania] 87 | - slot{"location": "Lithuania"} 88 | - action_weather 89 | * goodbye 90 | - utter_goodbye 91 | ## Generated Story 749341625444436446 92 | - slot{"location": "London"} 93 | - action_weather 94 | * goodbye 95 | - utter_goodbye 96 | - export 97 | ## Generated Story 3674528830535006447 98 | - action_weather 99 | - slot{"location": "italy"} 100 | * goodbye 101 | - utter_goodbye 102 | - export 103 | ## Generated Story 749341625444436446 104 | - slot{"location": "London"} 105 | - action_weather 106 | * goodbye 107 | - utter_goodbye 108 | - export 109 | ## Generated Story 749341625444436446 110 | - slot{"location": "London"} 111 | - action_weather 112 | * goodbye 113 | - utter_goodbye 114 | - export 115 | ## Generated Story 749341625444436446 116 | - slot{"location": "London"} 117 | - action_weather 118 | * goodbye 119 | - utter_goodbye 120 | - export 121 | ## Generated Story -853329873854260177 122 | * goodbye 123 | - utter_goodbye 124 | - export 125 | ## Generated Story -853329873854260177 126 | * goodbye 127 | - utter_goodbye 128 | - export 129 | ## Generated Story -853329873854260177 130 | * goodbye 131 | - utter_goodbye 132 | - export 133 | ## Generated Story -853329873854260177 134 | * goodbye 135 | - utter_goodbye 136 | - export 137 | ## Generated Story -853329873854260177 138 | * goodbye 139 | - utter_goodbye 140 | - export 141 | ## Generated Story 749341625444436446 142 | - slot{"location": "London"} 143 | - action_weather 144 | * goodbye 145 | - utter_goodbye 146 | - export 147 | ## Generated Story 3674528830535006447 148 | - action_weather 149 | - slot{"location": "italy"} 150 | * goodbye 151 | - utter_goodbye 152 | - export 153 | ## Generated Story 749341625444436446 154 | - slot{"location": "London"} 155 | - action_weather 156 | * goodbye 157 | - utter_goodbye 158 | - export 159 | ## Generated Story 749341625444436446 160 | - slot{"location": "London"} 161 | - action_weather 162 | * goodbye 163 | - utter_goodbye 164 | - export 165 | ## Generated Story 749341625444436446 166 | - slot{"location": "London"} 167 | - action_weather 168 | * goodbye 169 | - utter_goodbye 170 | - export 171 | ## Generated Story -853329873854260177 172 | * goodbye 173 | - utter_goodbye 174 | - export 175 | ## Generated Story -853329873854260177 176 | * goodbye 177 | - utter_goodbye 178 | - export 179 | ## Generated Story -853329873854260177 180 | * goodbye 181 | - utter_goodbye 182 | - export 183 | ## Generated Story -853329873854260177 184 | * goodbye 185 | - utter_goodbye 186 | - export 187 | ## Generated Story -853329873854260177 188 | * goodbye 189 | - utter_goodbye 190 | - export 191 | ## Generated Story 749341625444436446 192 | - slot{"location": "London"} 193 | - action_weather 194 | * goodbye 195 | - utter_goodbye 196 | - export 197 | ## Generated Story 3674528830535006447 198 | - action_weather 199 | - slot{"location": "italy"} 200 | * goodbye 201 | - utter_goodbye 202 | - export 203 | ## Generated Story 749341625444436446 204 | - slot{"location": "London"} 205 | - action_weather 206 | * goodbye 207 | - utter_goodbye 208 | - export 209 | ## Generated Story 749341625444436446 210 | - slot{"location": "London"} 211 | - action_weather 212 | * goodbye 213 | - utter_goodbye 214 | - export 215 | ## Generated Story 749341625444436446 216 | - slot{"location": "London"} 217 | - action_weather 218 | * goodbye 219 | - utter_goodbye 220 | - export 221 | ## Generated Story -853329873854260177 222 | * goodbye 223 | - utter_goodbye 224 | - export 225 | ## Generated Story -853329873854260177 226 | * goodbye 227 | - utter_goodbye 228 | - export 229 | ## Generated Story -853329873854260177 230 | * goodbye 231 | - utter_goodbye 232 | - export 233 | ## Generated Story -853329873854260177 234 | * goodbye 235 | - utter_goodbye 236 | - export 237 | ## Generated Story -853329873854260177 238 | * goodbye 239 | - utter_goodbye 240 | - export 241 | ## Generated Story 749341625444436446 242 | - slot{"location": "London"} 243 | - action_weather 244 | * goodbye 245 | - utter_goodbye 246 | - export 247 | ## Generated Story 3674528830535006447 248 | - action_weather 249 | - slot{"location": "italy"} 250 | * goodbye 251 | - utter_goodbye 252 | - export 253 | ## Generated Story 749341625444436446 254 | - slot{"location": "London"} 255 | - action_weather 256 | * goodbye 257 | - utter_goodbye 258 | - export 259 | ## Generated Story 749341625444436446 260 | - slot{"location": "London"} 261 | - action_weather 262 | * goodbye 263 | - utter_goodbye 264 | - export 265 | ## Generated Story 749341625444436446 266 | - slot{"location": "London"} 267 | - action_weather 268 | * goodbye 269 | - utter_goodbye 270 | - export 271 | ## Generated Story -853329873854260177 272 | * goodbye 273 | - utter_goodbye 274 | - export 275 | ## Generated Story -853329873854260177 276 | * goodbye 277 | - utter_goodbye 278 | - export 279 | ## Generated Story -853329873854260177 280 | * goodbye 281 | - utter_goodbye 282 | - export 283 | ## Generated Story -853329873854260177 284 | * goodbye 285 | - utter_goodbye 286 | - export 287 | ## Generated Story -853329873854260177 288 | * goodbye 289 | - utter_goodbye 290 | - export 291 | ## Generated Story -11764743858527245 292 | - slot{"location": "London"} 293 | - action_weather 294 | * goodbye 295 | - utter_goodbye 296 | - export 297 | ## Generated Story -11764743858527245 298 | - slot{"location": "London"} 299 | - action_weather 300 | * goodbye 301 | - utter_goodbye 302 | - export 303 | ## Generated Story -387284345606858929 304 | - action_weather 305 | - slot{"location": "italy"} 306 | * goodbye 307 | - utter_goodbye 308 | - export 309 | ## Generated Story -11764743858527245 310 | - slot{"location": "London"} 311 | - action_weather 312 | * goodbye 313 | - utter_goodbye 314 | - export 315 | ## Generated Story -11764743858527245 316 | - slot{"location": "London"} 317 | - action_weather 318 | * goodbye 319 | - utter_goodbye 320 | - export 321 | ## Generated Story -7673766305203884102 322 | * goodbye 323 | - utter_goodbye 324 | - export 325 | ## Generated Story -7673766305203884102 326 | * goodbye 327 | - utter_goodbye 328 | - export 329 | ## Generated Story -7673766305203884102 330 | * goodbye 331 | - utter_goodbye 332 | - export 333 | ## Generated Story -7673766305203884102 334 | * goodbye 335 | - utter_goodbye 336 | - export 337 | ## Generated Story -7673766305203884102 338 | * goodbye 339 | - utter_goodbye 340 | - export 341 | ## Generated Story -11764743858527245 342 | - slot{"location": "London"} 343 | - action_weather 344 | * goodbye 345 | - utter_goodbye 346 | - export 347 | ## Generated Story -11764743858527245 348 | - slot{"location": "London"} 349 | - action_weather 350 | * goodbye 351 | - utter_goodbye 352 | - export 353 | ## Generated Story -387284345606858929 354 | - action_weather 355 | - slot{"location": "italy"} 356 | * goodbye 357 | - utter_goodbye 358 | - export 359 | ## Generated Story -11764743858527245 360 | - slot{"location": "London"} 361 | - action_weather 362 | * goodbye 363 | - utter_goodbye 364 | - export 365 | ## Generated Story -11764743858527245 366 | - slot{"location": "London"} 367 | - action_weather 368 | * goodbye 369 | - utter_goodbye 370 | - export 371 | ## Generated Story -7673766305203884102 372 | * goodbye 373 | - utter_goodbye 374 | - export 375 | ## Generated Story -7673766305203884102 376 | * goodbye 377 | - utter_goodbye 378 | - export 379 | ## Generated Story -7673766305203884102 380 | * goodbye 381 | - utter_goodbye 382 | - export 383 | ## Generated Story -7673766305203884102 384 | * goodbye 385 | - utter_goodbye 386 | - export 387 | ## Generated Story -7673766305203884102 388 | * goodbye 389 | - utter_goodbye 390 | - export 391 | ## Generated Story -11764743858527245 392 | - slot{"location": "London"} 393 | - action_weather 394 | * goodbye 395 | - utter_goodbye 396 | - export 397 | ## Generated Story -11764743858527245 398 | - slot{"location": "London"} 399 | - action_weather 400 | * goodbye 401 | - utter_goodbye 402 | - export 403 | ## Generated Story -387284345606858929 404 | - action_weather 405 | - slot{"location": "italy"} 406 | * goodbye 407 | - utter_goodbye 408 | - export 409 | ## Generated Story -11764743858527245 410 | - slot{"location": "London"} 411 | - action_weather 412 | * goodbye 413 | - utter_goodbye 414 | - export 415 | ## Generated Story -11764743858527245 416 | - slot{"location": "London"} 417 | - action_weather 418 | * goodbye 419 | - utter_goodbye 420 | - export 421 | ## Generated Story -7673766305203884102 422 | * goodbye 423 | - utter_goodbye 424 | - export 425 | ## Generated Story -7673766305203884102 426 | * goodbye 427 | - utter_goodbye 428 | - export 429 | ## Generated Story -7673766305203884102 430 | * goodbye 431 | - utter_goodbye 432 | - export 433 | ## Generated Story -7673766305203884102 434 | * goodbye 435 | - utter_goodbye 436 | - export 437 | ## Generated Story -7673766305203884102 438 | * goodbye 439 | - utter_goodbye 440 | - export 441 | ## Generated Story -11764743858527245 442 | - slot{"location": "London"} 443 | - action_weather 444 | * goodbye 445 | - utter_goodbye 446 | - export 447 | ## Generated Story -11764743858527245 448 | - slot{"location": "London"} 449 | - action_weather 450 | * goodbye 451 | - utter_goodbye 452 | - export 453 | ## Generated Story -387284345606858929 454 | - action_weather 455 | - slot{"location": "italy"} 456 | * goodbye 457 | - utter_goodbye 458 | - export 459 | ## Generated Story -11764743858527245 460 | - slot{"location": "London"} 461 | - action_weather 462 | * goodbye 463 | - utter_goodbye 464 | - export 465 | ## Generated Story -11764743858527245 466 | - slot{"location": "London"} 467 | - action_weather 468 | * goodbye 469 | - utter_goodbye 470 | - export 471 | ## Generated Story -7673766305203884102 472 | * goodbye 473 | - utter_goodbye 474 | - export 475 | ## Generated Story -7673766305203884102 476 | * goodbye 477 | - utter_goodbye 478 | - export 479 | ## Generated Story -7673766305203884102 480 | * goodbye 481 | - utter_goodbye 482 | - export 483 | ## Generated Story -7673766305203884102 484 | * goodbye 485 | - utter_goodbye 486 | - export 487 | ## Generated Story -7673766305203884102 488 | * goodbye 489 | - utter_goodbye 490 | - export 491 | -------------------------------------------------------------------------------- /Full Code/train_init.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import unicode_literals 4 | 5 | import logging 6 | 7 | from rasa_core.agent import Agent 8 | from rasa_core.policies.keras_policy import KerasPolicy 9 | from rasa_core.policies.memoization import MemoizationPolicy 10 | 11 | if __name__ == '__main__': 12 | logging.basicConfig(level='INFO') 13 | 14 | training_data_file = './data/stories.md' 15 | model_path = './models/dialogue' 16 | 17 | agent = Agent('weather_domain.yml', policies = [MemoizationPolicy(), KerasPolicy()]) 18 | 19 | agent.train( 20 | training_data_file, 21 | augmentation_factor = 50, 22 | max_history = 2, 23 | epochs = 500, 24 | batch_size = 10, 25 | validation_split = 0.2) 26 | 27 | agent.persist(model_path) 28 | -------------------------------------------------------------------------------- /Full Code/train_online.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | from __future__ import unicode_literals 5 | 6 | import logging 7 | 8 | from rasa_core.agent import Agent 9 | from rasa_core.channels.console import ConsoleInputChannel 10 | from rasa_core.interpreter import RegexInterpreter 11 | from rasa_core.policies.keras_policy import KerasPolicy 12 | from rasa_core.policies.memoization import MemoizationPolicy 13 | from rasa_core.interpreter import RasaNLUInterpreter 14 | 15 | logger = logging.getLogger(__name__) 16 | 17 | 18 | def run_weather_online(input_channel, interpreter, 19 | domain_file="weather_domain.yml", 20 | training_data_file='data/stories.md'): 21 | agent = Agent(domain_file, 22 | policies=[MemoizationPolicy(), KerasPolicy()], 23 | interpreter=interpreter) 24 | 25 | agent.train_online(training_data_file, 26 | input_channel=input_channel, 27 | max_history=2, 28 | batch_size=50, 29 | epochs=200, 30 | max_training_samples=300) 31 | 32 | return agent 33 | 34 | 35 | if __name__ == '__main__': 36 | logging.basicConfig(level="INFO") 37 | nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu') 38 | run_weather_online(ConsoleInputChannel(), nlu_interpreter) 39 | -------------------------------------------------------------------------------- /Full Code/weather_domain.yml: -------------------------------------------------------------------------------- 1 | slots: 2 | location: 3 | type: text 4 | 5 | 6 | intents: 7 | - greet 8 | - goodbye 9 | - inform 10 | 11 | 12 | entities: 13 | - location 14 | 15 | templates: 16 | utter_greet: 17 | - 'Hello! How can I help?' 18 | utter_goodbye: 19 | - 'Talk to you later.' 20 | - 'Bye bye :(' 21 | utter_ask_location: 22 | - 'In what location?' 23 | 24 | 25 | actions: 26 | - utter_greet 27 | - utter_goodbye 28 | - utter_ask_location 29 | - actions.ActionWeather 30 | -------------------------------------------------------------------------------- /Full_Code_Latest/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full_Code_Latest/.DS_Store -------------------------------------------------------------------------------- /Full_Code_Latest/README.md: -------------------------------------------------------------------------------- 1 | # Weatherbot Tutorial (using the latest release of Rasa) 2 | 3 | **Disclaimer: This project is not an official Rasa tutorial. 4 | While it's a good source to learn about Rasa, I would recommend 5 | also checking out official Rasa education sources like 6 | [Rasa Masterclass](https://www.youtube.com/playlist?list=PL75e0qA87dlHQny7z43NduZHPo6qd-cRc).** 7 | 8 | 9 | Rasa devs are doing an amazing job improving this library which results in code changes for one method or another. In fact, since I recorded a Wetherbot tutorial, 10 | there were quite a few changes which were introduced to Rasa (former Rasa NLU and Rasa Core). This repo contains the updated weatherbot code compatible with the latest release of Rasa. 11 | 12 | ## How to use this repo 13 | 14 | The code of this repo differs quite significantly from the original video. This is how to use it: 15 | 16 | ### Training the NLU model 17 | 18 | Since the release of Rasa 1.0, the training of the NLU models became a lot easier with the new CLI. Train the model by running: 19 | 20 | ```rasa train nlu ``` 21 | 22 | Once the model is trained, test the model: 23 | 24 | ```rasa shell nlu``` 25 | 26 | 27 | ### Training the dialogue model 28 | 29 | The biggest change in how Rasa Core model works is that custom action 'action_weather' now needs to run on a separate server. That server has to be configured in a 'endpoints.yml' file. This is how to train and run the dialogue management model: 30 | 1. Start the custom action server by running: 31 | 32 | ``` rasa run actions``` 33 | 34 | 2. Open a new terminal and train the Rasa Core model by running: 35 | 36 | ``` rasa train``` 37 | 38 | 3. Talk to the chatbot once it's loaded after running: 39 | ```rasa shell``` 40 | 41 | 42 | ### Starting the interactive training session: 43 | 44 | To run your assistant in a interactive learning session, run: 45 | 1. Make sure the custom actions server is running: 46 | 47 | ```rasa run actions``` 48 | 49 | 2. Start the interactive training session by running: 50 | 51 | ```rasa interactive``` 52 | 53 | ### Connecting a chatbot to Slack: 54 | 1. Configure the slack app as shown in the video 55 | 2. Provide the slack configuration tokens in a credentials.yml file 56 | 3. Make sure custom actions server is running 57 | 4. Start the agent by running `rasa run` 58 | 5. Start the ngrok on the port 5004 59 | 6. Provide the url: https://your_ngrok_url/webhooks/slack/webhook to 'Event Subscriptions' page of the slack configuration. 60 | 7. Talk to you bot. 61 | 62 | I will do my best to keep this repo up-to-date, but if you encounter any issues with using the code, please raise an issue or drop me a message :) 63 | 64 | Latest code update: 31/04/2020 65 | 66 | Latest compatible Rasa version: 1.9.6 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Full_Code_Latest/__pycache__/actions.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full_Code_Latest/__pycache__/actions.cpython-36.pyc -------------------------------------------------------------------------------- /Full_Code_Latest/actions.py: -------------------------------------------------------------------------------- 1 | from rasa_sdk import Action 2 | from rasa_sdk.events import SlotSet 3 | 4 | class ActionWeather(Action): 5 | def name(self): 6 | return 'action_weather' 7 | 8 | def run(self, dispatcher, tracker, domain): 9 | from apixu.client import ApixuClient 10 | api_key = '...' #your apixu key 11 | client = ApixuClient(api_key) 12 | 13 | loc = tracker.get_slot('location') 14 | current = client.getcurrent(q=loc) 15 | 16 | country = current['location']['country'] 17 | city = current['location']['name'] 18 | condition = current['current']['condition']['text'] 19 | temperature_c = current['current']['temp_c'] 20 | humidity = current['current']['humidity'] 21 | wind_mph = current['current']['wind_mph'] 22 | 23 | response = """It is currently {} in {} at the moment. The temperature is {} degrees, the humidity is {}% and the wind speed is {} mph.""".format(condition, city, temperature_c, humidity, wind_mph) 24 | 25 | dispatcher.utter_message(response) 26 | return [SlotSet('location',loc)] 27 | 28 | -------------------------------------------------------------------------------- /Full_Code_Latest/config.yml: -------------------------------------------------------------------------------- 1 | language: "en" 2 | pipeline: "pretrained_embeddings_spacy" 3 | 4 | 5 | policies: 6 | - name: MemoizationPolicy 7 | - name: KerasPolicy 8 | epochs: 200 -------------------------------------------------------------------------------- /Full_Code_Latest/credentials.yml: -------------------------------------------------------------------------------- 1 | slack: 2 | slack_token: "xoxb-286425452756-safjasdf7sl38KLls" 3 | slack_channel: "#my_channel" -------------------------------------------------------------------------------- /Full_Code_Latest/data/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "rasa_nlu_data": { 3 | "common_examples": [ 4 | { 5 | "text": "Hello", 6 | "intent": "greet", 7 | "entities": [] 8 | }, 9 | { 10 | "text": "goodbye", 11 | "intent": "goodbye", 12 | "entities": [] 13 | }, 14 | { 15 | "text": "What's the weather in Berlin at the moment?", 16 | "intent": "inform", 17 | "entities": [ 18 | { 19 | "start": 22, 20 | "end": 28, 21 | "value": "Berlin", 22 | "entity": "location" 23 | } 24 | ] 25 | }, 26 | { 27 | "text": "hey", 28 | "intent": "greet", 29 | "entities": [] 30 | }, 31 | { 32 | "text": "hello", 33 | "intent": "greet", 34 | "entities": [] 35 | }, 36 | { 37 | "text": "hi", 38 | "intent": "greet", 39 | "entities": [] 40 | }, 41 | { 42 | "text": "heya", 43 | "intent": "greet", 44 | "entities": [] 45 | }, 46 | { 47 | "text": "howdy", 48 | "intent": "greet", 49 | "entities": [] 50 | }, 51 | { 52 | "text": "hey there", 53 | "intent": "greet", 54 | "entities": [] 55 | }, 56 | { 57 | "text": "bye", 58 | "intent": "goodbye", 59 | "entities": [] 60 | }, 61 | { 62 | "text": "goodbye", 63 | "intent": "goodbye", 64 | "entities": [] 65 | }, 66 | { 67 | "text": "bye bye", 68 | "intent": "goodbye", 69 | "entities": [] 70 | }, 71 | { 72 | "text": "see ya", 73 | "intent": "goodbye", 74 | "entities": [] 75 | }, 76 | { 77 | "text": "see you later", 78 | "intent": "goodbye", 79 | "entities": [] 80 | }, 81 | { 82 | "text": "What's the weather today?", 83 | "intent": "inform", 84 | "entities": [] 85 | }, 86 | { 87 | "text": "What's the weather in London today?", 88 | "intent": "inform", 89 | "entities": [ 90 | { 91 | "start": 22, 92 | "end": 28, 93 | "value": "London", 94 | "entity": "location" 95 | } 96 | ] 97 | }, 98 | { 99 | "text": "Show me what's the weather in Paris", 100 | "intent": "inform", 101 | "entities": [ 102 | { 103 | "start": 30, 104 | "end": 35, 105 | "value": "Paris", 106 | "entity": "location" 107 | } 108 | ] 109 | }, 110 | { 111 | "text": "I wonder what is the weather in Vilnius right now?", 112 | "intent": "inform", 113 | "entities": [ 114 | { 115 | "start": 32, 116 | "end": 39, 117 | "value": "Vilnius", 118 | "entity": "location" 119 | } 120 | ] 121 | }, 122 | { 123 | "text": "what is the weather?", 124 | "intent": "inform", 125 | "entities": [] 126 | }, 127 | { 128 | "text": "Tell me the weather", 129 | "intent": "inform", 130 | "entities": [] 131 | }, 132 | { 133 | "text": "Is the weather nice in Barcelona today?", 134 | "intent": "inform", 135 | "entities": [ 136 | { 137 | "start": 23, 138 | "end": 32, 139 | "value": "Barcelona", 140 | "entity": "location" 141 | } 142 | ] 143 | }, 144 | { 145 | "text": "I am going to London today and I wonder what is the weather out there?", 146 | "intent": "inform", 147 | "entities": [ 148 | { 149 | "start": 14, 150 | "end": 20, 151 | "value": "London", 152 | "entity": "location" 153 | } 154 | ] 155 | }, 156 | { 157 | "text": "I am planning my trip to Amsterdam. What is the weather out there?", 158 | "intent": "inform", 159 | "entities": [ 160 | { 161 | "start": 25, 162 | "end": 34, 163 | "value": "Amsterdam", 164 | "entity": "location" 165 | } 166 | ] 167 | }, 168 | { 169 | "text": "Show me the weather in Dublin, please", 170 | "intent": "inform", 171 | "entities": [ 172 | { 173 | "start": 23, 174 | "end": 29, 175 | "value": "Dublin", 176 | "entity": "location" 177 | } 178 | ] 179 | }, 180 | { 181 | "text": "in London", 182 | "intent": "inform", 183 | "entities": [ 184 | { 185 | "start": 3, 186 | "end": 9, 187 | "value": "London", 188 | "entity": "location" 189 | } 190 | ] 191 | }, 192 | { 193 | "text": "Lithuania", 194 | "intent": "inform", 195 | "entities": [ 196 | { 197 | "start": 0, 198 | "end": 9, 199 | "value": "Lithuania", 200 | "entity": "location" 201 | } 202 | ] 203 | }, 204 | { 205 | "text": "Oh, sorry, in Italy", 206 | "intent": "inform", 207 | "entities": [ 208 | { 209 | "start": 14, 210 | "end": 19, 211 | "value": "Italy", 212 | "entity": "location" 213 | } 214 | ] 215 | }, 216 | { 217 | "text": "Tell me the weather in Vilnius", 218 | "intent": "inform", 219 | "entities": [ 220 | { 221 | "start": 23, 222 | "end": 30, 223 | "value": "Vilnius", 224 | "entity": "location" 225 | } 226 | ] 227 | }, 228 | { 229 | "text": "The weather condition in Italy", 230 | "intent": "inform", 231 | "entities": [ 232 | { 233 | "start": 25, 234 | "end": 30, 235 | "value": "Italy", 236 | "entity": "location" 237 | } 238 | ] 239 | } 240 | ] 241 | } 242 | } -------------------------------------------------------------------------------- /Full_Code_Latest/data/stories.md: -------------------------------------------------------------------------------- 1 | ## Generated Story 3320800183399695936 2 | * greet 3 | - utter_greet 4 | * inform 5 | - utter_ask_location 6 | * inform{"location": "italy"} 7 | - slot{"location": "italy"} 8 | - action_weather 9 | - slot{"location": "italy"} 10 | * goodbye 11 | - utter_goodbye 12 | - export 13 | ## Generated Story -3351152636827275381 14 | * greet 15 | - utter_greet 16 | * inform{"location": "London"} 17 | - slot{"location": "London"} 18 | - action_weather 19 | * goodbye 20 | - utter_goodbye 21 | - export 22 | ## Generated Story 8921121480760034253 23 | * greet 24 | - utter_greet 25 | * inform 26 | - utter_ask_location 27 | * inform{"location":"London"} 28 | - slot{"location": "London"} 29 | - action_weather 30 | * goodbye 31 | - utter_goodbye 32 | - export 33 | ## Generated Story -5208991511085841103 34 | - slot{"location": "London"} 35 | - action_weather 36 | * goodbye 37 | - utter_goodbye 38 | - export 39 | ## Generated Story -5208991511085841103 40 | - slot{"location": "London"} 41 | - action_weather 42 | * goodbye 43 | - utter_goodbye 44 | - export 45 | ## story_001 46 | * greet 47 | - utter_greet 48 | * inform 49 | - utter_ask_location 50 | * inform{"location":"London"} 51 | - slot{"location": "London"} 52 | - action_weather 53 | * goodbye 54 | - utter_goodbye 55 | ## story_002 56 | * greet 57 | - utter_greet 58 | * inform{"location":"Paris"} 59 | - slot{"location": "Paris"} 60 | - action_weather 61 | * goodbye 62 | - utter_goodbye 63 | ## story_003 64 | * greet 65 | - utter_greet 66 | * inform 67 | - utter_ask_location 68 | * inform{"location":"Vilnius"} 69 | - slot{"location": "Vilnius"} 70 | - action_weather 71 | * goodbye 72 | - utter_goodbye 73 | ## story_004 74 | * greet 75 | - utter_greet 76 | * inform{"location":"Italy"} 77 | - slot{"location": "Italy"} 78 | - action_weather 79 | * goodbye 80 | - utter_goodbye 81 | ## story_005 82 | * greet 83 | - utter_greet 84 | * inform 85 | - utter_ask_location 86 | * inform{"location":"Lithuania"} 87 | - slot{"location": "Lithuania"} 88 | - action_weather 89 | * goodbye 90 | - utter_goodbye 91 | -------------------------------------------------------------------------------- /Full_Code_Latest/domain.yml: -------------------------------------------------------------------------------- 1 | slots: 2 | location: 3 | type: text 4 | 5 | 6 | intents: 7 | - greet 8 | - goodbye 9 | - inform 10 | 11 | 12 | entities: 13 | - location 14 | 15 | responses: 16 | utter_greet: 17 | - text: 'Hello! How can I help?' 18 | utter_goodbye: 19 | - text: 'Talk to you later.' 20 | - text: 'Bye bye :(' 21 | utter_ask_location: 22 | - text: 'In what location?' 23 | 24 | 25 | actions: 26 | - action_weather 27 | -------------------------------------------------------------------------------- /Full_Code_Latest/endpoints.yml: -------------------------------------------------------------------------------- 1 | action_endpoint: 2 | url: "http://localhost:5055/webhook/" -------------------------------------------------------------------------------- /Full_Code_Latest/models/20190717-171515.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full_Code_Latest/models/20190717-171515.tar.gz -------------------------------------------------------------------------------- /Full_Code_Latest/models/20200421-110137.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full_Code_Latest/models/20200421-110137.tar.gz -------------------------------------------------------------------------------- /Full_Code_Latest/models/dialogue/domain.json: -------------------------------------------------------------------------------- 1 | { 2 | "states": [ 3 | "intent_goodbye", 4 | "intent_greet", 5 | "intent_inform", 6 | "entity_location", 7 | "slot_location_0", 8 | "prev_action_listen", 9 | "prev_action_restart", 10 | "prev_action_default_fallback", 11 | "prev_action_deactivate_form", 12 | "prev_action_revert_fallback_events", 13 | "prev_action_default_ask_affirmation", 14 | "prev_action_default_ask_rephrase", 15 | "prev_utter_greet", 16 | "prev_utter_goodbye", 17 | "prev_utter_ask_location", 18 | "prev_action_weather" 19 | ] 20 | } -------------------------------------------------------------------------------- /Full_Code_Latest/models/dialogue/domain.yml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | actions: 4 | - utter_greet 5 | - utter_goodbye 6 | - utter_ask_location 7 | - action_weather 8 | config: 9 | store_entities_as_slots: true 10 | entities: 11 | - location 12 | forms: [] 13 | intents: 14 | - greet: 15 | use_entities: true 16 | - goodbye: 17 | use_entities: true 18 | - inform: 19 | use_entities: true 20 | slots: 21 | location: 22 | auto_fill: true 23 | initial_value: null 24 | type: rasa_core.slots.TextSlot 25 | templates: 26 | utter_ask_location: 27 | - text: In what location? 28 | utter_goodbye: 29 | - text: Talk to you later. 30 | - text: Bye bye :( 31 | utter_greet: 32 | - text: Hello! How can I help? 33 | -------------------------------------------------------------------------------- /Full_Code_Latest/models/dialogue/policy_0_MemoizationPolicy/featurizer.json: -------------------------------------------------------------------------------- 1 | {"py/object": "rasa_core.featurizers.MaxHistoryTrackerFeaturizer", "max_history": 5, "remove_duplicates": true, "state_featurizer": {"py/object": "rasa_core.featurizers.SingleStateFeaturizer", "slot_feature_len": null, "user_feature_len": null}, "use_intent_probabilities": false} -------------------------------------------------------------------------------- /Full_Code_Latest/models/dialogue/policy_0_MemoizationPolicy/memorized_turns.json: -------------------------------------------------------------------------------- 1 | { 2 | "max_history": 5, 3 | "lookup": { 4 | "eJyLzivNydFRQCari3PyS+Jz8pMTSzLz8+INrBQM9QxqgeIFRall8YnJYNHy1MSSjNQisJyOAlYdsQDw8iAM": 0, 5 | "eJyLzivNydFRgJDVxTn5JfE5+cmJJZn5efEGVgqGega1QPGCotSy+MRksGh5amJJRmoRWE5HAZeOzLyS1LyS+PT8/JSkylSoYmRjcjKLgSrwmRILANZRNgc=": 8, 6 | "eJyLzivNydFRqC7OyS+Jz8lPTizJzM+LN7BSMNQzqAWKFxSllsUnJoNFy1MTSzJSi8ByOgq4dGTmlaTmlcSn5+enJFWmQhUjG5OTWQxUQbYppSUlqUVoElhNiQUAQBxMEg==": 0, 7 | "eJyLri7OyS+Jz8lPTizJzM+LN7BSMNQzqNVRqC4oSi2LT0wGi5anJpZkpBaB5XQUcOnIzCtJzSuJT8/PT0mqTIUqRjYmJ7MYqIJsU0pLSlKL0CQImVKUmlpClktiAV+yYTs=": 7, 8 | "eJyLri4oSi2LT0wuyczPiy9PTSzJSC2yUjDUM9BRKM7JL4nPyU9OBMsZgEVrdRSqM/NKUvNK4tPz81OSKlOhipGNycksBqog25TSkpLUIjQJQqYUpaaWUOoSdDOg7kASxmpCLACUiG9z": 0, 9 | "eJyLrs7MK0nNK4lPz89PSapMtVIw1DPQUSgoSi2LT0wuyczPi8/JLAaqgEoU5+SXxOfkJyeCpQzAorU6CnhMKS0pSS1CkyBkSlFqagmlLkE3A+oOJGFcJgC1Z5ZUwmWgqqHmZual5RflkuW4WABRKn1N": 10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7MK0nNK4lPz89PSapMtVIw1DPQUSgoSi2LLy0pSS1CkyjOyS+Jz8lPTizJzM+LNwCL1uoo4DElMRmstDw1sSQjtYhSY3Iyi4EqyDaF3l6KBQBYBnlZ": 0, 54 | "eJyLrs7MK0nNK4lPz89PSapMtVIw1DPQUSgoSi2LT0wuyczPiy9PTSzJSC2CyhTn5JfE5+QnJ4LlDMCitToKhI3JySwGqiDblNKSktQiNAmy3UI3L8UCAEyeeUk=": 8 55 | } 56 | } -------------------------------------------------------------------------------- /Full_Code_Latest/models/dialogue/policy_1_KerasPolicy/featurizer.json: -------------------------------------------------------------------------------- 1 | {"py/object": "rasa_core.featurizers.MaxHistoryTrackerFeaturizer", "max_history": 3, "remove_duplicates": true, "state_featurizer": {"py/object": "rasa_core.featurizers.BinarySingleStateFeaturizer", "input_state_map": {"entity_location": 3, "intent_goodbye": 0, "intent_greet": 1, "intent_inform": 2, "prev_action_deactivate_form": 8, "prev_action_default_ask_affirmation": 10, "prev_action_default_ask_rephrase": 11, "prev_action_default_fallback": 7, "prev_action_listen": 5, "prev_action_restart": 6, "prev_action_revert_fallback_events": 9, "prev_action_weather": 15, "prev_utter_ask_location": 14, "prev_utter_goodbye": 13, "prev_utter_greet": 12, "slot_location_0": 4}, "num_features": 16, "slot_feature_len": 1, "user_feature_len": 4}, "use_intent_probabilities": false} -------------------------------------------------------------------------------- /Full_Code_Latest/models/dialogue/policy_1_KerasPolicy/keras_model.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full_Code_Latest/models/dialogue/policy_1_KerasPolicy/keras_model.h5 -------------------------------------------------------------------------------- /Full_Code_Latest/models/dialogue/policy_1_KerasPolicy/keras_policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "model": "keras_model.h5", 3 | "epochs": 100 4 | } -------------------------------------------------------------------------------- /Full_Code_Latest/models/dialogue/policy_metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "action_fingerprints": { 3 | "null": { 4 | "slots": [ 5 | "location" 6 | ] 7 | }, 8 | "action_listen": { 9 | "slots": [ 10 | "location" 11 | ] 12 | }, 13 | "utter_goodbye": { 14 | "slots": [ 15 | "location" 16 | ] 17 | } 18 | }, 19 | "python": "3.6.7", 20 | "max_histories": [ 21 | 5, 22 | 3 23 | ], 24 | "ensemble_name": "rasa_core.policies.ensemble.SimplePolicyEnsemble", 25 | "policy_names": [ 26 | "rasa_core.policies.memoization.MemoizationPolicy", 27 | "rasa_core.policies.keras_policy.KerasPolicy" 28 | ], 29 | "trained_at": "20190125-164749", 30 | "rasa_core": "0.13.0", 31 | "tensorflow": "1.12.0", 32 | "sklearn": "0.20.2" 33 | } -------------------------------------------------------------------------------- /Full_Code_Latest/models/nlu/default/weathernlu/crf_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full_Code_Latest/models/nlu/default/weathernlu/crf_model.pkl -------------------------------------------------------------------------------- /Full_Code_Latest/models/nlu/default/weathernlu/intent_classifier.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full_Code_Latest/models/nlu/default/weathernlu/intent_classifier.pkl -------------------------------------------------------------------------------- /Full_Code_Latest/models/nlu/default/weathernlu/intent_classifier_sklearn.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full_Code_Latest/models/nlu/default/weathernlu/intent_classifier_sklearn.pkl -------------------------------------------------------------------------------- /Full_Code_Latest/models/nlu/default/weathernlu/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "en", 3 | "pipeline": [ 4 | { 5 | "model": "en", 6 | "case_sensitive": false, 7 | "name": "nlp_spacy", 8 | "class": "rasa_nlu.utils.spacy_utils.SpacyNLP" 9 | }, 10 | { 11 | "name": "tokenizer_spacy", 12 | "class": "rasa_nlu.tokenizers.spacy_tokenizer.SpacyTokenizer" 13 | }, 14 | { 15 | "name": "intent_featurizer_spacy", 16 | "class": "rasa_nlu.featurizers.spacy_featurizer.SpacyFeaturizer" 17 | }, 18 | { 19 | "name": "intent_entity_featurizer_regex", 20 | "regex_file": "regex_featurizer.json", 21 | "class": "rasa_nlu.featurizers.regex_featurizer.RegexFeaturizer" 22 | }, 23 | { 24 | "BILOU_flag": true, 25 | "features": [ 26 | [ 27 | "low", 28 | "title", 29 | "upper" 30 | ], 31 | [ 32 | "bias", 33 | "low", 34 | "prefix5", 35 | "prefix2", 36 | "suffix5", 37 | "suffix3", 38 | "suffix2", 39 | "upper", 40 | "title", 41 | "digit", 42 | "pattern" 43 | ], 44 | [ 45 | "low", 46 | "title", 47 | "upper" 48 | ] 49 | ], 50 | "max_iterations": 50, 51 | "L1_c": 0.1, 52 | "L2_c": 0.1, 53 | "name": "ner_crf", 54 | "classifier_file": "crf_model.pkl", 55 | "class": "rasa_nlu.extractors.crf_entity_extractor.CRFEntityExtractor" 56 | }, 57 | { 58 | "name": "ner_synonyms", 59 | "synonyms_file": null, 60 | "class": "rasa_nlu.extractors.entity_synonyms.EntitySynonymMapper" 61 | }, 62 | { 63 | "C": [ 64 | 1, 65 | 2, 66 | 5, 67 | 10, 68 | 20, 69 | 100 70 | ], 71 | "gamma": [ 72 | 0.1 73 | ], 74 | "kernels": [ 75 | "linear" 76 | ], 77 | "max_cross_validation_folds": 5, 78 | "scoring_function": "f1_weighted", 79 | "name": "intent_classifier_sklearn", 80 | "classifier_file": "intent_classifier_sklearn.pkl", 81 | "class": "rasa_nlu.classifiers.sklearn_intent_classifier.SklearnIntentClassifier" 82 | } 83 | ], 84 | "training_data": "training_data.json", 85 | "trained_at": "20190125-164210", 86 | "rasa_nlu_version": "0.14.1" 87 | } -------------------------------------------------------------------------------- /Full_Code_Latest/models/nlu/default/weathernlu/regex_featurizer.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /Full_Code_Latest/models/nlu/default/weathernlu/training_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "rasa_nlu_data": { 3 | "common_examples": [ 4 | { 5 | "intent": "greet", 6 | "text": "Hello" 7 | }, 8 | { 9 | "intent": "goodbye", 10 | "text": "goodbye" 11 | }, 12 | { 13 | "intent": "inform", 14 | "entities": [ 15 | { 16 | "start": 22, 17 | "end": 28, 18 | "value": "Berlin", 19 | "entity": "location" 20 | } 21 | ], 22 | "text": "What's the weather in Berlin at the moment?" 23 | }, 24 | { 25 | "intent": "greet", 26 | "text": "hey" 27 | }, 28 | { 29 | "intent": "greet", 30 | "text": "hello" 31 | }, 32 | { 33 | "intent": "greet", 34 | "text": "hi" 35 | }, 36 | { 37 | "intent": "greet", 38 | "text": "heya" 39 | }, 40 | { 41 | "intent": "greet", 42 | "text": "howdy" 43 | }, 44 | { 45 | "intent": "greet", 46 | "text": "hey there" 47 | }, 48 | { 49 | "intent": "goodbye", 50 | "text": "bye" 51 | }, 52 | { 53 | "intent": "goodbye", 54 | "text": "goodbye" 55 | }, 56 | { 57 | "intent": "goodbye", 58 | "text": "bye bye" 59 | }, 60 | { 61 | "intent": "goodbye", 62 | "text": "see ya" 63 | }, 64 | { 65 | "intent": "goodbye", 66 | "text": "see you later" 67 | }, 68 | { 69 | "intent": "inform", 70 | "text": "What's the weather today?" 71 | }, 72 | { 73 | "intent": "inform", 74 | "entities": [ 75 | { 76 | "start": 22, 77 | "end": 28, 78 | "value": "London", 79 | "entity": "location" 80 | } 81 | ], 82 | "text": "What's the weather in London today?" 83 | }, 84 | { 85 | "intent": "inform", 86 | "entities": [ 87 | { 88 | "start": 30, 89 | "end": 35, 90 | "value": "Paris", 91 | "entity": "location" 92 | } 93 | ], 94 | "text": "Show me what's the weather in Paris" 95 | }, 96 | { 97 | "intent": "inform", 98 | "entities": [ 99 | { 100 | "start": 32, 101 | "end": 39, 102 | "value": "Vilnius", 103 | "entity": "location" 104 | } 105 | ], 106 | "text": "I wonder what is the weather in Vilnius right now?" 107 | }, 108 | { 109 | "intent": "inform", 110 | "text": "what is the weather?" 111 | }, 112 | { 113 | "intent": "inform", 114 | "text": "Tell me the weather" 115 | }, 116 | { 117 | "intent": "inform", 118 | "entities": [ 119 | { 120 | "start": 23, 121 | "end": 32, 122 | "value": "Barcelona", 123 | "entity": "location" 124 | } 125 | ], 126 | "text": "Is the weather nice in Barcelona today?" 127 | }, 128 | { 129 | "intent": "inform", 130 | "entities": [ 131 | { 132 | "start": 14, 133 | "end": 20, 134 | "value": "London", 135 | "entity": "location" 136 | } 137 | ], 138 | "text": "I am going to London today and I wonder what is the weather out there?" 139 | }, 140 | { 141 | "intent": "inform", 142 | "entities": [ 143 | { 144 | "start": 25, 145 | "end": 34, 146 | "value": "Amsterdam", 147 | "entity": "location" 148 | } 149 | ], 150 | "text": "I am planning my trip to Amsterdam. What is the weather out there?" 151 | }, 152 | { 153 | "intent": "inform", 154 | "entities": [ 155 | { 156 | "start": 23, 157 | "end": 29, 158 | "value": "Dublin", 159 | "entity": "location" 160 | } 161 | ], 162 | "text": "Show me the weather in Dublin, please" 163 | }, 164 | { 165 | "intent": "inform", 166 | "entities": [ 167 | { 168 | "start": 3, 169 | "end": 9, 170 | "value": "London", 171 | "entity": "location" 172 | } 173 | ], 174 | "text": "in London" 175 | }, 176 | { 177 | "intent": "inform", 178 | "entities": [ 179 | { 180 | "start": 0, 181 | "end": 9, 182 | "value": "Lithuania", 183 | "entity": "location" 184 | } 185 | ], 186 | "text": "Lithuania" 187 | }, 188 | { 189 | "intent": "inform", 190 | "entities": [ 191 | { 192 | "start": 14, 193 | "end": 19, 194 | "value": "Italy", 195 | "entity": "location" 196 | } 197 | ], 198 | "text": "Oh, sorry, in Italy" 199 | }, 200 | { 201 | "intent": "inform", 202 | "entities": [ 203 | { 204 | "start": 23, 205 | "end": 30, 206 | "value": "Vilnius", 207 | "entity": "location" 208 | } 209 | ], 210 | "text": "Tell me the weather in Vilnius" 211 | }, 212 | { 213 | "intent": "inform", 214 | "entities": [ 215 | { 216 | "start": 25, 217 | "end": 30, 218 | "value": "Italy", 219 | "entity": "location" 220 | } 221 | ], 222 | "text": "The weather condition in Italy" 223 | } 224 | ], 225 | "regex_features": [], 226 | "lookup_tables": [], 227 | "entity_synonyms": [] 228 | } 229 | } -------------------------------------------------------------------------------- /Full_Code_Latest/rasa_core.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinaPetr/Weatherbot_Tutorial/8485665b54f77681bbdcd99add80592ac8114816/Full_Code_Latest/rasa_core.log -------------------------------------------------------------------------------- /Full_Code_Latest/requirements.txt: -------------------------------------------------------------------------------- 1 | rasa==1.9.6 2 | git+https://github.com/apixu/apixu-python.git -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Weatherbot Tutorial 2 | 3 | **Disclaimer: This project is not an official Rasa tutorial. 4 | While it's a good source to learn about Rasa, I would recommend 5 | also checking out official Rasa education sources like 6 | [Rasa Masterclass](https://www.youtube.com/playlist?list=PL75e0qA87dlHQny7z43NduZHPo6qd-cRc).** 7 | 8 | 9 | This directory contains the code for a video tutorial which can be found here: https://jpboost.com/2018/02/06/creating-a-chatbot-with-rasa-nlu-and-rasa-core/ 10 | 11 | The directory contains three sub-directories: 12 | 13 | - 'Video Files' contains the 'getting started' files which you can use if you code as you watch. 14 | - 'Full Code' contains the full completed code of the tutorial which you can use if you want to test the models, make changes, break or improve things :) 15 | - 'Full_Code_Latest' contains the full code of Weatherbot tutorial which is compatible with the latest releases of Rasa NLU and Rasa Core. 16 | -------------------------------------------------------------------------------- /Video files/README.md: -------------------------------------------------------------------------------- 1 | # Weatherbot Tutorial (Video files) 2 | 3 | This directory contains the 'getting started' files which you can take and use if you want to create a bot as you watch the tutorial. 4 | 5 | -------------------------------------------------------------------------------- /Video files/data/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "rasa_nlu_data": { 3 | "common_examples": [ 4 | { 5 | "text": "Hello", 6 | "intent": "greet", 7 | "entities": [] 8 | }, 9 | { 10 | "text": "goodbye", 11 | "intent": "goodbye", 12 | "entities": [] 13 | }, 14 | { 15 | "text": "What's the weather in Berlin at the moment?", 16 | "intent": "inform", 17 | "entities": [ 18 | { 19 | "start": 22, 20 | "end": 28, 21 | "value": "Berlin", 22 | "entity": "location" 23 | } 24 | ] 25 | }, 26 | { 27 | "text": "hey", 28 | "intent": "greet", 29 | "entities": [] 30 | }, 31 | { 32 | "text": "hello", 33 | "intent": "greet", 34 | "entities": [] 35 | }, 36 | { 37 | "text": "hi", 38 | "intent": "greet", 39 | "entities": [] 40 | }, 41 | { 42 | "text": "heya", 43 | "intent": "greet", 44 | "entities": [] 45 | }, 46 | { 47 | "text": "howdy", 48 | "intent": "greet", 49 | "entities": [] 50 | }, 51 | { 52 | "text": "hey there", 53 | "intent": "greet", 54 | "entities": [] 55 | }, 56 | { 57 | "text": "bye", 58 | "intent": "goodbye", 59 | "entities": [] 60 | }, 61 | { 62 | "text": "goodbye", 63 | "intent": "goodbye", 64 | "entities": [] 65 | }, 66 | { 67 | "text": "bye bye", 68 | "intent": "goodbye", 69 | "entities": [] 70 | }, 71 | { 72 | "text": "see ya", 73 | "intent": "goodbye", 74 | "entities": [] 75 | }, 76 | { 77 | "text": "see you later", 78 | "intent": "goodbye", 79 | "entities": [] 80 | }, 81 | { 82 | "text": "What's the weather today?", 83 | "intent": "inform", 84 | "entities": [] 85 | }, 86 | { 87 | "text": "What's the weather in London today?", 88 | "intent": "inform", 89 | "entities": [ 90 | { 91 | "start": 22, 92 | "end": 28, 93 | "value": "London", 94 | "entity": "location" 95 | } 96 | ] 97 | }, 98 | { 99 | "text": "Show me what's the weather in Paris", 100 | "intent": "inform", 101 | "entities": [ 102 | { 103 | "start": 30, 104 | "end": 35, 105 | "value": "Paris", 106 | "entity": "location" 107 | } 108 | ] 109 | }, 110 | { 111 | "text": "I wonder what is the weather in Vilnius right now?", 112 | "intent": "inform", 113 | "entities": [ 114 | { 115 | "start": 32, 116 | "end": 39, 117 | "value": "Vilnius", 118 | "entity": "location" 119 | } 120 | ] 121 | }, 122 | { 123 | "text": "what is the weather?", 124 | "intent": "inform", 125 | "entities": [] 126 | }, 127 | { 128 | "text": "Tell me the weather", 129 | "intent": "inform", 130 | "entities": [] 131 | }, 132 | { 133 | "text": "Is the weather nice in Barcelona today?", 134 | "intent": "inform", 135 | "entities": [ 136 | { 137 | "start": 23, 138 | "end": 32, 139 | "value": "Barcelona", 140 | "entity": "location" 141 | } 142 | ] 143 | }, 144 | { 145 | "text": "I am going to London today and I wonder what is the weather out there?", 146 | "intent": "inform", 147 | "entities": [ 148 | { 149 | "start": 14, 150 | "end": 20, 151 | "value": "London", 152 | "entity": "location" 153 | } 154 | ] 155 | }, 156 | { 157 | "text": "I am planning my trip to Amsterdam. What is the weather out there?", 158 | "intent": "inform", 159 | "entities": [ 160 | { 161 | "start": 25, 162 | "end": 34, 163 | "value": "Amsterdam", 164 | "entity": "location" 165 | } 166 | ] 167 | }, 168 | { 169 | "text": "Show me the weather in Dublin, please", 170 | "intent": "inform", 171 | "entities": [ 172 | { 173 | "start": 23, 174 | "end": 29, 175 | "value": "Dublin", 176 | "entity": "location" 177 | } 178 | ] 179 | }, 180 | { 181 | "text": "in London", 182 | "intent": "inform", 183 | "entities": [ 184 | { 185 | "start": 3, 186 | "end": 9, 187 | "value": "London", 188 | "entity": "location" 189 | } 190 | ] 191 | }, 192 | { 193 | "text": "Lithuania", 194 | "intent": "inform", 195 | "entities": [ 196 | { 197 | "start": 0, 198 | "end": 9, 199 | "value": "Lithuania", 200 | "entity": "location" 201 | } 202 | ] 203 | }, 204 | { 205 | "text": "Oh, sorry, in Italy", 206 | "intent": "inform", 207 | "entities": [ 208 | { 209 | "start": 14, 210 | "end": 19, 211 | "value": "Italy", 212 | "entity": "location" 213 | } 214 | ] 215 | }, 216 | { 217 | "text": "Tell me the weather in Vilnius", 218 | "intent": "inform", 219 | "entities": [ 220 | { 221 | "start": 23, 222 | "end": 30, 223 | "value": "Vilnius", 224 | "entity": "location" 225 | } 226 | ] 227 | }, 228 | { 229 | "text": "The weather condition in Italy", 230 | "intent": "inform", 231 | "entities": [ 232 | { 233 | "start": 25, 234 | "end": 30, 235 | "value": "Italy", 236 | "entity": "location" 237 | } 238 | ] 239 | } 240 | ] 241 | } 242 | } -------------------------------------------------------------------------------- /Video files/data/stories.md: -------------------------------------------------------------------------------- 1 | ## Generated Story 3320800183399695936 2 | * greet 3 | - utter_greet 4 | * inform 5 | - utter_ask_location 6 | * inform{"location": "italy"} 7 | - slot{"location": "italy"} 8 | - action_weather 9 | - slot{"location": "italy"} 10 | * goodbye 11 | - utter_goodbye 12 | - export 13 | ## Generated Story -3351152636827275381 14 | * greet 15 | - utter_greet 16 | * inform[location=London] 17 | - slot{"location": "London"} 18 | - action_weather 19 | * goodbye 20 | - utter_goodbye 21 | - export 22 | ## Generated Story 8921121480760034253 23 | * greet 24 | - utter_greet 25 | * inform 26 | - utter_ask_location 27 | * inform[location=London] 28 | - slot{"location": "London"} 29 | - action_weather 30 | * goodbye 31 | - utter_goodbye 32 | - export 33 | ## Generated Story -5208991511085841103 34 | - slot{"location": "London"} 35 | - action_weather 36 | * goodbye 37 | - utter_goodbye 38 | - export 39 | ## Generated Story -5208991511085841103 40 | - slot{"location": "London"} 41 | - action_weather 42 | * goodbye 43 | - utter_goodbye 44 | - export 45 | ## story_001 46 | * greet 47 | - utter_greet 48 | * inform 49 | - utter_ask_location 50 | * inform[location=London] 51 | - slot{"location": "London"} 52 | - action_weather 53 | * goodbye 54 | - utter_goodbye 55 | ## story_002 56 | * greet 57 | - utter_greet 58 | * inform[location=Paris] 59 | - slot{"location": "Paris"} 60 | - action_weather 61 | * goodbye 62 | - utter_goodbye 63 | ## story_003 64 | * greet 65 | - utter_greet 66 | * inform 67 | - utter_ask_location 68 | * inform[location=Vilnius] 69 | - slot{"location": "Vilnius"} 70 | - action_weather 71 | * goodbye 72 | - utter_goodbye 73 | ## story_004 74 | * greet 75 | - utter_greet 76 | * inform[location=Italy] 77 | - slot{"location": "Italy"} 78 | - action_weather 79 | * goodbye 80 | - utter_goodbye 81 | ## story_005 82 | * greet 83 | - utter_greet 84 | * inform 85 | - utter_ask_location 86 | * inform[location=Lithuania] 87 | - slot{"location": "Lithuania"} 88 | - action_weather 89 | * goodbye 90 | - utter_goodbye 91 | -------------------------------------------------------------------------------- /Video files/requirements.txt: -------------------------------------------------------------------------------- 1 | ###rasa_nlu 2 | gevent==1.2.1 3 | Klein==17.2.0 4 | boto3==1.4.4 5 | typing==3.5.3.0 6 | future==0.16.0 7 | six==1.10.0 8 | jsonschema==2.6.0 9 | matplotlib==1.5.3 10 | requests==2.14.2 11 | tqdm==4.11.2 12 | numpy==1.13.1 13 | simplejson==3.11.1 14 | 15 | ### Sklearn 16 | spacy==1.8.2 17 | scikit-learn==0.19.1 18 | sklearn-crfsuite==0.3.5 19 | 20 | ###rasa_core 21 | apscheduler==3.3.1 22 | fakeredis==0.8.2 23 | graphviz==0.7.1 24 | h5py==2.7.0 25 | jsonpickle==0.9.4 26 | keras==2.0.8 27 | pandoc==1.0.0b2 28 | redis==2.10.5 29 | tensorflow 30 | networkx==1.11 31 | fbmessenger==4.3.1 32 | ConfigArgParse==0.12.0 33 | pykwalify==1.6.0 34 | coloredlogs==7.3 35 | ruamel.yaml==0.15.34 36 | flask==0.12 37 | rasa_nlu==0.11.4 38 | 39 | ###additional 40 | pypandoc 41 | slackclient 42 | rasa_core==0.8.2 43 | git+https://github.com/apixu/apixu-python.git -------------------------------------------------------------------------------- /Video files/train_init.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import unicode_literals 4 | 5 | import logging 6 | 7 | from rasa_core.agent import Agent 8 | from rasa_core.policies.keras_policy import KerasPolicy 9 | from rasa_core.policies.memoization import MemoizationPolicy 10 | 11 | if __name__ == '__main__': 12 | logging.basicConfig(level='INFO') 13 | 14 | training_data_file = './data/stories.md' 15 | model_path = './models/dialogue' 16 | 17 | agent = Agent('weather_domain.yml', policies = [MemoizationPolicy(), KerasPolicy()]) 18 | 19 | agent.train( 20 | training_data_file, 21 | augmentation_factor = 50, 22 | max_history = 2, 23 | epochs = 500, 24 | batch_size = 10, 25 | validation_split = 0.2) 26 | 27 | agent.persist(model_path) 28 | -------------------------------------------------------------------------------- /Video files/train_online.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | from __future__ import unicode_literals 5 | 6 | import logging 7 | 8 | from rasa_core.agent import Agent 9 | from rasa_core.channels.console import ConsoleInputChannel 10 | from rasa_core.interpreter import RegexInterpreter 11 | from rasa_core.policies.keras_policy import KerasPolicy 12 | from rasa_core.policies.memoization import MemoizationPolicy 13 | from rasa_core.interpreter import RasaNLUInterpreter 14 | 15 | logger = logging.getLogger(__name__) 16 | 17 | 18 | def run_weather_online(input_channel, interpreter, 19 | domain_file="weather_domain.yml", 20 | training_data_file='data/stories.md'): 21 | agent = Agent(domain_file, 22 | policies=[MemoizationPolicy(), KerasPolicy()], 23 | interpreter=interpreter) 24 | 25 | agent.train_online(training_data_file, 26 | input_channel=input_channel, 27 | max_history=2, 28 | batch_size=50, 29 | epochs=200, 30 | max_training_samples=300) 31 | 32 | return agent 33 | 34 | 35 | if __name__ == '__main__': 36 | logging.basicConfig(level="INFO") 37 | nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/weathernlu') 38 | run_weather_online(ConsoleInputChannel(), nlu_interpreter) 39 | --------------------------------------------------------------------------------