Skip to main content

Messaging

Overview

Internal messaging between teachers, admins, and parents. Supports individual threads and broadcast messages.

Message Thread

{
id: string;
participants: [{ userId: string, role: Role }];
type: 'INDIVIDUAL' | 'GROUP';
subject?: string;
lastMessage: {
body: string;
sentAt: Date;
senderId: string;
};
}

Send Message

One-to-One

POST /messaging/send
{
"data": {
"recipientId": "uuid", // userId
"body": "Please collect your child's report card on Saturday."
}
}

Group / Broadcast

POST /school-admin/messaging/broadcast
{
"data": {
"recipientRole": "PARENT", // or list of specific userIds
"subject": "PTM Notice",
"body": "Parent-Teacher Meeting on 15th April, 2024 at 10 AM.",
"targetClassId": "uuid" // optional: only parents of this class
}
}

Thread List

GET /messaging/threads
{
"data": [
{
"id": "uuid",
"participants": [{"name": "John Doe", "role": "PARENT"}],
"type": "INDIVIDUAL",
"lastMessage": { "body": "Thank you.", "sentAt": "2024-04-01T14:30:00Z" },
"unreadCount": 2
}
]
}

Get Messages in Thread

GET /messaging/thread/:threadId/messages?page=1&limit=20

Mark as Read

POST /messaging/thread/:threadId/read

Teacher Messaging (Teachers App)

Teachers can message individual parents or broadcast to their class:

POST /teacher/messaging/send
{
"data": {
"recipientId": "parent-uuid",
"body": "Your child was absent today. Please ensure attendance."
}
}

SMS Fallback

If in-app messaging delivery fails (user not active), system falls back to SMS via SNS:

if (!userIsActive) {
await snsClient.publish({
PhoneNumber: recipientPhone,
Message: `[SyncAD] New message: ${message.body}. Check the app for full message.`,
});
}