mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
fix: chatbot services
This commit is contained in:
parent
25cbe3a035
commit
2344dfc22f
@ -23,6 +23,7 @@ export class DifyService {
|
||||
const session = await this.prismaRepository.integrationSession.create({
|
||||
data: {
|
||||
remoteJid: data.remoteJid,
|
||||
pushName: data.pushName,
|
||||
sessionId: data.remoteJid,
|
||||
status: 'opened',
|
||||
awaitUser: false,
|
||||
@ -254,7 +255,6 @@ export class DifyService {
|
||||
|
||||
const message = answer;
|
||||
|
||||
console.log('message:', answer);
|
||||
await this.sendMessageWhatsApp(instance, remoteJid, message, settings);
|
||||
|
||||
await this.prismaRepository.integrationSession.update({
|
||||
@ -401,6 +401,7 @@ export class DifyService {
|
||||
) {
|
||||
const data = await this.createNewSession(instance, {
|
||||
remoteJid,
|
||||
pushName,
|
||||
botId: dify.id,
|
||||
});
|
||||
|
||||
|
@ -22,6 +22,7 @@ export class FlowiseService {
|
||||
const session = await this.prismaRepository.integrationSession.create({
|
||||
data: {
|
||||
remoteJid: data.remoteJid,
|
||||
pushName: data.pushName,
|
||||
sessionId: data.remoteJid,
|
||||
status: 'opened',
|
||||
awaitUser: false,
|
||||
@ -41,14 +42,7 @@ export class FlowiseService {
|
||||
return content.includes('imageMessage');
|
||||
}
|
||||
|
||||
private async sendMessageToBot(
|
||||
instance: any,
|
||||
session: IntegrationSession,
|
||||
bot: Flowise,
|
||||
remoteJid: string,
|
||||
pushName: string,
|
||||
content: string,
|
||||
) {
|
||||
private async sendMessageToBot(instance: any, bot: Flowise, remoteJid: string, pushName: string, content: string) {
|
||||
const payload: any = {
|
||||
question: content,
|
||||
overrideConfig: {
|
||||
@ -188,6 +182,7 @@ export class FlowiseService {
|
||||
) {
|
||||
const data = await this.createNewSession(instance, {
|
||||
remoteJid,
|
||||
pushName,
|
||||
botId: bot.id,
|
||||
});
|
||||
|
||||
@ -195,7 +190,7 @@ export class FlowiseService {
|
||||
session = data.session;
|
||||
}
|
||||
|
||||
const message = await this.sendMessageToBot(instance, session, bot, remoteJid, pushName, content);
|
||||
const message = await this.sendMessageToBot(instance, bot, remoteJid, pushName, content);
|
||||
|
||||
await this.sendMessageWhatsApp(instance, remoteJid, session, settings, message);
|
||||
|
||||
@ -300,7 +295,7 @@ export class FlowiseService {
|
||||
return;
|
||||
}
|
||||
|
||||
const message = await this.sendMessageToBot(instance, session, bot, remoteJid, pushName, content);
|
||||
const message = await this.sendMessageToBot(instance, bot, remoteJid, pushName, content);
|
||||
|
||||
await this.sendMessageWhatsApp(instance, remoteJid, session, settings, message);
|
||||
|
||||
|
@ -22,6 +22,7 @@ export class GenericService {
|
||||
const session = await this.prismaRepository.integrationSession.create({
|
||||
data: {
|
||||
remoteJid: data.remoteJid,
|
||||
pushName: data.pushName,
|
||||
sessionId: data.remoteJid,
|
||||
status: 'opened',
|
||||
awaitUser: false,
|
||||
@ -181,6 +182,7 @@ export class GenericService {
|
||||
) {
|
||||
const data = await this.createNewSession(instance, {
|
||||
remoteJid,
|
||||
pushName,
|
||||
botId: bot.id,
|
||||
});
|
||||
|
||||
|
@ -238,6 +238,7 @@ export class OpenaiService {
|
||||
session = await this.prismaRepository.integrationSession.create({
|
||||
data: {
|
||||
remoteJid: data.remoteJid,
|
||||
pushName: data.pushName,
|
||||
sessionId: threadId,
|
||||
status: 'opened',
|
||||
awaitUser: false,
|
||||
@ -265,6 +266,7 @@ export class OpenaiService {
|
||||
) {
|
||||
const data = await this.createAssistantNewSession(instance, {
|
||||
remoteJid,
|
||||
pushName,
|
||||
openaiCredsId: openaiBot.openaiCredsId,
|
||||
botId: openaiBot.id,
|
||||
});
|
||||
@ -526,6 +528,7 @@ export class OpenaiService {
|
||||
const session = await this.prismaRepository.integrationSession.create({
|
||||
data: {
|
||||
remoteJid: data.remoteJid,
|
||||
pushName: data.pushName,
|
||||
sessionId: id,
|
||||
status: 'opened',
|
||||
awaitUser: false,
|
||||
@ -544,6 +547,7 @@ export class OpenaiService {
|
||||
private async initChatCompletionNewSession(
|
||||
instance: any,
|
||||
remoteJid: string,
|
||||
pushName: string,
|
||||
openaiBot: OpenaiBot,
|
||||
settings: OpenaiSetting,
|
||||
session: IntegrationSession,
|
||||
@ -551,6 +555,7 @@ export class OpenaiService {
|
||||
) {
|
||||
const data = await this.createChatCompletionNewSession(instance, {
|
||||
remoteJid,
|
||||
pushName,
|
||||
openaiCredsId: openaiBot.openaiCredsId,
|
||||
botId: openaiBot.id,
|
||||
});
|
||||
@ -573,6 +578,7 @@ export class OpenaiService {
|
||||
public async processOpenaiChatCompletion(
|
||||
instance: any,
|
||||
remoteJid: string,
|
||||
pushName: string,
|
||||
openaiBot: OpenaiBot,
|
||||
session: IntegrationSession,
|
||||
settings: OpenaiSetting,
|
||||
@ -610,13 +616,13 @@ export class OpenaiService {
|
||||
});
|
||||
}
|
||||
|
||||
await this.initChatCompletionNewSession(instance, remoteJid, openaiBot, settings, session, content);
|
||||
await this.initChatCompletionNewSession(instance, remoteJid, pushName, openaiBot, settings, session, content);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!session) {
|
||||
await this.initChatCompletionNewSession(instance, remoteJid, openaiBot, settings, session, content);
|
||||
await this.initChatCompletionNewSession(instance, remoteJid, pushName, openaiBot, settings, session, content);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ export class TypebotService {
|
||||
listeningFromMe: listeningFromMe,
|
||||
remoteJid: remoteJid,
|
||||
pushName: msg.pushName,
|
||||
typebotId: findTypebot.id,
|
||||
botId: findTypebot.id,
|
||||
});
|
||||
|
||||
if (data?.session) {
|
||||
|
Loading…
Reference in New Issue
Block a user