crisis-response-protocol
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCrisis Response Protocol
危机响应协议
This skill helps you implement safe crisis intervention features for the AI coaching system, following mental health best practices.
本技能可帮助你遵循心理健康最佳实践,为AI辅导系统实施安全的危机干预功能。
When to Use
适用场景
✅ USE this skill for:
- Implementing crisis detection in recovery/mental health apps
- Building safety planning features
- Integrating hotline and emergency resource displays
- Designing risk assessment interfaces
- Creating escalation protocols for AI chat systems
❌ DO NOT use for:
- Responding to an actual crisis yourself → Call 988 or emergency services
- General mental health content → use or
sober-addict-protectorrecovery-coach-patterns - Medical advice or diagnosis → Always defer to licensed professionals
- Replacing human crisis counselors → AI should augment, never replace
✅ 适用场景:
- 在康复/心理健康应用中实施危机检测
- 构建安全规划功能
- 集成热线与紧急资源展示
- 设计风险评估界面
- 为AI聊天系统创建升级协议
❌ 不适用场景:
- 亲自响应实际危机 → 请拨打988或紧急服务电话
- 一般心理健康内容 → 使用或
sober-addict-protectorrecovery-coach-patterns - 医疗建议或诊断 → 始终交由持证专业人员处理
- 替代人类危机咨询师 → AI只能作为辅助,绝不能替代
Critical Safety Principle
核心安全原则
AI should NEVER be the sole responder in acute crisis situations. Always provide pathways to human support and emergency services.
AI绝不能成为急性危机情况中的唯一响应者。 始终要提供对接人类支持和紧急服务的渠道。
Crisis Detection
危机检测
Risk Indicator Categories
风险指标分类
typescript
interface RiskIndicators {
// PRIMARY - Immediate escalation required
primary: {
suicidalIdeation: string[]; // "want to die", "end it all"
selfHarmIntent: string[]; // "hurt myself", "cutting"
homicidalIdeation: string[]; // "hurt someone"
activeSubstanceEmergency: string[]; // "overdosed", "can't stop"
};
// SECONDARY - Elevated monitoring
secondary: {
severeDepression: string[]; // "hopeless", "no point"
panicSymptoms: string[]; // "can't breathe", "heart racing"
psychoticSymptoms: string[]; // "hearing voices"
severeAnxiety: string[]; // "terrified", "losing control"
};
// TERTIARY - Check-in triggers
tertiary: {
isolationPatterns: string[]; // "no one cares", "alone"
substanceRelapse: string[]; // "started using", "slipped"
hopelessness: string[]; // "never get better"
};
}typescript
interface RiskIndicators {
// PRIMARY - 需立即升级
primary: {
suicidalIdeation: string[]; // "want to die", "end it all"
selfHarmIntent: string[]; // "hurt myself", "cutting"
homicidalIdeation: string[]; // "hurt someone"
activeSubstanceEmergency: string[]; // "overdosed", "can't stop"
};
// SECONDARY - 需加强监控
secondary: {
severeDepression: string[]; // "hopeless", "no point"
panicSymptoms: string[]; // "can't breathe", "heart racing"
psychoticSymptoms: string[]; // "hearing voices"
severeAnxiety: string[]; // "terrified", "losing control"
};
// TERTIARY - 触发签到提醒
tertiary: {
isolationPatterns: string[]; // "no one cares", "alone"
substanceRelapse: string[]; // "started using", "slipped"
hopelessness: string[]; // "never get better"
};
}Detection Implementation
检测实现
typescript
// src/lib/ai/crisis-detection.ts
export interface CrisisAssessment {
level: 'none' | 'low' | 'medium' | 'high' | 'critical';
indicators: string[];
recommendedAction: CrisisAction;
timestamp: Date;
}
export type CrisisAction =
| 'continue_conversation'
| 'gentle_check_in'
| 'safety_resources'
| 'crisis_protocol'
| 'emergency_escalation';
export function assessCrisisLevel(
messageContent: string,
conversationHistory: Message[],
userCheckInHistory: CheckIn[]
): CrisisAssessment {
const indicators: string[] = [];
let level: CrisisAssessment['level'] = 'none';
// Check primary indicators (critical)
if (hasPrimaryIndicators(messageContent)) {
level = 'critical';
indicators.push('primary_risk_detected');
}
// Check secondary indicators
if (hasSecondaryIndicators(messageContent)) {
level = level === 'none' ? 'high' : level;
indicators.push('secondary_risk_detected');
}
// Check pattern indicators from history
if (hasWorseningPattern(userCheckInHistory)) {
level = level === 'none' ? 'medium' : level;
indicators.push('worsening_trend');
}
// Check conversation escalation
if (hasEscalatingDistress(conversationHistory)) {
level = level === 'none' ? 'medium' : level;
indicators.push('escalating_distress');
}
return {
level,
indicators,
recommendedAction: getRecommendedAction(level),
timestamp: new Date(),
};
}typescript
// src/lib/ai/crisis-detection.ts
export interface CrisisAssessment {
level: 'none' | 'low' | 'medium' | 'high' | 'critical';
indicators: string[];
recommendedAction: CrisisAction;
timestamp: Date;
}
export type CrisisAction =
| 'continue_conversation'
| 'gentle_check_in'
| 'safety_resources'
| 'crisis_protocol'
| 'emergency_escalation';
export function assessCrisisLevel(
messageContent: string,
conversationHistory: Message[],
userCheckInHistory: CheckIn[]
): CrisisAssessment {
const indicators: string[] = [];
let level: CrisisAssessment['level'] = 'none';
// 检查一级指标(危急)
if (hasPrimaryIndicators(messageContent)) {
level = 'critical';
indicators.push('primary_risk_detected');
}
// 检查二级指标
if (hasSecondaryIndicators(messageContent)) {
level = level === 'none' ? 'high' : level;
indicators.push('secondary_risk_detected');
}
// 检查历史记录中的模式指标
if (hasWorseningPattern(userCheckInHistory)) {
level = level === 'none' ? 'medium' : level;
indicators.push('worsening_trend');
}
// 检查对话中的情绪升级
if (hasEscalatingDistress(conversationHistory)) {
level = level === 'none' ? 'medium' : level;
indicators.push('escalating_distress');
}
return {
level,
indicators,
recommendedAction: getRecommendedAction(level),
timestamp: new Date(),
};
}Tiered Response Protocol
分级响应协议
Level 1: Continue Conversation (No Crisis)
一级:继续对话(无危机)
Normal AI coaching interaction.
正常AI辅导交互。
Level 2: Gentle Check-In (Low Risk)
二级:温和签到(低风险)
typescript
const gentleCheckInResponse = `
I want to make sure I understand how you're feeling.
It sounds like you're going through a difficult time.
Would you like to:
- Talk more about what's on your mind?
- Try a grounding exercise together?
- Look at some coping strategies?
I'm here to listen.
`;typescript
const gentleCheckInResponse = `
我想确认我理解了你的感受。
听起来你正在经历一段艰难的时光。
你是否愿意:
- 更多地聊聊你心里的想法?
- 一起尝试一个接地练习?
- 看看一些应对策略?
我会在这里倾听你。
`;Level 3: Safety Resources (Medium Risk)
三级:安全资源推送(中风险)
typescript
const safetyResourcesResponse = `
I hear that you're struggling, and I want you to know that support is available.
Here are some resources that might help:
📞 988 Suicide & Crisis Lifeline: Call or text 988
💬 Crisis Text Line: Text HOME to 741741
🌐 SAMHSA Helpline: 1-800-662-4357
Would you like to talk about what's going on, or would connecting with one of these resources feel right?
`;typescript
const safetyResourcesResponse = `
我听到你现在很痛苦,想让你知道有支持资源可以求助。
以下是一些可能有帮助的资源:
📞 988自杀与危机生命线:拨打或发送短信至988
💬 危机短信热线:发送HOME至741741
🌐 SAMHSA热线:1-800-662-4357
你想聊聊目前的状况,还是觉得对接这些资源更合适?
`;Level 4: Crisis Protocol (High Risk)
四级:危机协议启动(高风险)
typescript
const crisisProtocolResponse = `
I'm concerned about what you've shared, and I want to make sure you're safe.
Right now, I'd like you to consider reaching out to someone who can help:
🆘 If you're in immediate danger: Call 911
📞 988 Suicide & Crisis Lifeline: Call or text 988 (24/7)
💬 Crisis Text Line: Text HOME to 741741
These are trained counselors who understand what you're going through.
Is there someone you trust - a friend, family member, or sponsor - who you could reach out to right now?
I'm still here with you.
`;typescript
const crisisProtocolResponse = `
我很担心你分享的内容,希望确保你的安全。
现在,我希望你考虑联系能提供帮助的人:
🆘 如果你身处即时危险中:请拨打911
📞 988自杀与危机生命线:拨打或发送短信至988(24/7在线)
💬 危机短信热线:发送HOME至741741
这些都是经过专业训练的咨询师,能理解你的处境。
你身边有没有可以信任的人——朋友、家人或担保人——你现在可以联系他们?
我会一直在这里陪着你。
`;Level 5: Emergency Escalation (Critical)
五级:紧急升级(危急)
typescript
const emergencyResponse = `
I'm very concerned about your safety right now.
🆘 Please call 911 or go to your nearest emergency room immediately.
If you can't do that, please call 988 right now - they can help.
Your life matters. Please reach out for help right now.
[EMERGENCY CONTACTS DISPLAYED]
`;
// System action: Flag for human review, notify emergency contact if configuredtypescript
const emergencyResponse = `
我现在非常担心你的安全。
🆘 请立即拨打911或前往最近的急诊室。
如果你无法做到,请立即拨打988——他们能提供帮助。
你的生命很重要。请现在就求助。
[显示紧急联系人]
`;
// 系统操作:标记为人工审核,若已配置则通知紧急联系人Implementation in Chat Handler
在聊天处理器中的实现
typescript
// src/lib/ai/chat-handler.ts
export async function handleChatMessage(
message: string,
conversationId: string,
userId: string
): Promise<ChatResponse> {
// 1. Assess crisis level BEFORE generating AI response
const crisisAssessment = await assessCrisisLevel(
message,
await getConversationHistory(conversationId),
await getUserCheckIns(userId, 7)
);
// 2. Log assessment (for safety review)
await logCrisisAssessment(userId, conversationId, crisisAssessment);
// 3. Handle based on level
if (crisisAssessment.level === 'critical') {
// Don't use AI - provide immediate crisis response
await notifyEmergencyContact(userId);
await flagForHumanReview(conversationId, 'critical_crisis');
return {
message: emergencyResponse,
showEmergencyContacts: true,
disableChat: true, // Prevent further AI interaction
crisisLevel: 'critical',
};
}
if (crisisAssessment.level === 'high') {
// Provide crisis resources, continue with caution
await flagForHumanReview(conversationId, 'high_risk');
return {
message: crisisProtocolResponse,
showCrisisResources: true,
crisisLevel: 'high',
};
}
// 4. For lower levels, proceed with AI but inject safety context
const systemPrompt = getSystemPromptWithSafetyContext(crisisAssessment);
const aiResponse = await generateAIResponse(message, systemPrompt);
// 5. Post-process AI response for safety
const safeResponse = await validateResponseSafety(aiResponse);
return {
message: safeResponse,
crisisLevel: crisisAssessment.level,
};
}typescript
// src/lib/ai/chat-handler.ts
export async function handleChatMessage(
message: string,
conversationId: string,
userId: string
): Promise<ChatResponse> {
// 1. 在生成AI响应前先评估危机等级
const crisisAssessment = await assessCrisisLevel(
message,
await getConversationHistory(conversationId),
await getUserCheckIns(userId, 7)
);
// 2. 记录评估结果(用于安全审核)
await logCrisisAssessment(userId, conversationId, crisisAssessment);
// 3. 根据等级处理
if (crisisAssessment.level === 'critical') {
// 不使用AI,直接提供紧急危机响应
await notifyEmergencyContact(userId);
await flagForHumanReview(conversationId, 'critical_crisis');
return {
message: emergencyResponse,
showEmergencyContacts: true,
disableChat: true, // 禁止进一步AI交互
crisisLevel: 'critical',
};
}
if (crisisAssessment.level === 'high') {
// 提供危机资源,谨慎继续交互
await flagForHumanReview(conversationId, 'high_risk');
return {
message: crisisProtocolResponse,
showCrisisResources: true,
crisisLevel: 'high',
};
}
// 4. 对于低等级情况,继续使用AI但注入安全上下文
const systemPrompt = getSystemPromptWithSafetyContext(crisisAssessment);
const aiResponse = await generateAIResponse(message, systemPrompt);
// 5. 对AI响应进行安全后处理
const safeResponse = await validateResponseSafety(aiResponse);
return {
message: safeResponse,
crisisLevel: crisisAssessment.level,
};
}Safety Resources Database
安全资源数据库
typescript
// src/lib/crisis/resources.ts
export const crisisResources = {
national: [
{
name: '988 Suicide & Crisis Lifeline',
phone: '988',
text: '988',
url: 'https://988lifeline.org',
available: '24/7',
description: 'Free, confidential crisis support',
},
{
name: 'Crisis Text Line',
text: 'HOME to 741741',
url: 'https://www.crisistextline.org',
available: '24/7',
description: 'Text-based crisis support',
},
{
name: 'SAMHSA National Helpline',
phone: '1-800-662-4357',
url: 'https://www.samhsa.gov/find-help/national-helpline',
available: '24/7',
description: 'Substance abuse and mental health referrals',
},
],
recovery: [
{
name: 'AA Hotline',
phone: '1-800-839-1686',
url: 'https://www.aa.org',
description: 'Alcoholics Anonymous support',
},
{
name: 'NA Helpline',
phone: '1-818-773-9999',
url: 'https://na.org',
description: 'Narcotics Anonymous support',
},
],
specialized: [
{
name: 'Veterans Crisis Line',
phone: '988 (press 1)',
text: '838255',
description: 'For veterans and service members',
},
{
name: 'Trevor Project',
phone: '1-866-488-7386',
text: 'START to 678-678',
description: 'LGBTQ+ youth crisis support',
},
],
};typescript
// src/lib/crisis/resources.ts
export const crisisResources = {
national: [
{
name: '988 Suicide & Crisis Lifeline',
phone: '988',
text: '988',
url: 'https://988lifeline.org',
available: '24/7',
description: 'Free, confidential crisis support',
},
{
name: 'Crisis Text Line',
text: 'HOME to 741741',
url: 'https://www.crisistextline.org',
available: '24/7',
description: 'Text-based crisis support',
},
{
name: 'SAMHSA National Helpline',
phone: '1-800-662-4357',
url: 'https://www.samhsa.gov/find-help/national-helpline',
available: '24/7',
description: 'Substance abuse and mental health referrals',
},
],
recovery: [
{
name: 'AA Hotline',
phone: '1-800-839-1686',
url: 'https://www.aa.org',
description: 'Alcoholics Anonymous support',
},
{
name: 'NA Helpline',
phone: '1-818-773-9999',
url: 'https://na.org',
description: 'Narcotics Anonymous support',
},
],
specialized: [
{
name: 'Veterans Crisis Line',
phone: '988 (press 1)',
text: '838255',
description: 'For veterans and service members',
},
{
name: 'Trevor Project',
phone: '1-866-488-7386',
text: 'START to 678-678',
description: 'LGBTQ+ youth crisis support',
},
],
};Emergency Contact System
紧急联系人系统
typescript
// src/lib/crisis/emergency-contacts.ts
export async function notifyEmergencyContact(userId: string): Promise<void> {
const contacts = await getEmergencyContacts(userId);
if (contacts.length === 0) {
// Log that no emergency contact was available
await logCrisisEvent(userId, 'no_emergency_contact');
return;
}
const primaryContact = contacts[0];
// Send notification (SMS, email, or push)
await sendEmergencyNotification(primaryContact, {
type: 'crisis_alert',
message: `${userName} may be in crisis and could use your support. ` +
`Please reach out to them if you can.`,
// Never include conversation content - privacy
});
// Audit log
await logCrisisEvent(userId, 'emergency_contact_notified', {
contactId: primaryContact.id,
});
}typescript
// src/lib/crisis/emergency-contacts.ts
export async function notifyEmergencyContact(userId: string): Promise<void> {
const contacts = await getEmergencyContacts(userId);
if (contacts.length === 0) {
// 记录无可用紧急联系人的情况
await logCrisisEvent(userId, 'no_emergency_contact');
return;
}
const primaryContact = contacts[0];
// 发送通知(短信、邮件或推送)
await sendEmergencyNotification(primaryContact, {
type: 'crisis_alert',
message: `${userName}可能正处于危机中,需要你的支持。 ` +
`如果可以,请立即联系他们。`,
// 绝不包含对话内容——保护隐私
});
// 审计日志
await logCrisisEvent(userId, 'emergency_contact_notified', {
contactId: primaryContact.id,
});
}Safety Guardrails for AI
AI安全防护措施
typescript
// Prompt injection for safety context
const safetySystemPrompt = `
CRITICAL SAFETY INSTRUCTIONS:
1. You are NOT a therapist or crisis counselor
2. For ANY mention of self-harm, suicide, or harming others:
- Express genuine concern
- Provide crisis resources (988, Crisis Text Line)
- Encourage professional help
- Do NOT attempt to counsel through crisis
3. Never minimize feelings or use toxic positivity
4. Never promise confidentiality about safety concerns
5. Always validate emotions while encouraging professional support
6. If user mentions relapse, acknowledge and provide SAMHSA helpline
`;
// Response validation
async function validateResponseSafety(response: string): Promise<string> {
const unsafePatterns = [
/don't (call|reach out|get help)/i,
/you don't need (help|therapy|a professional)/i,
/just (think positive|be happy|get over it)/i,
/it's not that (bad|serious)/i,
];
for (const pattern of unsafePatterns) {
if (pattern.test(response)) {
// Flag for review and return safe fallback
await flagForReview('unsafe_response_pattern');
return getSafeFallbackResponse();
}
}
return response;
}typescript
// 用于注入安全上下文的提示词
const safetySystemPrompt = `
核心安全指令:
1. 你不是治疗师或危机咨询师
2. 对于任何提及自我伤害、自杀或伤害他人的内容:
- 表达真诚的关心
- 提供危机资源(988、危机短信热线)
- 鼓励寻求专业帮助
- 不要尝试为危机提供咨询
3. 绝不轻视感受或使用有毒的积极话术
4. 绝不承诺对安全问题保密
5. 始终先共情情绪,再鼓励寻求专业支持
6. 如果用户提及复吸,要认可并提供SAMHSA热线
`;
// 响应验证
async function validateResponseSafety(response: string): Promise<string> {
const unsafePatterns = [
/don't (call|reach out|get help)/i,
/you don't need (help|therapy|a professional)/i,
/just (think positive|be happy|get over it)/i,
/it's not that (bad|serious)/i,
];
for (const pattern of unsafePatterns) {
if (pattern.test(response)) {
// 标记为审核并返回安全 fallback 响应
await flagForReview('unsafe_response_pattern');
return getSafeFallbackResponse();
}
}
return response;
}Audit & Compliance
审计与合规
typescript
// All crisis events must be logged for review
export async function logCrisisEvent(
userId: string,
eventType: CrisisEventType,
details?: Record<string, unknown>
): Promise<void> {
await db.insert(crisisEvents).values({
id: generateId(),
userId,
eventType,
details: JSON.stringify(sanitizeDetails(details)),
createdAt: new Date(),
reviewed: false, // Requires human review
});
// Critical events trigger immediate notification
if (isCriticalEvent(eventType)) {
await notifyOnCallStaff(userId, eventType);
}
}typescript
// 所有危机事件必须记录以便审核
export async function logCrisisEvent(
userId: string,
eventType: CrisisEventType,
details?: Record<string, unknown>
): Promise<void> {
await db.insert(crisisEvents).values({
id: generateId(),
userId,
eventType,
details: JSON.stringify(sanitizeDetails(details)),
createdAt: new Date(),
reviewed: false, // 需要人工审核
});
// 重大事件触发即时通知
if (isCriticalEvent(eventType)) {
await notifyOnCallStaff(userId, eventType);
}
}Testing Crisis Features
危机功能测试
typescript
// NEVER use real crisis content in tests
describe('Crisis Detection', () => {
it('detects high-risk indicators', () => {
// Use clearly artificial test phrases
const result = assessCrisisLevel(
'[TEST_HIGH_RISK_INDICATOR]',
[],
[]
);
expect(result.level).toBe('high');
});
it('provides appropriate resources', () => {
const response = getCrisisResponse('high');
expect(response).toContain('988');
expect(response).toContain('Crisis Text Line');
});
});typescript
// 绝不在测试中使用真实危机内容
describe('Crisis Detection', () => {
it('detects high-risk indicators', () => {
// 使用明确的人工测试语句
const result = assessCrisisLevel(
'[TEST_HIGH_RISK_INDICATOR]',
[],
[]
);
expect(result.level).toBe('high');
});
it('provides appropriate resources', () => {
const response = getCrisisResponse('high');
expect(response).toContain('988');
expect(response).toContain('Crisis Text Line');
});
});