Skip to content

newb-dev-1008/AjayBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ajay – WhatsApp AI Chatbot with Personality

Ajay is a WhatsApp-based AI chatbot that interacts with users in real-time using the WhatsApp Cloud API.
Built as a fun and creative project, Ajay embodies a flamboyant, Bollywood-style persona.

The bot responds to messages with charm, wit and a dramatic personality — all powered by AI.


Features

  • Real-time WhatsApp chat
  • Custom AI persona (Ajay)
    • Hindi + English mix
    • Confident, flirtatious, dramatic tone
    • Playful jealousy and humor
  • Instant replies via webhook
  • AI-powered responses using OpenAI
  • Deployed on Railway (24/7 availability)
  • Secure environment-based configuration

How It Works

  1. A user sends a message to the WhatsApp number
  2. WhatsApp Cloud API forwards it to a webhook
  3. FastAPI server processes the message
  4. The message is sent to OpenAI with a custom persona prompt
  5. AI generates a response
  6. Response is sent back to the user via WhatsApp API

Tech Stack

  • Backend: FastAPI (Python)
  • Messaging: WhatsApp Cloud API (Meta)
  • AI: OpenAI API (gpt-4.1-mini)
  • Hosting: Railway
  • Tunneling (dev): ngrok
  • Database (optional): SQLite / PostgreSQL
  • Environment Management: .env

Project Structure

.
├── main.py          # FastAPI app + webhook handling
├── brain.py         # AI response generation logic
├── persona.py       # Ajay's personality definition
├── db.py            # (optional) chat logging
├── requirements.txt
├── Procfile
└── README.md

Setup Instructions

1. Clone the Repository

git clone https://github.com/your-username/ajay-whatsapp-bot.git
cd ajay-whatsapp-bot

2. Install Dependencies

pip install -r requirements.txt

3. Create .env file

WHATSAPP_TOKEN=your_meta_permanent_token
PHONE_NUMBER_ID=your_phone_number_id
VERIFY_TOKEN=your_custom_verify_token
OPENAI_API_KEY=your_openai_api_key

4. Run Locally

uvicorn main:app --reload --port 8000

5. Expose via ngrok (for development)

ngrok http 8000

Use the generated URL for webhook configuration:

https://<ngrok-id>.ngrok-free.app/webhook

6. Configure Meta Webhook

  • Go to Meta Developer Dashboard
  • Add webhook URL
  • Set verify token
  • Subscribe to:
    • messages

7. Deploy on Railway (Production)

  1. Push code to GitHub
  2. Go to Railway → New Project → Deploy from GitHub
  3. Add environment variables in Railway dashboard
  4. Replace webhook URL with Railway URL:
https://your-app.up.railway.app/webhook

Environment Variables

Variable Description
WHATSAPP_TOKEN Permanent access token from Meta
PHONE_NUMBER_ID WhatsApp Business phone number ID
VERIFY_TOKEN Custom token for webhook verification
OPENAI_API_KEY OpenAI API key

Cost Notes

  • OpenAI usage is extremely low (₹5–₹50 per week for moderate usage)
  • Railway free credits (~$5) are sufficient for short-term usage
  • Suitable for small-scale or personal projects

Limitations

  • WhatsApp requires a 24-hour conversation window
  • AI replies depend on OpenAI quota
  • SQLite (if used) is not persistent on Railway without volumes

Use Cases

  • Fun chatbot projects
  • Experimenting with AI personalities
  • Learning WhatsApp Cloud API integration
  • Event-based interactive experiences

Future Improvements

  • Persistent memory (PostgreSQL)
  • Admin dashboard to monitor chats
  • Voice note responses
  • Scheduled messages
  • Dynamic persona control

About

A flirty WhatsApp bot that I created to play around with my girlfriend.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors