http://localhost:3000/api
Admin endpoints require JWT authentication. Include token in Authorization header:
Authorization: Bearer <token>
Process user message and get bot response.
Request Body:
{
"userMessage": "Hello, tell me about your products",
"userId": "optional-user-id",
"sessionId": "optional-session-id"
}Response:
{
"success": true,
"data": {
"botReply": "🛵 **Our Products**\n\nSMG Electric Scooters offers...",
"intentName": "products",
"confidenceScore": 0.9,
"conversationId": "65a1b2c3d4e5f6g7h8i9j0k1",
"sessionId": "session_1234567890"
}
}Get conversation history for a session.
Query Parameters:
limit(optional): Number of messages to return (default: 50)
Response:
{
"success": true,
"count": 10,
"data": [
{
"message": "Hello",
"intent": "greeting",
"response": "Hello! 👋 Welcome...",
"createdAt": "2024-01-01T12:00:00.000Z"
}
]
}Create a new lead.
Request Body:
{
"name": "John Doe",
"phone": "9876543210",
"email": "john@example.com",
"interest": "product",
"city": "Mumbai",
"message": "Interested in electric scooter"
}Interest Types: product, internship, scholarship, dealership, other
Response:
{
"success": true,
"message": "Lead created successfully",
"data": {
"_id": "65a1b2c3d4e5f6g7h8i9j0k1",
"name": "John Doe",
"phone": "9876543210",
"email": "john@example.com",
"interest": "product",
"city": "Mumbai",
"status": "new",
"createdAt": "2024-01-01T12:00:00.000Z"
}
}Get all SMG programs (Internships, Scholarships, Industrial Visits).
Response:
{
"success": true,
"count": 3,
"data": {
"smgNirmaan": {
"name": "SMG Nirmaan Programme",
"type": "internship",
"duration": "3-6 months",
"eligibility": [...],
"benefits": [...]
},
"smgScholarships": {...},
"smgBhraman": {...}
}
}Get specific program by type.
Types: internship, scholarship, industrial-visit
Admin login.
Request Body:
{
"email": "admin@smg.com",
"password": "admin123"
}Response:
{
"success": true,
"message": "Login successful",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"admin": {
"id": "65a1b2c3d4e5f6g7h8i9j0k1",
"email": "admin@smg.com",
"name": "SMG Admin",
"role": "admin"
}
}
}Get admin profile.
Headers:
Authorization: Bearer <token>
Get all conversations with filters.
Query Parameters:
intent(optional): Filter by intentuserId(optional): Filter by user IDsessionId(optional): Filter by session IDstartDate(optional): Start date (ISO format)endDate(optional): End date (ISO format)page(optional): Page number (default: 1)limit(optional): Items per page (default: 50)
Response:
{
"success": true,
"count": 25,
"total": 150,
"page": 1,
"pages": 6,
"intentStatistics": [
{
"_id": "products",
"count": 45,
"avgConfidence": 0.87
}
],
"data": [...]
}Get all leads with filters.
Query Parameters:
interest(optional): Filter by interest typestatus(optional): Filter by statusstartDate(optional): Start dateendDate(optional): End datepage(optional): Page numberlimit(optional): Items per page
Response:
{
"success": true,
"count": 20,
"total": 100,
"page": 1,
"pages": 5,
"statistics": {
"byInterest": [...],
"byStatus": [...]
},
"data": [...]
}Get single lead by ID.
Update lead status.
Request Body:
{
"status": "contacted"
}Status Values: new, contacted, qualified, converted, closed
Get analytics dashboard data.
Query Parameters:
startDate(optional): Start dateendDate(optional): End date
Response:
{
"success": true,
"data": {
"conversations": {
"total": 500,
"intentDistribution": [...]
},
"leads": {
"total": 150,
"byInterest": [...],
"byStatus": [...]
},
"dailyActivity": [...]
}
}All errors follow this format:
{
"success": false,
"message": "Error message here"
}Status Codes:
400- Bad Request (validation errors)401- Unauthorized (invalid/missing token)403- Forbidden (inactive account)404- Not Found409- Conflict (duplicate entry)500- Internal Server Error
The chatbot recognizes the following intents:
greeting- Greetings and salutationsabout_smg- About SMG companyproducts- Product informationservices- Services and supportinternships- SMG Nirmaan Programmescholarships- SMG Scholarshipsindustrial_visit- SMG Bhraman visitsfinancing_insurance- Financing and insurancecontact_social- Contact and social mediaunknown- Unrecognized intent
// Chat API
const response = await fetch('http://localhost:3000/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
userMessage: 'Tell me about internships'
})
});
const data = await response.json();
// Admin Login
const loginResponse = await fetch('http://localhost:3000/api/admin/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'admin@smg.com',
password: 'admin123'
})
});
const { data: { token } } = await loginResponse.json();
// Get Conversations (with auth)
const convResponse = await fetch('http://localhost:3000/api/admin/conversations?intent=products', {
headers: {
'Authorization': `Bearer ${token}`
}
});# Chat
curl -X POST http://localhost:3000/api/chat \
-H "Content-Type: application/json" \
-d '{"userMessage": "Hello"}'
# Admin Login
curl -X POST http://localhost:3000/api/admin/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@smg.com", "password": "admin123"}'
# Get Conversations
curl http://localhost:3000/api/admin/conversations \
-H "Authorization: Bearer <token>"