Skip to content

About

Bangla AI customer support chatbot (Flask + Gemini) with text, voice and WhatsApp/Messenger integration

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

TreBa — Bangla AI Customer Support Chatbot (Flask + Gemini)

A Bangla-language customer support chatbot built for a fictional online clothing shop, ট্রেন্ডি বাজার (Trendy Bazaar). Built with Flask and Google's Gemini API, it supports text chat, voice chat (speech-to-text and text-to-speech), product image replies, and can be connected to WhatsApp and Messenger as well.

This project was built for a YouTube tutorial. If you're following along from the video, this README explains what the project does and how to run it yourself.

Features

  • Text chat — customers can chat in Bangla and get context-aware replies (the bot remembers the last few messages in the conversation).
  • Voice chat — customers can send a voice message; it gets transcribed to text, replied to, and the reply is converted back to speech (audio) using Gemini's text-to-speech.
  • Product images — if a customer asks about a product category (saree, formal suit, panjabi, formal shoes, women's dress), the bot automatically sends relevant images.
  • Fixed shop info (no hallucination) — prices, delivery charges, delivery time, return policy, and the shop's website are hardcoded in the system prompt so the bot never makes up wrong information.
  • WhatsApp & Messenger integration — webhook endpoints are included so the same bot can reply to customers directly on WhatsApp and Facebook Messenger.
  • Rate limiting — built-in request limits to prevent API abuse/cost overruns.
  • Session-based memory — each browser/user session keeps its own separate conversation history (in-memory; resets when the server restarts).

Tech Stack

  • Backend: Python, Flask
  • AI Model: Google Gemini (gemini-2.5-flash for chat/transcription, gemini-2.5-flash-preview-tts for text-to-speech)
  • Other libraries: flask-cors, flask-limiter, python-dotenv, requests

Project Structure

bangla-chatbot/
├── app_gemini.py           # Main Flask application
├── requirements_gemini.txt # Python dependencies
├── templates/
│   └── chat.html           # Web chat interface
├── static/
│   └── images/
│       ├── sharee/
│       ├── formal/
│       ├── panjabi/
│       ├── shoes_formal/
│       └── w_dress/
├── .env                     # Your API keys (NOT committed to git)
└── .gitignore

Setup & Installation

1. Clone the repository

git clone https://github.com/billawithaiml/bangla-chatbot.git
cd bangla-chatbot

2. Create a virtual environment

python3 -m venv venv
source venv/bin/activate   # On Windows: venv\Scripts\activate

3. Install dependencies

pip install -r requirements_gemini.txt

4. Set up environment variables

Create a .env file in the project root and add:

GEMINI_API_KEY=your_gemini_api_key_here
FLASK_SECRET_KEY=some_random_secret_string
FLASK_DEBUG=False

You can get a free Gemini API key from Google AI Studio.

If you also want to connect WhatsApp/Messenger, add these too:

WHATSAPP_TOKEN=your_whatsapp_access_token
WHATSAPP_PHONE_NUMBER_ID=your_whatsapp_phone_number_id
WHATSAPP_VERIFY_TOKEN=your_own_verify_token

MESSENGER_PAGE_TOKEN=your_messenger_page_access_token
MESSENGER_VERIFY_TOKEN=your_own_messenger_verify_token

5. Run the app

python3 app_gemini.py

API Endpoints

Endpoint Method Description
/ GET Loads the web chat interface
/chat POST Send a text message, get a reply (JSON)
/voice-chat POST Send an audio file, get transcript + reply + audio reply
/reset POST Clear the current session's conversation history
/webhook GET/POST WhatsApp webhook (verification + incoming messages)
/messenger-webhook GET/POST Messenger webhook (verification + incoming messages)

Notes

  • Conversation history is stored in memory — it resets whenever the server restarts. For a production deployment, use Redis or a database instead.
  • Never commit your .env file — it contains your private API keys. This repo's .gitignore already excludes it.
  • To connect WhatsApp/Messenger locally, you'll need a tool like ngrok to expose your local server to the internet, since Meta needs a public URL to send webhook requests to.

Disclaimer

This is a demo project built for educational purposes. "Trendy Bazaar" is a fictional shop, and all product/pricing info is sample data for demonstration only.

Credits

Built by billawithaiml for a YouTube tutorial on building an AI-powered customer support chatbot with Flask and Gemini, on the channel @llmlabofficial.

About

Bangla AI customer support chatbot (Flask + Gemini) with text, voice and WhatsApp/Messenger integration

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages