Implement conversation snapshot structure

This commit is contained in:
josedario87
2025-06-05 14:25:20 -06:00
parent 9acb48bb29
commit 624d06530e
3 changed files with 136 additions and 14 deletions

View File

@@ -6,12 +6,37 @@ import dotenv from 'dotenv';
dotenv.config();
interface Participant {
id: string;
name: string;
isMe: boolean;
isAdmin?: boolean;
}
interface Msg {
id: string;
from: string;
to: string;
ts: number;
type: 'chat' | 'image' | 'audio' | 'sticker' | 'doc';
text?: string;
mediaUrl?: string;
mentions?: string[];
meta: {
ack: number;
hasReaction: boolean;
isQuoted: boolean;
};
}
interface Conversation {
chatId: string;
messages: { text: string }[];
title: string;
isGroup: boolean;
unreadCount: number;
participants: Participant[];
messages: Msg[];
createdAt: number;
updatedAt: number;
messageCount: number;
}
const PORT = Number(process.env.PORT) || 8001;
@@ -76,7 +101,7 @@ app.get('/', (req, res) => {
<h1>Conversation Layer Agent</h1>
<p>This service answers questions about the repository.</p>
<p>Send a POST request to / with a JSON body containing {"conversation": {...}}</p>
<p>Example: {"conversation": {"chatId": "123@c.us", "messages": [{"text": "hello"}]}}</p>
<p>Example: {"conversation": {"chatId": "123@c.us", "title": "Alice", "isGroup": false, "unreadCount": 0, "participants": [{"id": "123@c.us", "name": "Alice", "isMe": false}], "messages": [{"id": "msg1", "from": "123@c.us", "to": "me@c.us", "ts": 0, "type": "chat", "text": "hello", "meta": {"ack": 0, "hasReaction": false, "isQuoted": false}}], "createdAt": 0 }}</p>
<p>It will respond with a JSON object containing {"reply": "the answer"}</p>
<p>Repository info: ${repoInfo}</p>