This project integrates the eCitizen Facebook page with ChatGPT to provide automated customer support
The following tools should be preinstalled in the target host
Clone the repository
Launch terminal and navigate to the root directory of the cloned folder
Create and activate a virtual environment
Navigate to backend
folder
$ cd backend
Install project dependencies
$ pip install -r requirements.txt
Create the database your-development-db
in the host machine
.env
file in the backend
directoryCONFIG_MODE=development
TEST_DATABASE_URL=mysql+pymysql://user:password@localhost:3306/your-test-db
DEVELOPMENT_DATABASE_URL=mysql+pymysql://user:password@localhost:3306/your-development-db
SQLALCHEMY_TRACK_MODIFICATIONS=False
$ flask --app run --debug run
pytest.ini
file in the backend
directory[pytest]
addopts = -p no:warnings
env=
CONFIG_MODE=testing
TEST_DATABASE_URL=mysql+pymysql://user:password@localhost:3306/your-test-db
DEVELOPMENT_DATABASE_URL=''
SQLALCHEMY_TRACK_MODIFICATIONS=False
SECRET_KEY=my-sweet-secret-do-not-tell
JWT_SECRET_KEY=my-sweet-jwt-secret-do-not-tell
JWT_BLACKLIST_ENABLED=True
JWT_BLACKLIST_TOKEN_CHECKS="['access', 'refresh']"
HUGGING_FACE_API_KEY= your-huggingface-issued-api-key
HUGGING_FACE_API_URL=your-huggingface_model_url
RESOURCE_PATH=your_path_to/ecitizen-fb-chatbot/backend/app/api/ai/faqs.txt
LARGE_LANGUAGE_MODEL=your-large-language-model
$ coverage run -m pytest -v
$ coverage report
Method | Endpoint | Functionality |
---|---|---|
POST |
/api/v1/chatbot/auth/register |
User Registration: Creates a new user |
POST |
/api/v1/chatbot/auth/login |
User Authentication: Authenticates a user |
GET |
/api/v1/chatbot |
Index Page: The landing page route |
POST |
/api/v1/chatbot/auth/logout |
User Logout: Revokes user access |
POST |
/api/v1/chatbot/auth/refresh |
Refresh: Regenerates user access tokens |
Method | Endpoint | Functionality |
---|---|---|
POST |
/api/v1/chatbot/ai |
User Interaction: Interacts with the AI model |
{
"email": "test@ecitizen.go.ke",
"password": "testpassword"
}
{
"status_code": 201,
"message": "User registration successful"
}
{
"email": "test@ecitizen.go.ke",
"password": "testpassword"
}
{
"status_code": 200,
"message": "User authentication successful",
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcyMjAxMDg0NCwianRpIjoiMTQ3PjQ5YTAtNGY1ZS00MzhiLWE2NjgtNTHzNTdiM2JmNGQ2IiwidHlwZSI6ImFjY2VzcyIsInN1YiI6ImFkbWluQGVjaXRpemVuLmNvbSIsIk5iZiI6MTcyMjAxMDg0NCwiY3NyZiI6IjE5ZTNkMDQ3LTY5ZWUtNGJjZC04ZDU0LTYzNjlmMjEzYTAzMiIsImV4cCI6MTcyMjAxMTc0NH0.DxcdXquE7iimUaGs_NmbIomypQ3nxaqCL5pQTBhbeRb",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCIoZmFsc2UsImlhdCI6MTcytjIxNjYwMywianRpJjoiYWRlYzkyNzMtZjUzZi00OWMxLWFmMmItMDkwZDcyOGU0ODFlIiwidHlwZSI6InJlZnJlc2giLCJzdWIiOiJhZG1pbkBlY2l0aXplbi5jb20iLCJuYmYiOjE3MjIyMTY2MDMsImNzcmYiOiI3MDcyMjMyYS03MjA4LTRiOWQtYjllYi1jODZiYTEzNDU4YWEiLCJleNAiOjE3MjQ4MDg2MDN9.Q79STusDl1E8bnrGWEcAHzsdrFHLVRdJw3rTVTT1hpx"
}
{
"status_code": 200,
"message": "logout successful"
}
{
"msg": "Token has been revoked"
}
{
"msg": "Token has expired"
}
{
"access_token": "eyJhbGciOiJIUrI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcwMjIxOTQxNCwianRpIjoiM2Q5MDY3N2QtMmM2Yi00ZDY1LWFkODctMzM3MjBkODJkNDYyIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6ImBkbWluQGVjaXRpemVuLmNvbSIsIm5iZiI6MTcyMjIx8TQxNCwiY3NyZiI6IjZiMPk1NWE0LWM2ZjYtNDFjNi04ZWQwLTA2MGQ3ZDliMjQxYSIsImV4cCI6MTcyMjIyMDMxNH0.w49lTF6RmkZSlybJKWBcNPhlvtEdkN3atPODu05F5AX",
"status_code": 200
}
{
"question": "Can a soldier register a private security company?"
}
{
"answer": "No. Current serving members of the disciplined forces cannot register a private security company. However, where a person has previously served in any of the disciplined forces, he or she must submit to the Authority a certificate of discharge and a certificate of clearance from such service.",
"message": "OK"
}