A rule-based Myanmar language chatbot with emotion detection, served as a Flask REST API and tested via a minimal HTML UI.
myanmar-chatbot/
├── app.py # Flask API
├── index.html # Browser UI for testing
├── requirements.txt # Python dependencies
├── .gitignore
└── README.md
- Python 3.8 or higher
- pip
- A modern browser (Chrome, Firefox, Safari)
git clone https://github.com/sai-zack-dev/myanmar-chatbot.git
cd myanmar-chatbotOr if you downloaded a ZIP, extract it and open a terminal inside the folder.
# macOS / Linux
python3 -m venv venv
# Windows
python -m venv venv# macOS / Linux
source venv/bin/activate
# Windows (Command Prompt)
venv\Scripts\activate
# Windows (PowerShell)
venv\Scripts\Activate.ps1You will see (venv) appear at the start of your terminal prompt.
pip install -r requirements.txtrequirements.txt
flask>=3.0.0
flask-cors>=4.0.0
python app.pyYou should see:
* Running on http://0.0.0.0:5005
* Debug mode: on
The API is now live at http://localhost:5005.
Open index.html directly in your browser — double-click the file or drag it into a browser window. No server needed for the HTML file itself.
Make sure the BASE URL field at the top shows http://localhost:5005, then click ping ↻ to confirm the connection. The status indicator in the top-right corner will turn green when connected.
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Health check, returns a random greeting |
GET |
/greet |
Returns a random opening greeting |
POST |
/chat |
Send a message, receive a reply + emotion analysis |
POST |
/emotion |
Analyse emotion only, no bot reply |
Request
{ "message": "မင်္ဂလာပါ" }Response
{
"user_message": "မင်္ဂလာပါ",
"bot_reply": "ဟုတ်ကဲ့၊ ဆက်ပြောပါဦး။ နားထောင်နေပါတယ်ခင်ဗျာ။",
"is_quit": false,
"emotion": {
"label": "Joy",
"confidence": 66.7,
"scores": {
"Sadness": 8.3,
"Joy": 66.7,
"Love": 8.3,
"Anger": 8.3,
"Fear": 8.3,
"Surprise": 0.0
}
}
}Request
{ "message": "ဝမ်းနည်းနေတယ်" }Response
{
"label": "Sadness",
"confidence": 57.1,
"scores": {
"Sadness": 57.1,
"Joy": 7.1,
"Love": 7.1,
"Anger": 7.1,
"Fear": 14.3,
"Surprise": 7.1
}
}# Health check
curl http://localhost:5005/
# Greeting
curl http://localhost:5005/greet
# Chat
curl -X POST http://localhost:5005/chat \
-H "Content-Type: application/json" \
-d '{"message": "မင်္ဂလာပါ"}'
# Emotion analysis
curl -X POST http://localhost:5005/emotion \
-H "Content-Type: application/json" \
-d '{"message": "ဝမ်းနည်းနေတယ်"}'If the browser blocks requests from index.html to the API (this can happen on some setups), flask-cors is already included in requirements.txt. Make sure these two lines are present in app.py:
from flask_cors import CORS
CORS(app) # place this right after: app = Flask(__name__)Sending any of the following will trigger a farewell response and set is_quit: true in the API response:
ဘိုင် သွားပြီ တာ့တာ သွားမယ် နှုတ်ဆက်
bye quit exit goodbye see you cya cu
When you are done working, run:
deactivate| Task | Command |
|---|---|
| Activate venv (Mac/Linux) | source venv/bin/activate |
| Activate venv (Windows) | venv\Scripts\activate |
| Install dependencies | pip install -r requirements.txt |
| Start server | python app.py |
| Stop server | Ctrl + C |
| Deactivate venv | deactivate |
| Save new packages | pip freeze > requirements.txt |