THESIS_CAIRONE_FIORENTINO
Politecnico of Turin Thesis: "Implementation and Evaluation of an Educational Chatbot based on NLP Techniques"
GENERATE TOKEN SLACK
NB: REMEMBER TO REGENERATE SLACK TOKENS AND CHANNEL ID IF ARE DISABLE (SEE THESIS PDF)
- Go on your Slack App ( App Slack )-> select your app or create new -> Settings -> Install App -> (regenerate two tokens) -> Copy Tokens in
actions/Constants.pyandcredentials.ymlfiles.
RASA - LOCAL MODE
Components Installation
- Writing in Anaconda console this command:
conda create --name venv python==3.8.0conda activate venvconda install ujson tensorflowpip install rasapip install rasa[spacy]for SPACY configurationpip install rasa[trasformers]for BERT configurationrasa initif you want to create new project
MORE INFO: See this video: link
Code Execution
-
First, in
TESI_POLI_POBOTdirectory do the training in anaconda console withvenvactivate:rasa train --config configs/{file_cofiguration}.yml --fixed-model-name {model_name}
-
After run server rasa:
-
rasa run --connector slack --model {model_name} --debug -
In an other prompr run server rasa ACTIONS:
-
rasa run actions --action actions --debug -
If you want,to test locally the intent classification, run in Anaconda console:
rasa train --config configs/{file_cofiguration}.yml --fixed-model-name {model_name}rasa shell --model {model_name}
Rasa Bot - Slack Connection
- after training and running the server in Anaconda console (see
## Execution of codeparagraph):- in
BOT_RASA/ngrokdirectory run this command (in console prompt):ngrok http 5005to create a tunnel forlocalhost:5005address:- select the forwarding address choose to ngrok ({address} = http://<number_code>.ngrok.io)
- in Slack App link save the address (selecting in
Featuresmenu):- Interactivity & Shortcut > Request URL: ({address}/webhooks/slack/webhook) > Save Changes
- OAuth & Permissions > Redirect URLs > Add : ({address}/webhooks/slack/webhook) > Save URLs
- Event Subscriptions > Enable Events (Request URL) > Change: ({address}/webhooks/slack/webhook) > Save Changes
- expired time of ngrok address: 2 hours. (when we will use a public address, ngrok will become USELESS)
- in
- tokens bot save as environment variable in PC server (for security issue)
- Slack bot: link
To Connect also the ACTION Server Rasa:
ngrok http 5055to create a tunnel forlocalhost:5055- In
endpoints.ymlmodifyurlofaction_endpoint:{address}/webhook
RASA X
Components Installation
- Writing in Anaconda console this command:
conda create --name venv python==3.9.0conda activate venvconda install ujson tensorflowpip install rasa[spacy]for SPACY configurationpip install rasa[trasformers]for BERT configurationpip install --upgrade pip==20.0.1pip3 install rasa-x --extra-index-url https://pypi.rasa.com/simplepip install --upgrade pip
Code Execution
-
First, in
TESI_POLI_POBOTdirectory do the training in anaconda console withvenvactivate:set PYTHONUTF8=1rasa x --connector slack --config configs/{file_cofiguration}.yml
-
In an other prompt run server rasa ACTIONS:
-
rasa run actions --action actions --debug
Rasa Bot - Slack Connection
- after training and running the server in Anaconda console (see
## Execution of codeparagraph):- in
BOT_RASA/ngrokdirectory run this command (in console prompt):ngrok http 5005to create a tunnel forlocalhost:5005address:- select the forwarding address choose to ngrok ({address} = http://<number_code>.ngrok.io)
- in Slack App link save the address (selecting in
Featuresmenu):- Interactivity & Shortcut > Request URL: ({address}/webhooks/slack/webhook) > Save Changes
- OAuth & Permissions > Redirect URLs > Add : ({address}/webhooks/slack/webhook) > Save URLs
- Event Subscriptions > Enable Events (Request URL) > Change: ({address}/webhooks/slack/webhook) > Save Changes
- expired time of ngrok address: 2 hours. (when we will use a public address, ngrok will become USELESS)
- in
- tokens bot save as environment variable in PC server (for security issue)
- Slack bot: link
To Connect also the ACTION Server Rasa:
ngrok http 5055to create a tunnel forlocalhost:5055- In
endpoints.ymlmodifyurlofaction_endpoint:{address}/webhook
To Connect also the ACTION Server Rasa X:
ngrok http 5055to create a tunnel forlocalhost:5002- In
credentials.ymlmodifyurlofrasa:{address}/api
RASA - DOCKER MODE
Code Execution
If is the first time, run this commands:
docker volume create db-volume
docker-compose up -d
docker-compose down
docker-compose up -d
python rasa_x_commands.py create --update admin me <password_rasa_server> (i.e. password)
docker-compose down
docker-compose up -d
Otherwise, in TESI_POLI_POBOT directory in console run only this command:
docker-compose up -d
Rasa Bot - Slack Connection
After all container is in running mode, in web browser go in `http:://localhost:80' and insert the password choose the first time. (i.e. password)
If rasa x server not contain NLU data (possible first time) you can upload the file directly using interface of rasa x server in Training -> NLU data / Stories / Rules / Configuration (copy and paste the content of config choose in TESI_POLI_POBOT directory)
If you want to connect to slack:
- after training and running the server in Anaconda console (see
## Execution of codeparagraph):- in
BOT_RASA/ngrokdirectory run this command (in console prompt):ngrok http 80to create a tunnel forlocalhost:80address:- select the forwarding address choose to ngrok ({address} = http://<number_code>.ngrok.io)
- in Slack App link save the address (selecting in
Featuresmenu):- Interactivity & Shortcut > Request URL: ({address}/core/webhooks/slack/webhook) > Save Changes
- OAuth & Permissions > Redirect URLs > Add : ({address}/core/webhooks/slack/webhook) > Save URLs
- Event Subscriptions > Enable Events (Request URL) > Change: ({address}/core/webhooks/slack/webhook) > Save Changes
- expired time of ngrok address: 2 hours. (when we will use a public address, ngrok will become USELESS)
- in
- tokens bot save as environment variable in PC server (for security issue)
- Slack bot: link
RASA - TEST DATA
Test stories in tests directory
- if you want tests stories with cross-validation:
rasa train --config configs/{file_cofiguration}.yml --fixed-model-name {model_name}(if model does not exist)rasa test --config configs/{file_cofiguration}.yml --cross-validation --runs {time_runs} --folds {num_folds} --out {dir_out} --model {model_name}
Test NLU data
-
if you want test only the NLU data splitted:
rasa train nlu --nlu train_test_split/training_data.yml --config configs/{file_cofiguration}.yml --fixed-model-name ./models_NLU/{model_name}(if model does not exist)rasa test nlu --nlu train_test_split/test_data.yml --out {dir_out} --model ./models_NLU/{model_name}
-
if you want test only the NLU data totally:
rasa train nlu --config configs/{file_cofiguration}.yml --fixed-model-name {model_name}(if model does not exist)rasa test nlu --nlu train_test_split/test_data.yml --out {dir_out} --model {model_name}
Test CORE data
- if you want test only the CORE data:
rasa train --config configs/{file_cofiguration}.yml --fixed-model-name {model_name}(if model does not exist)rasa test core --stories tests/test_stories.yml --out {dir_out} --model {model_name}