Skip to content

sai-zack-dev/myanmar-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elyza — မြန်မာ Chatbot

A rule-based Myanmar language chatbot with emotion detection, served as a Flask REST API and tested via a minimal HTML UI.


Project Structure

myanmar-chatbot/
├── app.py              # Flask API
├── index.html          # Browser UI for testing
├── requirements.txt    # Python dependencies
├── .gitignore
└── README.md

Requirements

  • Python 3.8 or higher
  • pip
  • A modern browser (Chrome, Firefox, Safari)

Local Setup

1. Clone or download the project

git clone https://github.com/sai-zack-dev/myanmar-chatbot.git
cd myanmar-chatbot

Or if you downloaded a ZIP, extract it and open a terminal inside the folder.


2. Create a virtual environment

# macOS / Linux
python3 -m venv venv

# Windows
python -m venv venv

3. Activate the virtual environment

# macOS / Linux
source venv/bin/activate

# Windows (Command Prompt)
venv\Scripts\activate

# Windows (PowerShell)
venv\Scripts\Activate.ps1

You will see (venv) appear at the start of your terminal prompt.


4. Install dependencies

pip install -r requirements.txt

requirements.txt

flask>=3.0.0
flask-cors>=4.0.0

5. Start the Flask server

python app.py

You should see:

 * Running on http://0.0.0.0:5005
 * Debug mode: on

The API is now live at http://localhost:5005.


6. Open the UI

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.


API Endpoints

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

POST /chat

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
    }
  }
}

POST /emotion

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
  }
}

Testing with curl

# 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": "ဝမ်းနည်းနေတယ်"}'

CORS Note

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__)

Quit Keywords

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

Deactivating the Virtual Environment

When you are done working, run:

deactivate

Quick Reference

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

About

A rule-based Myanmar language chatbot with emotion detection, served as a Flask REST API and tested via a minimal HTML UI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors