curaflow/backend/agents/FollowUpAgent.js

37 lines
1.4 KiB
JavaScript

const BaseAgent = require('./BaseAgent');
class FollowUpAgent extends BaseAgent {
constructor() {
super('FollowUpAgent');
this.responseMocks = {
'default': JSON.stringify({ message: "Hello! It has been a few days since your visit. How are you feeling today?" })
};
}
async execute(config, payload) {
const { patientName, phone, daysSinceVisit, context } = payload;
console.log(`[FollowUpAgent] Generating follow-up for ${patientName} (${daysSinceVisit} days post-visit)`);
const prompt = `
Draft a friendly, empathetic WhatsApp follow-up message for patient ${patientName}.
Context of last visit: "${context}"
Return a JSON object: { "message": "..." }
`;
const llmResponse = await this.mockLLMCall(prompt, this.responseMocks);
try {
const result = JSON.parse(llmResponse);
console.log(`[FollowUpAgent] Message to send: ${result.message}`);
// Here we would integrate with WhatsApp API to actually send it
return result;
} catch (e) {
console.error('[FollowUpAgent] Failed to parse LLM response', e);
return { message: "Hi! Just checking in on your health. Let us know if you need anything." };
}
}
}
module.exports = new FollowUpAgent();