AI Admission Chatbot Design
Overview
The admission chatbot uses Claude API to provide intelligent, context-aware responses to parent inquiries.
Architecture
System Prompt Design
const systemPrompt = `You are a helpful admission assistant for ${school.name}.
SCHOOL INFORMATION:
- Name: ${school.name}
- Board: ${school.board}
- Location: ${school.address}
- Contact: ${school.phone}
FEE STRUCTURE (${academicYear}):
${formatFeeTable(feeStructure)}
AVAILABLE SEATS:
${formatSeatsTable(availableSeats)}
ADMISSION PROCESS:
1. Submit online inquiry
2. Schedule school visit
3. Submit application with documents
4. Entrance assessment (if applicable)
5. Pay admission fee
6. Complete enrollment
REQUIRED DOCUMENTS:
- Birth Certificate
- Aadhaar Card
- Previous school TC (if applicable)
- Passport photos
- Address proof
GUIDELINES:
1. Be helpful, professional, and friendly
2. Provide accurate information only
3. If unsure, suggest contacting admission office
4. Offer to schedule visits when appropriate
5. Collect contact details if not provided
6. Do NOT share confidential information
7. Respond in the same language as the parent (Hindi/English)
RESPONSE FORMAT:
- Keep responses concise (2-3 paragraphs max)
- Use bullet points for lists
- Include specific numbers/dates when available
- End with a helpful next step or question`;
Intent Detection
const INTENTS = {
FEE_INFO: ['fee', 'cost', 'payment', 'फीस', 'पैसा'],
SEAT_AVAILABILITY: ['seats', 'vacancy', 'admission open', 'सीट'],
SCHEDULE_VISIT: ['visit', 'tour', 'see school', 'देखना'],
ADMISSION_PROCESS: ['process', 'how to apply', 'documents', 'प्रवेश'],
TRANSPORT: ['bus', 'transport', 'route', 'बस'],
FACILITIES: ['facilities', 'sports', 'lab', 'सुविधा'],
};
function detectIntent(message: string): string[] {
const detected = [];
for (const [intent, keywords] of Object.entries(INTENTS)) {
if (keywords.some(kw => message.toLowerCase().includes(kw))) {
detected.push(intent);
}
}
return detected.length ? detected : ['GENERAL'];
}
Suggested Actions
Based on detected intent, we provide action buttons:
| Intent | Actions |
|---|---|
| FEE_INFO | Download Fee Structure, Apply Now |
| SCHEDULE_VISIT | Schedule Visit, Request Callback |
| SEAT_AVAILABILITY | Apply Now, Check Eligibility |
| ADMISSION_PROCESS | Download Checklist, Start Application |
Chat History Management
interface ChatMessage {
role: 'user' | 'assistant';
content: string;
timestamp: Date;
intent?: string[];
}
// Store in JSONB column
await prisma.admissionInquiry.update({
where: { id: inquiryId },
data: {
aiChatHistory: [
...existingHistory,
{ role: 'user', content: message, timestamp: new Date() },
{ role: 'assistant', content: response, timestamp: new Date() },
],
},
});
Rate Limiting
@Controller('public/admission-inquiry')
export class InquiryController {
@Post(':id/chat')
@Throttle({ default: { limit: 30, ttl: 60000 } }) // 30 messages/minute
async chat(@Param('id') id: string, @Body() dto: ChatDto) {
// ...
}
}
Cost Optimization
| Strategy | Implementation |
|---|---|
| Token limits | max_tokens: 1024 |
| Context pruning | Keep last 10 messages |
| Cache responses | Redis cache for FAQs |
| Model selection | Use claude-sonnet-4-20250514 (cheaper) |
Fallback Handling
async function chat(message: string) {
try {
return await this.anthropic.messages.create({ ... });
} catch (error) {
if (error.status === 429) {
// Rate limited - use cached FAQ response
return this.getFallbackResponse(message);
}
// Log error and provide human handoff
return {
message: "I'm having trouble right now. Would you like to speak with our admission team?",
suggestedActions: [{ type: 'CALLBACK', label: 'Request Callback' }],
};
}
}
Analytics
Track chatbot performance:
interface ChatAnalytics {
inquiryId: string;
messageCount: number;
intentsDetected: string[];
sentiment: 'POSITIVE' | 'NEUTRAL' | 'NEGATIVE';
converted: boolean;
conversionTime?: number; // minutes
}
Sample Conversations
Fee Inquiry (English)
Parent: What is the fee for Class 5?
Bot: The fee structure for Class 5 (2025-26) is:
- Admission Fee: ₹25,000 (one-time)
- Tuition Fee: ₹8,000/month
- Annual Charges: ₹15,000
Total first-year cost: ₹1,31,000
Would you like me to:
[Download Fee Structure] [Apply Now]
Visit Request (Hindi)
Parent: मैं स्कूल देखना चाहता हूं
Bot: जी बिल्कुल! हमारे स्कूल में आपका स्वागत है।
स्कूल विजिट के लिए उपलब्ध समय:
- सोमवार से शुक्रवार: सुबह 9 से 11 बजे
- शनिवार: सुबह 10 से 12 बजे
क्या आप अपनी सुविधानुसार विजिट शेड्यूल करना चाहेंगे?
[विजिट शेड्यूल करें] [कॉलबैक का अनुरोध करें]