mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 15:14:49 -06:00
fix: Fixed bot fallback not working on integrations
This commit is contained in:
parent
2d732c8071
commit
d7ddb99fb0
@ -28,6 +28,7 @@
|
||||
* Fixed getBase64FromMediaMessage with convertToMp4
|
||||
* Fixed bug when send message when don't have mentionsEveryOne on payload
|
||||
* Does not search message without chatwoot Message Id for reply
|
||||
* Fixed bot fallback not working on integrations
|
||||
|
||||
# 2.1.1 (2024-09-22 10:31)
|
||||
|
||||
|
@ -726,7 +726,7 @@ export class DifyController extends ChatbotController implements ChatbotControll
|
||||
|
||||
const content = getConversationMessage(msg);
|
||||
|
||||
const findBot = (await this.findBotTrigger(
|
||||
let findBot = (await this.findBotTrigger(
|
||||
this.botRepository,
|
||||
this.settingsRepository,
|
||||
content,
|
||||
@ -734,7 +734,25 @@ export class DifyController extends ChatbotController implements ChatbotControll
|
||||
session,
|
||||
)) as DifyModel;
|
||||
|
||||
if (!findBot) return;
|
||||
if (!findBot) {
|
||||
const fallback = await this.settingsRepository.findFirst({
|
||||
where: {
|
||||
instanceId: instance.instanceId,
|
||||
},
|
||||
});
|
||||
|
||||
if (fallback?.difyIdFallback) {
|
||||
const findFallback = await this.botRepository.findFirst({
|
||||
where: {
|
||||
id: fallback.difyIdFallback,
|
||||
},
|
||||
});
|
||||
|
||||
findBot = findFallback;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let expire = findBot?.expire;
|
||||
let keywordFinish = findBot?.keywordFinish;
|
||||
|
@ -698,7 +698,7 @@ export class EvolutionBotController extends ChatbotController implements Chatbot
|
||||
|
||||
const content = getConversationMessage(msg);
|
||||
|
||||
const findBot = (await this.findBotTrigger(
|
||||
let findBot = (await this.findBotTrigger(
|
||||
this.botRepository,
|
||||
this.settingsRepository,
|
||||
content,
|
||||
@ -706,7 +706,25 @@ export class EvolutionBotController extends ChatbotController implements Chatbot
|
||||
session,
|
||||
)) as EvolutionBot;
|
||||
|
||||
if (!findBot) return;
|
||||
if (!findBot) {
|
||||
const fallback = await this.settingsRepository.findFirst({
|
||||
where: {
|
||||
instanceId: instance.instanceId,
|
||||
},
|
||||
});
|
||||
|
||||
if (fallback?.botIdFallback) {
|
||||
const findFallback = await this.botRepository.findFirst({
|
||||
where: {
|
||||
id: fallback.botIdFallback,
|
||||
},
|
||||
});
|
||||
|
||||
findBot = findFallback;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let expire = findBot?.expire;
|
||||
let keywordFinish = findBot?.keywordFinish;
|
||||
|
@ -698,7 +698,7 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
|
||||
|
||||
const content = getConversationMessage(msg);
|
||||
|
||||
const findBot = (await this.findBotTrigger(
|
||||
let findBot = (await this.findBotTrigger(
|
||||
this.botRepository,
|
||||
this.settingsRepository,
|
||||
content,
|
||||
@ -706,7 +706,25 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
|
||||
session,
|
||||
)) as Flowise;
|
||||
|
||||
if (!findBot) return;
|
||||
if (!findBot) {
|
||||
const fallback = await this.settingsRepository.findFirst({
|
||||
where: {
|
||||
instanceId: instance.instanceId,
|
||||
},
|
||||
});
|
||||
|
||||
if (fallback?.flowiseIdFallback) {
|
||||
const findFallback = await this.botRepository.findFirst({
|
||||
where: {
|
||||
id: fallback.flowiseIdFallback,
|
||||
},
|
||||
});
|
||||
|
||||
findBot = findFallback;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let expire = findBot?.expire;
|
||||
let keywordFinish = findBot?.keywordFinish;
|
||||
|
@ -935,7 +935,7 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
|
||||
|
||||
const content = getConversationMessage(msg);
|
||||
|
||||
const findBot = (await this.findBotTrigger(
|
||||
let findBot = (await this.findBotTrigger(
|
||||
this.botRepository,
|
||||
this.settingsRepository,
|
||||
content,
|
||||
@ -943,7 +943,25 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
|
||||
session,
|
||||
)) as OpenaiBot;
|
||||
|
||||
if (!findBot) return;
|
||||
if (!findBot) {
|
||||
const fallback = await this.settingsRepository.findFirst({
|
||||
where: {
|
||||
instanceId: instance.instanceId,
|
||||
},
|
||||
});
|
||||
|
||||
if (fallback?.openaiIdFallback) {
|
||||
const findFallback = await this.botRepository.findFirst({
|
||||
where: {
|
||||
id: fallback.openaiIdFallback,
|
||||
},
|
||||
});
|
||||
|
||||
findBot = findFallback;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let expire = findBot?.expire;
|
||||
let keywordFinish = findBot?.keywordFinish;
|
||||
|
@ -985,7 +985,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
||||
|
||||
const content = getConversationMessage(msg);
|
||||
|
||||
const findBot = (await this.findBotTrigger(
|
||||
let findBot = (await this.findBotTrigger(
|
||||
this.botRepository,
|
||||
this.settingsRepository,
|
||||
content,
|
||||
@ -993,7 +993,25 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
||||
session,
|
||||
)) as TypebotModel;
|
||||
|
||||
if (!findBot) return;
|
||||
if (!findBot) {
|
||||
const fallback = await this.settingsRepository.findFirst({
|
||||
where: {
|
||||
instanceId: instance.instanceId,
|
||||
},
|
||||
});
|
||||
|
||||
if (fallback?.typebotIdFallback) {
|
||||
const findFallback = await this.botRepository.findFirst({
|
||||
where: {
|
||||
id: fallback.typebotIdFallback,
|
||||
},
|
||||
});
|
||||
|
||||
findBot = findFallback;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const settings = await this.prismaRepository.typebotSetting.findFirst({
|
||||
where: {
|
||||
|
@ -129,21 +129,5 @@ export const findBotByTrigger = async (
|
||||
|
||||
if (findTriggerContains) return findTriggerContains;
|
||||
|
||||
const fallback = await settingsRepository.findFirst({
|
||||
where: {
|
||||
instanceId: instanceId,
|
||||
},
|
||||
});
|
||||
|
||||
if (fallback?.openaiIdFallback) {
|
||||
const findFallback = await botRepository.findFirst({
|
||||
where: {
|
||||
id: fallback.openaiIdFallback,
|
||||
},
|
||||
});
|
||||
|
||||
if (findFallback) return findFallback;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user