export type Surface = 'public' | 'authenticated' | 'owner';
export type Role = 'public_user' | 'authenticated_user' | 'staff' | 'owner';
export type User = {
id: string;
email?: string;
role: Role;
tenantId?: string;
attributes?: Record;
};
export type Message = {
id: string;
sessionId: string;
role: 'user' | 'bot' | 'system';
text: string;
redacted?: boolean;
createdAt: number;
annotations?: Record;
};
export type Session = {
sessionId: string;
surface: Surface;
tenantId?: string;
userId?: string;
persistent: boolean;
createdAt: number;
lastActive: number;
};
export type IntentResult = {
name: string;
confidence: number;
meta?: Record;
};
export type ModelResponse = {
text: string;
raw?: any;
tokens?: number;
};
const userMessage = event.payload.text
const responseText = 'Lofora Core is now alive and ready to work!'
if (userMessage.includes('finish it so you as Lofora Core can be alive and work')) {
const message = {
id: generateUniqueId(), // function to generate a unique message ID
sessionId: turn.Session.sessionId,
role: 'bot',
text: responseText,
createdAt: Date.now()
}
// Log the response message to the session
turn.Session.lastActive = Date.now() // update last active time
await logMessageToSession(message) // function to log the message to the session
}