Skip to content
/ alex Public

Alex is a prototype patient chatbot, allowing medical students - and other would-be doctors - to practice their diagnostic skills.

Notifications You must be signed in to change notification settings

tet-ai/alex

Repository files navigation

Alex: Prototype Chatbot for Tet.ai

Introduction

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.

Setup

The All-in-One

  1. Run this command in terminal

    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.

In Baby Steps

  1. Install Rasa

    pip install rasa_core
    pip install rasa_nlu[spacy]

    For more info or alternative installation methods, go here.

  2. Clone the repository

    cd ~/
    git clone https://github.com/tet-ai/alex
  3. Move to the repository

    cd ~/alex/
  4. Train the dialogue model

    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.

  5. (Optional) Talk to bot with structured data

    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.

  6. Train NLU

    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

  7. Talk to Bot

    Now the bot is all trained up. To speak to it, run

    python -m rasa_core.run -d models/dialogue -u models/current/nlu

Retraining the chatbot

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

Running for facebook

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

To run locally for facebook

  1. 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
  2. Create webhook

    node index.js
  3. Point facebook in the right direction

    1. Go to application page on 'Facebook for developers'. Mine is here.
    2. Webhooks
    3. Edit subscription
    4. Callback URL: 'random_name.ngrok.io/webhooks/facebook/webhook'
  4. Talk on messenger!

About

Alex is a prototype patient chatbot, allowing medical students - and other would-be doctors - to practice their diagnostic skills.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published