Filters incoming Swahili SMS messages for spam using a machine learning model.
# SMS Gateway Spam Filter
A Flask-based application that filters and processes incoming SMS messages using machine learning to detect spam.
## Features
- Real-time SMS spam detection using a pre-trained machine learning model
- Web dashboard to view message history and spam detection results
- Integration with Africa's Talking SMS API
- Environment-based configuration
- Detailed logging for troubleshooting
## Setup and Installation
### Prerequisites
- Python 3.7+
- pip (Python package manager)
- Africa's Talking account with API credentials
### Installation
1. Clone the repository
```bash
git clone
github.com
cd sms-gateway-filter
```
2. Create and activate a virtual environment
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. Install dependencies
```bash
pip install -r requirements.txt
```
4. Create a `.env` file in the project root with your Africa's Talking credentials:
```
AT_USERNAME=your_africastalking_username
AT_API_KEY=your_africastalking_api_key
```
5. Ensure you have the required ML model files:
- `spam_model.pkl`
- `vectorizer.pkl`
## Usage
### Starting the Server
Run the application:
```bash
python app.py
```
The server will start on
127.0.0.1 by default.
### Available Endpoints
- **GET /** - Web dashboard for viewing filtered messages
- **POST /incoming-messages** - Endpoint for receiving SMS messages
- **GET /test** - Simple endpoint to verify server status
### Sending Test Messages
You can test the API by sending a POST request to the `/incoming-messages` endpoint:
```bash
curl -X POST
localhost \
-H "Content-Type: application/json" \
-d '{"from": "+1234567890", "text": "Hello, this is a test message", "to": "+0987654321"}'
```
## Message Processing
When a message is received:
1. The system extracts the sender, message content, and recipient
2. The machine learning model analyzes the message to …