Open-source crisis safety infrastructure for AI apps.
Detects distress, finds local help. Zero tracking. Works offline.
34 countries · 100+ verified helplines · 205 safety tests · 0 permissions
Live Site · Get Help Now · Community · FAMTEC
SafeChat is an international register and toolkit for chat safety protocol. Free for everyone. Built for developers, health professionals, and communities.
SafeChat works as a standalone app on any device:
Open the popup: rob-e-graham.github.io/safechat/app/popup.html
<script src="https://cdn.jsdelivr.net/gh/rob-e-graham/safechat@main/src/browser.js"></script>
<script>
Safechat.protect(); // auto-monitor all text inputs
</script>
<script src="https://cdn.jsdelivr.net/gh/rob-e-graham/safechat@main/src/embed.js"
data-safechat-monitor="true"></script>
npm install safechat
const safechat = require('safechat');
const safety = safechat.check(userMessage);
if (safety.level === 'high') {
systemPrompt = safechat.promptOverride('high', safety.country)
+ '\n\n' + systemPrompt;
}
const safechat = require('safechat');
app.use(safechat.middleware());
app.post('/api/chat', (req, res) => {
const safety = req.safechat.check(req.body.message);
if (safety.action === 'crisis_intervention') {
systemPrompt = req.safechat.promptOverride(safety.level) + '\n\n' + systemPrompt;
}
});
<iframe src="https://rob-e-graham.github.io/safechat/app/popup.html"
style="width:100%;max-width:480px;height:700px;border:none;border-radius:16px;">
</iframe>
Detection uses regex pattern matching with three layers:
| Level | Triggers | Action |
|---|---|---|
| high | Suicidal ideation, self-harm, explicit intent | Show crisis resources immediately |
| low | Hopelessness, worthlessness, feeling trapped | Soft safety response with helpline link |
| none | No crisis signals | Normal operation |
SafeChat finds the user’s country without location permissions:
| Priority | Method | Permissions |
|---|---|---|
| 1 | Browser locale (navigator.language) |
None |
| 2 | Timezone (Intl.DateTimeFormat) |
None |
| 3 | CDN headers (CF-IPCountry, X-Vercel-IP-Country) |
None |
| 4 | Accept-Language header | None |
| 5 | Manual override | None |
| 6 | Global fallback (findahelpline.com) | None |
1. jsDelivr CDN (latest data) ← primary
2. GitHub raw (same data, different CDN) ← if jsDelivr down
3. localStorage cache ← if offline
4. Inline emergency numbers ← if never loaded
Verification workflow runs twice monthly to check all phone numbers and URLs.
SafeChat is designed for trust:
no-referrer on all pagessafechat.check(text, options?)safechat.check("I can't go on anymore", { country: "AU" });
// { level: "low", matched: "can't go on", country: "AU", action: "soft_warning", resources: {...} }
safechat.detect(text)safechat.detect("I want to kill myself") // { level: "high", matched: "kill myself" }
safechat.detect("I feel worthless") // { level: "low", matched: "worthless" }
safechat.detect("great day today") // { level: "none", matched: null }
safechat.promptOverride(level, countryCode)safechat.getResources(countryCode, options?)safechat.middleware()Australia, Austria, Belgium, Brazil, Canada, China, Denmark, Finland, France, Germany, Ghana, Hong Kong, India, Ireland, Israel, Italy, Japan, Kenya, Mexico, Netherlands, New Zealand, Nigeria, Norway, Pakistan, Philippines, Portugal, Russia, South Africa, South Korea, Spain, Sweden, Switzerland, United Kingdom, United States.
Plus global fallback via findahelpline.com (175+ countries).
SafeChat uses Business Source License (BSL 1.1).
Free for:
Commercial entities over $100K must obtain a commercial license: rob@fineartmedia.tech
Changes to MPL 2.0 on 2029-01-01.
SafeChat is provided as is. It is not emergency medical care, legal advice, professional mental health treatment, or a substitute for emergency services, clinicians, safeguarding teams, or local crisis procedures.
By downloading, installing, deploying, integrating, or using SafeChat, you accept responsibility for your own installation, configuration, compliance, testing, supervision, and use. To the maximum extent permitted by law, Rob Graham, FAMTEC, contributors, maintainers, copyright holders, and licensors are not liable for damages, losses, legal claims, regulatory penalties, system damage, data loss, personal injury, death, failure to obtain help, failure to detect crisis content, unlawful use, or other harm arising from installation or use.
If you do not accept these terms, do not download, install, deploy, integrate, or use SafeChat. See LICENSE for the full disclaimer and limitation of liability.
Help keep crisis resources accurate and expand to more countries. See CONTRIBUTING.md.
This project follows Samaritans safe messaging guidelines.
Created by Rob Graham / FAMTEC
If you or someone you know is in crisis: findahelpline.com