B

BotFaqUpdater

a1eadd87 First Commit · by root

Syncing the student FAQ and the KU chatbot

Info

KuChatBot - https://gitlab.kingston.ac.uk/KU67698/BotProtoType

StudentFAQ - https://studenthub.kingston.ac.uk/faqs/GuestFaq.aspx?CCTC=HUB&UTYP=FAQ

Description

When run, this python script will webscrape all question and answer pairs off of the FAQ and upload them to the QnA maker model. In this case Academic. The file is self contained and will provide a TSV and JSON output of the question and answer set. Furthermore the script will also create a back up of the old QnA maker database.

The file restoreFromBackup.py takes one command line argument, the back up file in the form QnAMakerBackup-dateTimeOfBackup.json. When run it will take this backup file and put the questions back into the KB and remove any new ones.

You must have a pre-existing dispatch files generated from running the dispatch create command. These files can be optained from the git project for the main bot file under the DISPATCH MODEL/ folder.

Dependencies

Python 3

Pip 3

Pip3 Modules

BeautifulSoup 4

Azure Services

A QnA maker model running through azure cognative services and access to that API

Examples

To use, you must have the bs4 modules installed via pip, this can be done in a python virtual environment if wished.

pip3 install bs4

Update from the FAQ

To perform the update, clone this repository and navigate into it.

git clone git@gitlab.kingston.ac.uk:KU67698/BotFaqUpdater.git

cd BotFaqUpdater

Move the contents of this folder into the same location as your dispatch files, in the case of the ku dispatch bot it would be in the DISPATCH MODEL/ folder within the orignal bot source code.

project.dispatch
project.json
Data

We can then run the script.

Windows

py main.py

Mac/Linux

python3 main.py

venv

python main.py

This will create the backup file in the current directory

Restore from a backup file

To restore from backup ensure you are once again in the directory of the program and file.

Windows

py restoreFromBackup.py BackupFileName.json

Mac/Linux

python3 restoreFromBackup.py BackupFileName.json 

venv

python restoreFromBackup.py BackupFileName.json