A free, open-source spam and phishing detection service powered by Hugging Face models and Cloudflare Workers. Completely serverless and costs $0 to run!
- π 100% Free - Runs on Cloudflare's free tier (100k requests/day)
- π Fast - Serverless edge computing with low latency
- π€ AI-Powered - Uses state-of-the-art ML models from Hugging Face
- π Easy to Use - Simple REST API
- π Privacy-Focused - No data storage, no tracking
- π‘οΈ CAPTCHA Protected - Cloudflare Turnstile prevents abuse
- π¦ Open Source - MIT licensed
- Check SMS messages for spam
- Detect phishing emails
- Validate user-submitted content
- Integrate into chatbots or messaging apps
- Protect your users from scams
- Node.js (v16+)
- A Cloudflare account (free)
- A Hugging Face account (free)
- Visit https://huggingface.co/settings/tokens
- Create a new token with "Read" permissions
- Copy the token (starts with
hf_...
)
- Go to Cloudflare Dashboard β Turnstile
- Click Add Site
- Enter a site name (e.g., "Spam Detector")
- Add your domain (or use
localhost
for testing) - Select Managed widget mode
- Copy the Site Key and Secret Key
# Clone this repository
git clone https://github.com/bettergov/scamcheck.git
cd scamcheck
# Install dependencies
npm install
# Run the server
npm run dev
# Open the browser
open http://localhost:8787
# Login to Cloudflare
npx wrangler login
# Add your Hugging Face token
npx wrangler secret put HF_TOKEN
# (paste your token when prompted)
# Add your Turnstile secret key to wrangler.toml
# Edit wrangler.toml and replace 'your-turnstile-secret-key-here' with your actual secret key
# Update test-page.html with your Turnstile site key
# Replace 'YOUR_TURNSTILE_SITE_KEY' with your actual site key
# Deploy!
npx wrangler deploy
You'll get a URL like: https://scamcheck.your-subdomain.workers.dev
POST https://your-worker-url.workers.dev
{
"text": "URGENT: Your account has been suspended. Click here immediately!",
"turnstileToken": "your-captcha-token-here"
}
Note: The turnstileToken
is required and obtained from the Cloudflare Turnstile widget on your frontend.
{
"success": true,
"text": "URGENT: Your account has been suspended. Click here immediately!",
"predictions": [
{
"label": "phishing",
"score": 0.9823
},
{
"label": "safe",
"score": 0.0177
}
],
"interpretation": {
"isSpam": true,
"confidence": "high",
"confidenceScore": "98.23%",
"message": "β οΈ HIGH RISK: This appears to be phishing/spam"
}
}
curl -X POST https://your-worker-url.workers.dev \
-H "Content-Type: application/json" \
-d '{"text": "URGENT: Click here to verify your account!"}'
const response = await fetch('https://your-worker-url.workers.dev', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text: 'Congratulations! You won $1000!'
})
});
const data = await response.json();
console.log(data.interpretation.message);
import requests
response = requests.post(
'https://your-worker-url.workers.dev',
json={'text': 'URGENT: Your account has been compromised!'}
)
data = response.json()
print(data['interpretation']['message'])
Edit scamcheck.js
and change the model URL:
const hfResponse = await fetch(
'https://api-inference.huggingface.co/models/cybersectony/phishing-email-detection-distilbert_v2.4.1',
// ...
);
Recommended models:
cybersectony/phishing-email-detection-distilbert_v2.4.1
(default)mrm8488/bert-tiny-finetuned-sms-spam-detection
mariagrandury/roberta-base-finetuned-sms-spam-detection
elftsdmr/spam-detector
The free tier includes:
- β 100,000 requests per day
- β 10ms CPU time per request
- β Worldwide edge locations
For higher limits, upgrade to Cloudflare Workers Paid plan ($5/month for 10M requests).
View real-time logs:
npx wrangler tail
Check analytics in your Cloudflare Dashboard.
Contributions are welcome! Please feel free to submit a Pull Request.
- Add support for multiple languages
- Implement request caching
- Add rate limiting per IP
- Support batch processing
- Create client libraries (Python, JavaScript, etc.)
- Add more detailed phishing indicators
- Improve the test UI
MIT License - feel free to use this in your projects!
- Hugging Face for the incredible model hosting
- Cloudflare for the generous free tier
- cybersectony for the phishing detection model
This tool is for educational and protective purposes. Always use multiple layers of security and don't rely solely on automated detection.
- π Report a bug
- π‘ Request a feature
- β Star this repo if you find it useful!
Made with β€οΈ by Jason Torres of BetterGov.ph