This is a Chat Function That calls Mpesa to Send money Without interacting with mpesa, Just using this OpenAi Chat Tool
# M-Pesa AI Backend with Enhanced Features
A robust FastAPI backend for M-Pesa payment processing with AI-powered conversation management, raw message tracking, and enhanced user experience.
## 🚀 Features
### ✅ **Core Features**
- **M-Pesa STK Push Integration**: Seamless payment processing
- **AI-Powered Conversations**: Google Gemini AI agent for natural interactions
- **Raw Message Tracking**: Track original user messages that triggered transactions
- **Firebase Integration**: User profile management and phone number fetching
- **Transaction History**: Complete payment history with message context
- **Real-time Status Updates**: Live payment status monitoring
### ✅ **Enhanced Features**
- **Message Deduplication**: Prevents duplicate message processing
- **Rate Limiting**: Protects against API abuse
- **Error Handling**: Graceful error management with user-friendly messages
- **Session Management**: Persistent conversation context
- **Entity Extraction**: Automatic extraction of payment details from messages
## 📁 Project Structure
```
mpesa-ai-backend-corrected-fix/
├── mpesa-ai-backend-fixed/
│ ├── app/
│ │ ├── main.py # FastAPI application
│ │ ├── auth.py # Authentication module
│ │ ├── models.py # Database models
│ │ ├── conversation_service.py # Conversation management
│ │ ├── transaction_manager.py # Transaction handling
│ │ └── mpesa_agent/
│ │ ├── agent.py # Base M-Pesa agent
│ │ ├── enhanced_agent.py # Enhanced AI agent
│ │ ├── mpesa_tools.py # M-Pesa tools and utilities
│ │ └── callback_manager.py # Callback handling
│ ├── docs/ # Documentation
│ ├── docker/ # Docker configuration
│ ├── requirements.txt # Python dependencies
│ └── README.md # This file
├── .gitignore # Git ignore rules
└── README.md # Projec …