Anand815353/honeypotApi
Agentic Honey-Pot for Scam Detection & Intelligence Extraction
AI-powered honeypot system that detects scam messages, handles multi-turn conversations, and extracts actionable intelligence without revealing detection.
Features
- Scam Detection: Detects scam intent from incoming messages using keyword matching and pattern detection
- Session Management: Tracks multi-turn conversations using in-memory session storage
- Intelligence Extraction: Extracts bank accounts, UPI IDs, phishing links, phone numbers, and suspicious keywords
- GUVI Callback Integration: Automatically sends extracted intelligence to GUVI evaluation endpoint
- API Key Authentication: Secured endpoints using x-api-key header
Project Structure
Agentic honeypot/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI app entry point
│ ├── models.py # Pydantic request/response models
│ ├── auth.py # API key authentication middleware
│ ├── services/
│ │ ├── __init__.py
│ │ ├── scam_detector.py # Scam detection logic
│ │ ├── intelligence_extractor.py # Intelligence extraction
│ │ ├── session_manager.py # In-memory session management
│ │ └── callback_client.py # HTTP client for GUVI callback
│ └── routers/
│ ├── __init__.py
│ └── message.py # Main message endpoint router
├── .env.example # Environment variables template
├── requirements.txt # Python dependencies
└── README.md # This fileSetup Instructions
Option 1: Docker (Recommended)
Using Docker Compose (Local Testing)
- Configure Environment Variables
Copy .env.example to .env and update with your values:
cp .env.example .env Edit .env:
API_KEY=your_secret_api_key_here
GUVI_CALLBACK_URL=https://hackathon.guvi.in/api/updateHoneyPotFinalResult- Build and Run with Docker Compose
docker-compose up --build The API will be available at http://localhost:8000
- Stop the Container
docker-compose downUsing Docker Directly
- Build the Docker Image
docker build -t agentic-honeypot .- Run the Container
docker run -d \
--name agentic-honeypot-api \
-p 8000:8000 \
--env-file .env \
-e PORT=8000 \
agentic-honeypot The API will be available at http://localhost:8000
- Stop and Remove Container
docker stop agentic-honeypot-api
docker rm agentic-honeypot-apiOption 2: Local Python Development
- Install Dependencies
pip install -r requirements.txt- Configure Environment Variables
Copy .env.example to .env and update with your values:
cp .env.example .env Edit .env:
API_KEY=your_secret_api_key_here
GUVI_CALLBACK_URL=https://hackathon.guvi.in/api/updateHoneyPotFinalResult- Run the Application
# Using uvicorn directly
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
# Or using Python
python -m app.main The API will be available at http://localhost:8000
Docker Deployment
Hugging Face Spaces
This application is configured for deployment on Hugging Face Spaces using Docker:
- Create a new Space on Hugging Face Hub
- Select Docker SDK as the SDK type
- Push your code to the Space repository
- Set Environment Variables in the Space settings:
API_KEY: Your secret API keyGUVI_CALLBACK_URL: The callback endpoint URLPORT: Will be automatically set to 7860 by HF Spaces
The application will automatically use port 7860 (configured in README.md frontmatter) when deployed on Hugging Face Spaces.
Port Configuration
- Local Development: Port 8000 (default)
- Docker Local: Port 8000 (configurable via
PORTenv var) - Hugging Face Spaces: Port 7860 (automatically set by HF Spaces)
The application reads the PORT environment variable and defaults to 8000 if not set.
API Endpoints
Health Check
- GET
/or/health - Returns:
{"status": "healthy"}
Process Message
- POST
/api/message - Headers:
x-api-key: YOUR_SECRET_API_KEYContent-Type: application/json- Request Body: See Request Format below
- Response: See Response Format below
Request Format
First Message (Start of Conversation)
{
"sessionId": "wertyu-dfghj-ertyui",
"message": {
"sender": "scammer",
"text": "Your bank account will be blocked today. Verify immediately.",
"timestamp": "2026-01-21T10:15:30Z"
},
"conversationHistory": [],
"metadata": {
"channel": "SMS",
"language": "English",
"locale": "IN"
}
}Follow-Up Message
{
"sessionId": "wertyu-dfghj-ertyui",
"message": {
"sender": "scammer",
"text": "Share your UPI ID to avoid account suspension.",
"timestamp": "2026-01-21T10:17:10Z"
},
"conversationHistory": [
{
"sender": "scammer",
"text": "Your bank account will be blocked today. Verify immediately.",
"timestamp": "2026-01-21T10:15:30Z"
},
{
"sender": "user",
"text": "Why will my account be blocked?",
"timestamp": "2026-01-21T10:16:10Z"
}
],
"metadata": {
"channel": "SMS",
"language": "English",
"locale": "IN"
}
}Response Format
{
"status": "success",
"scamDetected": true,
"engagementMetrics": {
"engagementDurationSeconds": 420,
"totalMessagesExchanged": 18
},
"extractedIntelligence": {
"bankAccounts": ["XXXX-XXXX-XXXX"],
"upiIds": ["scammer@upi"],
"phishingLinks": ["http://malicious-link.example"],
"phoneNumbers": ["+91XXXXXXXXXX"],
"suspiciousKeywords": ["urgent", "verify now", "account blocked"]
},
"agentNotes": "Scammer used urgency tactics and payment redirection"
}Testing the API
Using curl
curl -X POST "http://localhost:8000/api/message" \
-H "x-api-key: your_secret_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"sessionId": "test-session-123",
"message": {
"sender": "scammer",
"text": "Your bank account will be blocked today. Verify immediately.",
"timestamp": "2026-01-21T10:15:30Z"
},
"conversationHistory": [],
"metadata": {
"channel": "SMS",
"language": "English",
"locale": "IN"
}
}'Using Python requests
import requests
url = "http://localhost:8000/api/message"
headers = {
"x-api-key": "your_secret_api_key_here",
"Content-Type": "application/json"
}
payload = {
"sessionId": "test-session-123",
"message": {
"sender": "scammer",
"text": "Your bank account will be blocked today. Verify immediately.",
"timestamp": "2026-01-21T10:15:30Z"
},
"conversationHistory": [],
"metadata": {
"channel": "SMS",
"language": "English",
"locale": "IN"
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())API Documentation
Once the server is running, visit:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
How It Works
- Request Received: API receives incoming message with sessionId
- Session Management: Gets or creates session for the conversation
- Scam Detection: Analyzes message and history for scam indicators
- Intelligence Extraction: Extracts bank accounts, UPI IDs, links, phone numbers, keywords
- Session Update: Updates session with new message and intelligence
- Metrics Calculation: Calculates engagement duration and message count
- Callback: If scam detected and sufficient engagement, sends callback to GUVI endpoint (async)
- Response: Returns structured JSON with all extracted data
Notes
- Session data is stored in-memory (will be lost on server restart)
- Callback to GUVI endpoint is sent asynchronously to avoid blocking responses
- Scam detection uses keyword matching (can be enhanced with ML models)
- Intelligence extraction uses regex patterns (can be improved)
- Agent logic for conversation handling will be added later
Next Steps
- [ ] Integrate AI agent for conversation handling
- [ ] Enhance scam detection with ML models
- [ ] Improve intelligence extraction patterns
- [ ] Add persistent session storage (database)
- [ ] Add logging and monitoring
- [ ] Add unit tests
License
This project is developed for the hackathon.
