Skip to content

Umer-206/whatsapp-ai-executive-assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– WhatsApp AI Executive Assistant

AI-powered WhatsApp chatbot built using Groq Llama-3.1-8B + LangChain β€” acts as a personal executive assistant with memory, scheduling & email automation.


πŸ“Œ About This Project

This AI-powered WhatsApp Assistant functions like a personal executive assistant.
It can:

  • Schedule meetings
  • Send emails
  • Remember past conversations
  • Run LangChain tools
  • Use Groq's ultra-fast Llama-3.1-8B model
  • Store long-term memory in SQLite

Perfect for business automation, personal workflow automation, and AI-driven productivity.


🧠 Features

  • πŸ“± WhatsApp Integration using Twilio
  • 🧠 Persistent Memory (SQLite)
  • πŸ“… Meeting Scheduler Tool
  • πŸ“§ Email Sending Tool
  • ⚑ Groq Llama-3.1-8B Instant Model
  • πŸ”— LangChain Agent with Custom Tools
  • πŸ”’ Environment-based secure configuration
  • 🌐 ngrok tunneling for webhook testing

πŸš€ Tech Stack / Tools Used

Python LangChain Groq Twilio SQLite Flask ngrok


πŸ“‚ Project Structure

WhatsApp_AI_Executive_Assistan/
β”œβ”€β”€ .venv/                    Virtual environment  
β”œβ”€β”€ main.py                   Flask server (webhook handler)  
β”œβ”€β”€ agent.py                  LangChain agent logic (Groq LLM)  
β”œβ”€β”€ tools.py                  Custom tools (email, scheduling)  
β”œβ”€β”€ requirements.txt          Python dependencies  
β”œβ”€β”€ .env                      API keys (DO NOT COMMIT)  
β”œβ”€β”€ chat_history.db           SQLite memory database  
└── README.md                 Documentation  

πŸ› οΈ Installation

Create and activate virtual environment:

Windows:

python -m venv .venv
.venv\Scripts\activate

Mac/Linux:

python -m venv .venv
source .venv/bin/activate

Install packages:

pip install -r requirements.txt

πŸ” Configure API Keys

Create a .env file:

TWILIO_ACCOUNT_SID=your_twilio_sid_here
TWILIO_AUTH_TOKEN=your_twilio_token_here

GROQ_API_KEY=your_groq_api_key_here
MODEL_NAME=llama-3.1-8b-instant

How to get Groq API Key:

  1. Visit https://console.groq.com
  2. Click API Keys
  3. Create a new key
  4. Paste it into .env

▢️ Run the Server

python main.py

Server runs at:

http://localhost:5000

Webhook endpoint:

/bot

🌐 Expose Localhost Using ngrok

ngrok http 5000

Copy the HTTPS URL and set it in Twilio webhook:

https://your-ngrok-url.ngrok.io/bot

πŸ“² Setup Twilio WhatsApp Sandbox

  1. Visit https://www.twilio.com
  2. Go to Messaging β†’ Try it out β†’ WhatsApp
  3. Join the sandbox
  4. Set webhook:
https://your-ngrok-url.ngrok.io/bot

🧠 How Memory Works

Each WhatsApp user has a session ID:

whatsapp:+92300xxxxxxx

Memory is stored in the database:

chat_history.db

Even after restarting the server, the bot remembers previous conversations.


πŸ§ͺ Testing

βœ” Memory Test:

  1. Send: My secret code is Blue-Owl
  2. Stop the server
  3. Start the server again
  4. Send: What is my secret code?

Expected: Blue-Owl


βœ” Tools Test:

  • β€œSchedule a meeting with Ali on Monday at 2 PM”
  • β€œSend an email to hr@company.com saying I will be late.”

πŸ“¦ Requirements

  • Python 3.11+
  • Groq API key
  • Twilio WhatsApp Sandbox
  • ngrok

🧹 Recommended .gitignore

.env
.venv/
__pycache__/
*.pyc
chat_history.db
*.db
.DS_Store

πŸ›  Troubleshooting

❌ python-dotenv Error

βœ” Ensure .env only contains valid key-value pairs.

❌ Webhook Not Receiving Messages

βœ” ngrok must be running
βœ” Twilio webhook URL must match
βœ” WhatsApp sandbox must be joined

❌ Model Issues

βœ” MODEL_NAME must be llama-3.1-8b-instant
βœ” Groq API key must be valid


πŸ§‘β€πŸ’» Author

Muhammad Umer Iqbal β€” AI Engineer


πŸ“„ License

MIT License

About

A WhatsApp AI Executive Assistant built using Python, Flask, LangChain, Groq (llama-3.1-8b-instant) and Twilio. The bot can remember conversations using persistent SQLite memory, schedule meetings, send emails, and act as a smart personal assistant directly inside WhatsApp.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages