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.
- 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
- A user sends a message to the WhatsApp number
- WhatsApp Cloud API forwards it to a webhook
- FastAPI server processes the message
- The message is sent to OpenAI with a custom persona prompt
- AI generates a response
- Response is sent back to the user via WhatsApp API
- 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
.
├── 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
git clone https://github.com/your-username/ajay-whatsapp-bot.git
cd ajay-whatsapp-botpip install -r requirements.txtWHATSAPP_TOKEN=your_meta_permanent_token
PHONE_NUMBER_ID=your_phone_number_id
VERIFY_TOKEN=your_custom_verify_token
OPENAI_API_KEY=your_openai_api_keyuvicorn main:app --reload --port 8000ngrok http 8000Use the generated URL for webhook configuration:
https://<ngrok-id>.ngrok-free.app/webhook
- Go to Meta Developer Dashboard
- Add webhook URL
- Set verify token
- Subscribe to:
messages
- Push code to GitHub
- Go to Railway → New Project → Deploy from GitHub
- Add environment variables in Railway dashboard
- Replace webhook URL with Railway URL:
https://your-app.up.railway.app/webhook
| 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 |
- 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
- WhatsApp requires a 24-hour conversation window
- AI replies depend on OpenAI quota
- SQLite (if used) is not persistent on Railway without volumes
- Fun chatbot projects
- Experimenting with AI personalities
- Learning WhatsApp Cloud API integration
- Event-based interactive experiences
- Persistent memory (PostgreSQL)
- Admin dashboard to monitor chats
- Voice note responses
- Scheduled messages
- Dynamic persona control