33 lines
873 B
JavaScript
33 lines
873 B
JavaScript
const clinicAgent = require('./clinicAgent');
|
|
|
|
class BotLogic {
|
|
constructor() {
|
|
this.states = {}; // Context storage
|
|
}
|
|
|
|
setRescheduleOffer(patientId, offerData) {
|
|
this.states[`${patientId}_offer`] = offerData;
|
|
}
|
|
|
|
async handleMessage(patientId, message) {
|
|
const context = this.states[patientId] || {};
|
|
|
|
// Delegate to the Agent
|
|
const response = await clinicAgent.processMessage(patientId, message, context);
|
|
|
|
// Update local context/state based on agent response
|
|
if (response.nextStep) {
|
|
this.states[patientId] = { lastStep: response.nextStep };
|
|
} else {
|
|
// Reset or keep context as needed
|
|
}
|
|
|
|
return {
|
|
reply: response.reply,
|
|
buttons: response.buttons || []
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = new BotLogic();
|