Alex: Prototype Chatbot for Tet.ai
Alex is a prototype patient chatbot, allowing medical students - and other would-be doctors - to practice patient-doctor interactions and their diagnostic skills.
There are two main parts: the dialogue model and the NLU model. The NLU model can take natural language and convert it into structured data that a computer can understand. The dialogue model takes this structured data and chooses a suitable reply to it.
It can be run either locally, using the terminal, or running on Facebook Messenger using a websocket hosted on Heroku.
-
pip install rasa_core pip install rasa_nlu[spacy] cd ~/ git clone https://github.com/tet-ai/alex cd ~/alex/ python -m rasa_core.train -d domain.yml -s stories.md -o models/dialogue python -m rasa_nlu.train -c nlu_config.yml --data nlu.md -o models --fixed_model_name nlu --project current --verbose python -m rasa_core.run -d models/dialogue -u models/current/nlu
and you should be able to talk to the chatbot.
-
pip install rasa_core pip install rasa_nlu[spacy]
For more info or alternative installation methods, go here.
-
cd ~/ git clone https://github.com/tet-ai/alex
-
cd ~/alex/
-
Run
python -m rasa_core.train -d domain.yml -s stories.md -o models/dialogue
This will train the dialogue model and store it into
models/dialogue
. -
We have only trained the dialogue model, not the NLU. But we can send structured data to the bot now.
Run
python -m rasa_core.run -d models/dialogue
Then send it a message such as
/greet
. -
Run
python -m rasa_nlu.train -c nlu_config.yml --data nlu.md -o models --fixed_model_name nlu --project current --verbose
This creates the NLU model in
models/current/nlu
-
Now the bot is all trained up. To speak to it, run
python -m rasa_core.run -d models/dialogue -u models/current/nlu
If you make changes to the chatbot, you will need to retrain it.
python3 -m rasa_core.train -d domain.yml -s stories.md -o models/dialogue
python3 -m rasa_nlu.train -c nlu_config.yml --data nlu.md -o models --fixed_model_name nlu --project current --verbose
python3 -m rasa_core.run -d models/dialogue -u models/current/nlu
If setting up with facebook, follow these instructions.
python -m rasa_core.run -d models/dialogue -u models/current/nlu \
--port 5002 --connector facebook --credentials credentials.yml
python -m rasa_core.run -d models/dialogue -u models/current/nlu \
--port 5002 --credentials credentials.yml
-
Expose local link
ngrok http 5002
see ngrok.
This makes random_name.ngrok.io point to localhost:5002
-
-
Run virtual environment
source .env/bin/activate
-
Run Rasa
python -m rasa_core.run -d models/dialogue -u models/current/nlu \ --port 5002 --credentials credentials.yml
-
-
Create webhook
node index.js
-
Point facebook in the right direction
- Go to application page on 'Facebook for developers'. Mine is here.
- Webhooks
- Edit subscription
- Callback URL: 'random_name.ngrok.io/webhooks/facebook/webhook'
-
Talk on messenger!