mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-20 04:12:23 -06:00
fix: integrate Typebot status change events for webhook in chatbot controller and service
This commit is contained in:
@@ -9,6 +9,7 @@ import { getConversationMessage } from '@utils/getConversationMessage';
|
||||
|
||||
import { BaseChatbotDto } from './base-chatbot.dto';
|
||||
import { ChatbotController, ChatbotControllerInterface, EmitData } from './chatbot.controller';
|
||||
import { Events } from '@api/types/wa.types';
|
||||
|
||||
// Common settings interface for all chatbot integrations
|
||||
export interface ChatbotSettings {
|
||||
@@ -58,7 +59,7 @@ export abstract class BaseChatbotController<BotType = any, BotData extends BaseC
|
||||
settingsRepository: any;
|
||||
sessionRepository: any;
|
||||
userMessageDebounce: { [key: string]: { message: string; timeoutId: NodeJS.Timeout } } = {};
|
||||
|
||||
|
||||
// Name of the integration, to be set by the derived class
|
||||
protected abstract readonly integrationName: string;
|
||||
|
||||
@@ -445,7 +446,17 @@ export abstract class BaseChatbotController<BotType = any, BotData extends BaseC
|
||||
});
|
||||
|
||||
const remoteJid = data.remoteJid;
|
||||
const status = data.status;
|
||||
const status = data.status;
|
||||
const session = await this.getSession(remoteJid, instance);
|
||||
|
||||
if (this.integrationName === 'Typebot') {
|
||||
const typebotData = {
|
||||
remoteJid: remoteJid,
|
||||
status: status,
|
||||
session
|
||||
};
|
||||
this.waMonitor.waInstances[instance.instanceName].sendDataWebhook(Events.TYPEBOT_CHANGE_STATUS, typebotData);
|
||||
}
|
||||
|
||||
if (status === 'delete') {
|
||||
await this.sessionRepository.deleteMany({
|
||||
@@ -496,7 +507,7 @@ export abstract class BaseChatbotController<BotType = any, BotData extends BaseC
|
||||
status: status,
|
||||
session,
|
||||
};
|
||||
|
||||
|
||||
return { bot: { ...instance, bot: botData } };
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -867,6 +878,16 @@ export abstract class BaseChatbotController<BotType = any, BotData extends BaseC
|
||||
status: 'paused',
|
||||
},
|
||||
});
|
||||
|
||||
if (this.integrationName === 'Typebot') {
|
||||
const typebotData = {
|
||||
remoteJid: remoteJid,
|
||||
status: 'paused',
|
||||
session,
|
||||
};
|
||||
this.waMonitor.waInstances[instance.instanceName].sendDataWebhook(Events.TYPEBOT_CHANGE_STATUS, typebotData);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user