refactor: evolution bot

This commit is contained in:
Davidson Gomes 2024-08-25 10:22:22 -03:00
parent 8b7ff37261
commit d776770d09
22 changed files with 509 additions and 189 deletions

View File

@ -204,6 +204,7 @@ S3_USE_SSL=true
# S3_PORT=443 # S3_PORT=443
# S3_ENDPOINT=s3.domain.com # S3_ENDPOINT=s3.domain.com
# S3_USE_SSL=true # S3_USE_SSL=true
# S3_REGION=eu-south
# Define a global apikey to access all instances. # Define a global apikey to access all instances.
# OBS: This key must be inserted in the request header to create an instance. # OBS: This key must be inserted in the request header to create an instance.

View File

@ -4,7 +4,7 @@
* Improved layout manager * Improved layout manager
* Translation in manager: English, Portuguese, Spanish and French * Translation in manager: English, Portuguese, Spanish and French
* Generic Bot Integration * Evolution Bot Integration
* Option to disable chatwoot bot contact with CHATWOOT_BOT_CONTACT * Option to disable chatwoot bot contact with CHATWOOT_BOT_CONTACT
* Added flowise integration * Added flowise integration
* Added evolution channel on instance create * Added evolution channel on instance create

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
<link rel="icon" type="image/png" href="/assets/images/evolution-logo.png" /> <link rel="icon" type="image/png" href="/assets/images/evolution-logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Evolution Manager</title> <title>Evolution Manager</title>
<script type="module" crossorigin src="/assets/index-PmD1d8Kz.js"></script> <script type="module" crossorigin src="/assets/index-Vw61SpAX.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DvXIV-Pi.css"> <link rel="stylesheet" crossorigin href="/assets/index-DvXIV-Pi.css">
</head> </head>
<body> <body>

View File

@ -0,0 +1,219 @@
/*
Warnings:
- You are about to alter the column `createdAt` on the `Chat` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Chat` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Chatwoot` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Chatwoot` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Contact` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Contact` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Dify` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Dify` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `DifySetting` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `DifySetting` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Flowise` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Flowise` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `FlowiseSetting` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `FlowiseSetting` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `disconnectionAt` on the `Instance` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Instance` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Instance` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `IntegrationSession` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `IntegrationSession` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Label` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Label` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Media` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `OpenaiBot` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `OpenaiBot` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `OpenaiCreds` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `OpenaiCreds` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `OpenaiSetting` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `OpenaiSetting` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Proxy` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Proxy` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Rabbitmq` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Rabbitmq` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Session` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Setting` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Setting` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Sqs` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Sqs` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Template` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Template` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Typebot` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Typebot` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `TypebotSetting` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `TypebotSetting` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Webhook` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Webhook` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `createdAt` on the `Websocket` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to alter the column `updatedAt` on the `Websocket` table. The data in that column could be lost. The data in that column will be cast from `Timestamp(0)` to `Timestamp`.
- You are about to drop the `GenericBot` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `GenericSetting` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE `GenericBot` DROP FOREIGN KEY `GenericBot_instanceId_fkey`;
-- DropForeignKey
ALTER TABLE `GenericSetting` DROP FOREIGN KEY `GenericSetting_botIdFallback_fkey`;
-- DropForeignKey
ALTER TABLE `GenericSetting` DROP FOREIGN KEY `GenericSetting_instanceId_fkey`;
-- AlterTable
ALTER TABLE `Chat` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NULL;
-- AlterTable
ALTER TABLE `Chatwoot` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Contact` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NULL;
-- AlterTable
ALTER TABLE `Dify` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `DifySetting` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Flowise` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `FlowiseSetting` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Instance` MODIFY `disconnectionAt` TIMESTAMP NULL,
MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NULL;
-- AlterTable
ALTER TABLE `IntegrationSession` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Label` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Media` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE `OpenaiBot` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `OpenaiCreds` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `OpenaiSetting` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Proxy` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Rabbitmq` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Session` MODIFY `createdAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE `Setting` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Sqs` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Template` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Typebot` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NULL;
-- AlterTable
ALTER TABLE `TypebotSetting` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Webhook` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- AlterTable
ALTER TABLE `Websocket` MODIFY `createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
MODIFY `updatedAt` TIMESTAMP NOT NULL;
-- DropTable
DROP TABLE `GenericBot`;
-- DropTable
DROP TABLE `GenericSetting`;
-- CreateTable
CREATE TABLE `EvolutionBot` (
`id` VARCHAR(191) NOT NULL,
`enabled` BOOLEAN NOT NULL DEFAULT true,
`description` VARCHAR(255) NULL,
`apiUrl` VARCHAR(255) NULL,
`apiKey` VARCHAR(255) NULL,
`expire` INTEGER NULL DEFAULT 0,
`keywordFinish` VARCHAR(100) NULL,
`delayMessage` INTEGER NULL,
`unknownMessage` VARCHAR(100) NULL,
`listeningFromMe` BOOLEAN NULL DEFAULT false,
`stopBotFromMe` BOOLEAN NULL DEFAULT false,
`keepOpen` BOOLEAN NULL DEFAULT false,
`debounceTime` INTEGER NULL,
`ignoreJids` JSON NULL,
`triggerType` ENUM('all', 'keyword', 'none', 'advanced') NULL,
`triggerOperator` ENUM('contains', 'equals', 'startsWith', 'endsWith', 'regex') NULL,
`triggerValue` VARCHAR(191) NULL,
`createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` TIMESTAMP NOT NULL,
`instanceId` VARCHAR(191) NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `EvolutionBotSetting` (
`id` VARCHAR(191) NOT NULL,
`expire` INTEGER NULL DEFAULT 0,
`keywordFinish` VARCHAR(100) NULL,
`delayMessage` INTEGER NULL,
`unknownMessage` VARCHAR(100) NULL,
`listeningFromMe` BOOLEAN NULL DEFAULT false,
`stopBotFromMe` BOOLEAN NULL DEFAULT false,
`keepOpen` BOOLEAN NULL DEFAULT false,
`debounceTime` INTEGER NULL,
`ignoreJids` JSON NULL,
`createdAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` TIMESTAMP NOT NULL,
`botIdFallback` VARCHAR(100) NULL,
`instanceId` VARCHAR(191) NOT NULL,
UNIQUE INDEX `EvolutionBotSetting_instanceId_key`(`instanceId`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `EvolutionBot` ADD CONSTRAINT `EvolutionBot_instanceId_fkey` FOREIGN KEY (`instanceId`) REFERENCES `Instance`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `EvolutionBotSetting` ADD CONSTRAINT `EvolutionBotSetting_botIdFallback_fkey` FOREIGN KEY (`botIdFallback`) REFERENCES `EvolutionBot`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `EvolutionBotSetting` ADD CONSTRAINT `EvolutionBotSetting_instanceId_fkey` FOREIGN KEY (`instanceId`) REFERENCES `Instance`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -100,8 +100,8 @@ model Instance {
Dify Dify[] Dify Dify[]
DifySetting DifySetting? DifySetting DifySetting?
integrationSessions IntegrationSession[] integrationSessions IntegrationSession[]
GenericBot GenericBot[] EvolutionBot EvolutionBot[]
GenericSetting GenericSetting? EvolutionBotSetting EvolutionBotSetting?
Flowise Flowise[] Flowise Flowise[]
FlowiseSetting FlowiseSetting? FlowiseSetting FlowiseSetting?
} }
@ -486,7 +486,7 @@ model DifySetting {
instanceId String @unique instanceId String @unique
} }
model GenericBot { model EvolutionBot {
id String @id @default(cuid()) id String @id @default(cuid())
enabled Boolean @default(true) enabled Boolean @default(true)
description String? @db.VarChar(255) description String? @db.VarChar(255)
@ -508,10 +508,10 @@ model GenericBot {
updatedAt DateTime @updatedAt @db.Timestamp updatedAt DateTime @updatedAt @db.Timestamp
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade) Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId String instanceId String
GenericSetting GenericSetting[] EvolutionBotSetting EvolutionBotSetting[]
} }
model GenericSetting { model EvolutionBotSetting {
id String @id @default(cuid()) id String @id @default(cuid())
expire Int? @default(0) @db.Int expire Int? @default(0) @db.Int
keywordFinish String? @db.VarChar(100) keywordFinish String? @db.VarChar(100)
@ -524,7 +524,7 @@ model GenericSetting {
ignoreJids Json? ignoreJids Json?
createdAt DateTime? @default(dbgenerated("CURRENT_TIMESTAMP")) @db.Timestamp createdAt DateTime? @default(dbgenerated("CURRENT_TIMESTAMP")) @db.Timestamp
updatedAt DateTime @updatedAt @db.Timestamp updatedAt DateTime @updatedAt @db.Timestamp
Fallback GenericBot? @relation(fields: [botIdFallback], references: [id]) Fallback EvolutionBot? @relation(fields: [botIdFallback], references: [id])
botIdFallback String? @db.VarChar(100) botIdFallback String? @db.VarChar(100)
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade) Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId String @unique instanceId String @unique

View File

@ -0,0 +1,79 @@
/*
Warnings:
- You are about to drop the `GenericBot` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `GenericSetting` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "GenericBot" DROP CONSTRAINT "GenericBot_instanceId_fkey";
-- DropForeignKey
ALTER TABLE "GenericSetting" DROP CONSTRAINT "GenericSetting_botIdFallback_fkey";
-- DropForeignKey
ALTER TABLE "GenericSetting" DROP CONSTRAINT "GenericSetting_instanceId_fkey";
-- DropTable
DROP TABLE "GenericBot";
-- DropTable
DROP TABLE "GenericSetting";
-- CreateTable
CREATE TABLE "EvolutionBot" (
"id" TEXT NOT NULL,
"enabled" BOOLEAN NOT NULL DEFAULT true,
"description" VARCHAR(255),
"apiUrl" VARCHAR(255),
"apiKey" VARCHAR(255),
"expire" INTEGER DEFAULT 0,
"keywordFinish" VARCHAR(100),
"delayMessage" INTEGER,
"unknownMessage" VARCHAR(100),
"listeningFromMe" BOOLEAN DEFAULT false,
"stopBotFromMe" BOOLEAN DEFAULT false,
"keepOpen" BOOLEAN DEFAULT false,
"debounceTime" INTEGER,
"ignoreJids" JSONB,
"triggerType" "TriggerType",
"triggerOperator" "TriggerOperator",
"triggerValue" TEXT,
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP NOT NULL,
"instanceId" TEXT NOT NULL,
CONSTRAINT "EvolutionBot_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "EvolutionBotSetting" (
"id" TEXT NOT NULL,
"expire" INTEGER DEFAULT 0,
"keywordFinish" VARCHAR(100),
"delayMessage" INTEGER,
"unknownMessage" VARCHAR(100),
"listeningFromMe" BOOLEAN DEFAULT false,
"stopBotFromMe" BOOLEAN DEFAULT false,
"keepOpen" BOOLEAN DEFAULT false,
"debounceTime" INTEGER,
"ignoreJids" JSONB,
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP NOT NULL,
"botIdFallback" VARCHAR(100),
"instanceId" TEXT NOT NULL,
CONSTRAINT "EvolutionBotSetting_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "EvolutionBotSetting_instanceId_key" ON "EvolutionBotSetting"("instanceId");
-- AddForeignKey
ALTER TABLE "EvolutionBot" ADD CONSTRAINT "EvolutionBot_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "Instance"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "EvolutionBotSetting" ADD CONSTRAINT "EvolutionBotSetting_botIdFallback_fkey" FOREIGN KEY ("botIdFallback") REFERENCES "EvolutionBot"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "EvolutionBotSetting" ADD CONSTRAINT "EvolutionBotSetting_instanceId_fkey" FOREIGN KEY ("instanceId") REFERENCES "Instance"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -100,8 +100,8 @@ model Instance {
Dify Dify[] Dify Dify[]
DifySetting DifySetting? DifySetting DifySetting?
integrationSessions IntegrationSession[] integrationSessions IntegrationSession[]
GenericBot GenericBot[] EvolutionBot EvolutionBot[]
GenericSetting GenericSetting? EvolutionBotSetting EvolutionBotSetting?
Flowise Flowise[] Flowise Flowise[]
FlowiseSetting FlowiseSetting? FlowiseSetting FlowiseSetting?
} }
@ -487,7 +487,7 @@ model DifySetting {
instanceId String @unique instanceId String @unique
} }
model GenericBot { model EvolutionBot {
id String @id @default(cuid()) id String @id @default(cuid())
enabled Boolean @default(true) @db.Boolean enabled Boolean @default(true) @db.Boolean
description String? @db.VarChar(255) description String? @db.VarChar(255)
@ -509,10 +509,10 @@ model GenericBot {
updatedAt DateTime @updatedAt @db.Timestamp updatedAt DateTime @updatedAt @db.Timestamp
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade) Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId String instanceId String
GenericSetting GenericSetting[] EvolutionBotSetting EvolutionBotSetting[]
} }
model GenericSetting { model EvolutionBotSetting {
id String @id @default(cuid()) id String @id @default(cuid())
expire Int? @default(0) @db.Integer expire Int? @default(0) @db.Integer
keywordFinish String? @db.VarChar(100) keywordFinish String? @db.VarChar(100)
@ -525,7 +525,7 @@ model GenericSetting {
ignoreJids Json? ignoreJids Json?
createdAt DateTime? @default(now()) @db.Timestamp createdAt DateTime? @default(now()) @db.Timestamp
updatedAt DateTime @updatedAt @db.Timestamp updatedAt DateTime @updatedAt @db.Timestamp
Fallback GenericBot? @relation(fields: [botIdFallback], references: [id]) Fallback EvolutionBot? @relation(fields: [botIdFallback], references: [id])
botIdFallback String? @db.VarChar(100) botIdFallback String? @db.VarChar(100)
Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade) Instance Instance @relation(fields: [instanceId], references: [id], onDelete: Cascade)
instanceId String @unique instanceId String @unique

View File

@ -2,8 +2,8 @@ import { InstanceDto } from '@api/dto/instance.dto';
import { PrismaRepository } from '@api/repository/repository.service'; import { PrismaRepository } from '@api/repository/repository.service';
import { import {
difyController, difyController,
evolutionBotController,
flowiseController, flowiseController,
genericController,
openaiController, openaiController,
typebotController, typebotController,
} from '@api/server.module'; } from '@api/server.module';
@ -89,7 +89,7 @@ export class ChatbotController {
pushName, pushName,
isIntegration, isIntegration,
}; };
await genericController.emit(emitData); await evolutionBotController.emit(emitData);
await typebotController.emit(emitData); await typebotController.emit(emitData);

View File

@ -4,8 +4,8 @@ import { OpenaiRouter } from '@api/integrations/chatbot/openai/routes/openai.rou
import { TypebotRouter } from '@api/integrations/chatbot/typebot/routes/typebot.router'; import { TypebotRouter } from '@api/integrations/chatbot/typebot/routes/typebot.router';
import { Router } from 'express'; import { Router } from 'express';
import { EvolutionBotRouter } from './evolutionBot/routes/evolutionBot.router';
import { FlowiseRouter } from './flowise/routes/flowise.router'; import { FlowiseRouter } from './flowise/routes/flowise.router';
import { GenericRouter } from './generic/routes/generic.router';
export class ChatbotRouter { export class ChatbotRouter {
public readonly router: Router; public readonly router: Router;
@ -13,7 +13,7 @@ export class ChatbotRouter {
constructor(...guards: any[]) { constructor(...guards: any[]) {
this.router = Router(); this.router = Router();
this.router.use('/generic', new GenericRouter(...guards).router); this.router.use('/evolutionBot', new EvolutionBotRouter(...guards).router);
this.router.use('/chatwoot', new ChatwootRouter(...guards).router); this.router.use('/chatwoot', new ChatwootRouter(...guards).router);
this.router.use('/typebot', new TypebotRouter(...guards).router); this.router.use('/typebot', new TypebotRouter(...guards).router);
this.router.use('/openai', new OpenaiRouter(...guards).router); this.router.use('/openai', new OpenaiRouter(...guards).router);

View File

@ -1,6 +1,6 @@
export * from '@api/integrations/chatbot/chatwoot/validate/chatwoot.schema'; export * from '@api/integrations/chatbot/chatwoot/validate/chatwoot.schema';
export * from '@api/integrations/chatbot/dify/validate/dify.schema'; export * from '@api/integrations/chatbot/dify/validate/dify.schema';
export * from '@api/integrations/chatbot/evolutionBot/validate/evolutionBot.schema';
export * from '@api/integrations/chatbot/flowise/validate/flowise.schema'; export * from '@api/integrations/chatbot/flowise/validate/flowise.schema';
export * from '@api/integrations/chatbot/generic/validate/generic.schema';
export * from '@api/integrations/chatbot/openai/validate/openai.schema'; export * from '@api/integrations/chatbot/openai/validate/openai.schema';
export * from '@api/integrations/chatbot/typebot/validate/typebot.schema'; export * from '@api/integrations/chatbot/typebot/validate/typebot.schema';

View File

@ -771,6 +771,10 @@ export class DifyController extends ChatbotController implements ChatbotControll
return; return;
} }
if (session && !session.awaitUser) {
return;
}
if (debounceTime && debounceTime > 0) { if (debounceTime && debounceTime > 0) {
this.processDebounce(this.userMessageDebounce, content, remoteJid, debounceTime, async (debouncedContent) => { this.processDebounce(this.userMessageDebounce, content, remoteJid, debounceTime, async (debouncedContent) => {
await this.difyService.processDify( await this.difyService.processDify(

View File

@ -3,27 +3,27 @@ import { InstanceDto } from '@api/dto/instance.dto';
import { PrismaRepository } from '@api/repository/repository.service'; import { PrismaRepository } from '@api/repository/repository.service';
import { WAMonitoringService } from '@api/services/monitor.service'; import { WAMonitoringService } from '@api/services/monitor.service';
import { Logger } from '@config/logger.config'; import { Logger } from '@config/logger.config';
import { GenericBot } from '@prisma/client'; import { EvolutionBot } from '@prisma/client';
import { getConversationMessage } from '@utils/getConversationMessage'; import { getConversationMessage } from '@utils/getConversationMessage';
import { ChatbotController, ChatbotControllerInterface, EmitData } from '../../chatbot.controller'; import { ChatbotController, ChatbotControllerInterface, EmitData } from '../../chatbot.controller';
import { GenericBotDto } from '../dto/generic.dto'; import { EvolutionBotDto } from '../dto/evolutionBot.dto';
import { GenericService } from '../services/generic.service'; import { EvolutionBotService } from '../services/evolutionBot.service';
export class GenericController extends ChatbotController implements ChatbotControllerInterface { export class EvolutionBotController extends ChatbotController implements ChatbotControllerInterface {
constructor( constructor(
private readonly genericService: GenericService, private readonly evolutionBotService: EvolutionBotService,
prismaRepository: PrismaRepository, prismaRepository: PrismaRepository,
waMonitor: WAMonitoringService, waMonitor: WAMonitoringService,
) { ) {
super(prismaRepository, waMonitor); super(prismaRepository, waMonitor);
this.botRepository = this.prismaRepository.genericBot; this.botRepository = this.prismaRepository.evolutionBot;
this.settingsRepository = this.prismaRepository.genericSetting; this.settingsRepository = this.prismaRepository.evolutionBotSetting;
this.sessionRepository = this.prismaRepository.integrationSession; this.sessionRepository = this.prismaRepository.integrationSession;
} }
public readonly logger = new Logger(GenericController.name); public readonly logger = new Logger(EvolutionBotController.name);
integrationEnabled: boolean; integrationEnabled: boolean;
botRepository: any; botRepository: any;
@ -32,7 +32,7 @@ export class GenericController extends ChatbotController implements ChatbotContr
userMessageDebounce: { [key: string]: { message: string; timeoutId: NodeJS.Timeout } } = {}; userMessageDebounce: { [key: string]: { message: string; timeoutId: NodeJS.Timeout } } = {};
// Bots // Bots
public async createBot(instance: InstanceDto, data: GenericBotDto) { public async createBot(instance: InstanceDto, data: EvolutionBotDto) {
const instanceId = await this.prismaRepository.instance const instanceId = await this.prismaRepository.instance
.findFirst({ .findFirst({
where: { where: {
@ -220,7 +220,7 @@ export class GenericController extends ChatbotController implements ChatbotContr
return bot; return bot;
} }
public async updateBot(instance: InstanceDto, botId: string, data: GenericBotDto) { public async updateBot(instance: InstanceDto, botId: string, data: EvolutionBotDto) {
const instanceId = await this.prismaRepository.instance const instanceId = await this.prismaRepository.instance
.findFirst({ .findFirst({
where: { where: {
@ -626,7 +626,7 @@ export class GenericController extends ChatbotController implements ChatbotContr
instanceId: instanceId, instanceId: instanceId,
remoteJid, remoteJid,
botId: bot ? botId : { not: null }, botId: bot ? botId : { not: null },
type: 'generic', type: 'evolution',
}, },
}); });
} catch (error) { } catch (error) {
@ -704,7 +704,7 @@ export class GenericController extends ChatbotController implements ChatbotContr
content, content,
instance, instance,
session, session,
)) as GenericBot; )) as EvolutionBot;
if (!findBot) return; if (!findBot) return;
@ -743,9 +743,13 @@ export class GenericController extends ChatbotController implements ChatbotContr
return; return;
} }
if (session && !session.awaitUser) {
return;
}
if (debounceTime && debounceTime > 0) { if (debounceTime && debounceTime > 0) {
this.processDebounce(this.userMessageDebounce, content, remoteJid, debounceTime, async (debouncedContent) => { this.processDebounce(this.userMessageDebounce, content, remoteJid, debounceTime, async (debouncedContent) => {
await this.genericService.processBot( await this.evolutionBotService.processBot(
this.waMonitor.waInstances[instance.instanceName], this.waMonitor.waInstances[instance.instanceName],
remoteJid, remoteJid,
findBot, findBot,
@ -756,7 +760,7 @@ export class GenericController extends ChatbotController implements ChatbotContr
); );
}); });
} else { } else {
await this.genericService.processBot( await this.evolutionBotService.processBot(
this.waMonitor.waInstances[instance.instanceName], this.waMonitor.waInstances[instance.instanceName],
remoteJid, remoteJid,
findBot, findBot,

View File

@ -1,6 +1,6 @@
import { TriggerOperator, TriggerType } from '@prisma/client'; import { TriggerOperator, TriggerType } from '@prisma/client';
export class GenericBotDto { export class EvolutionBotDto {
enabled?: boolean; enabled?: boolean;
description?: string; description?: string;
apiUrl?: string; apiUrl?: string;
@ -19,7 +19,7 @@ export class GenericBotDto {
ignoreJids?: any; ignoreJids?: any;
} }
export class GenericBotSettingDto { export class EvolutionBotSettingDto {
expire?: number; expire?: number;
keywordFinish?: string; keywordFinish?: string;
delayMessage?: number; delayMessage?: number;

View File

@ -2,28 +2,28 @@ import { RouterBroker } from '@api/abstract/abstract.router';
import { IgnoreJidDto } from '@api/dto/chatbot.dto'; import { IgnoreJidDto } from '@api/dto/chatbot.dto';
import { InstanceDto } from '@api/dto/instance.dto'; import { InstanceDto } from '@api/dto/instance.dto';
import { HttpStatus } from '@api/routes/index.router'; import { HttpStatus } from '@api/routes/index.router';
import { genericController } from '@api/server.module'; import { evolutionBotController } from '@api/server.module';
import { instanceSchema } from '@validate/instance.schema'; import { instanceSchema } from '@validate/instance.schema';
import { RequestHandler, Router } from 'express'; import { RequestHandler, Router } from 'express';
import { GenericBotDto, GenericBotSettingDto } from '../dto/generic.dto'; import { EvolutionBotDto, EvolutionBotSettingDto } from '../dto/evolutionBot.dto';
import { import {
genericIgnoreJidSchema, evolutionBotIgnoreJidSchema,
genericSchema, evolutionBotSchema,
genericSettingSchema, evolutionBotSettingSchema,
genericStatusSchema, evolutionBotStatusSchema,
} from '../validate/generic.schema'; } from '../validate/evolutionBot.schema';
export class GenericRouter extends RouterBroker { export class EvolutionBotRouter extends RouterBroker {
constructor(...guards: RequestHandler[]) { constructor(...guards: RequestHandler[]) {
super(); super();
this.router this.router
.post(this.routerPath('create'), ...guards, async (req, res) => { .post(this.routerPath('create'), ...guards, async (req, res) => {
const response = await this.dataValidate<GenericBotDto>({ const response = await this.dataValidate<EvolutionBotDto>({
request: req, request: req,
schema: genericSchema, schema: evolutionBotSchema,
ClassRef: GenericBotDto, ClassRef: EvolutionBotDto,
execute: (instance, data) => genericController.createBot(instance, data), execute: (instance, data) => evolutionBotController.createBot(instance, data),
}); });
res.status(HttpStatus.CREATED).json(response); res.status(HttpStatus.CREATED).json(response);
@ -33,47 +33,47 @@ export class GenericRouter extends RouterBroker {
request: req, request: req,
schema: instanceSchema, schema: instanceSchema,
ClassRef: InstanceDto, ClassRef: InstanceDto,
execute: (instance) => genericController.findBot(instance), execute: (instance) => evolutionBotController.findBot(instance),
}); });
res.status(HttpStatus.OK).json(response); res.status(HttpStatus.OK).json(response);
}) })
.get(this.routerPath('fetch/:genericId'), ...guards, async (req, res) => { .get(this.routerPath('fetch/:evolutionBotId'), ...guards, async (req, res) => {
const response = await this.dataValidate<InstanceDto>({ const response = await this.dataValidate<InstanceDto>({
request: req, request: req,
schema: instanceSchema, schema: instanceSchema,
ClassRef: InstanceDto, ClassRef: InstanceDto,
execute: (instance) => genericController.fetchBot(instance, req.params.genericId), execute: (instance) => evolutionBotController.fetchBot(instance, req.params.evolutionBotId),
}); });
res.status(HttpStatus.OK).json(response); res.status(HttpStatus.OK).json(response);
}) })
.put(this.routerPath('update/:genericId'), ...guards, async (req, res) => { .put(this.routerPath('update/:evolutionBotId'), ...guards, async (req, res) => {
const response = await this.dataValidate<GenericBotDto>({ const response = await this.dataValidate<EvolutionBotDto>({
request: req, request: req,
schema: genericSchema, schema: evolutionBotSchema,
ClassRef: GenericBotDto, ClassRef: EvolutionBotDto,
execute: (instance, data) => genericController.updateBot(instance, req.params.genericId, data), execute: (instance, data) => evolutionBotController.updateBot(instance, req.params.evolutionBotId, data),
}); });
res.status(HttpStatus.OK).json(response); res.status(HttpStatus.OK).json(response);
}) })
.delete(this.routerPath('delete/:genericId'), ...guards, async (req, res) => { .delete(this.routerPath('delete/:evolutionBotId'), ...guards, async (req, res) => {
const response = await this.dataValidate<InstanceDto>({ const response = await this.dataValidate<InstanceDto>({
request: req, request: req,
schema: instanceSchema, schema: instanceSchema,
ClassRef: InstanceDto, ClassRef: InstanceDto,
execute: (instance) => genericController.deleteBot(instance, req.params.genericId), execute: (instance) => evolutionBotController.deleteBot(instance, req.params.evolutionBotId),
}); });
res.status(HttpStatus.OK).json(response); res.status(HttpStatus.OK).json(response);
}) })
.post(this.routerPath('settings'), ...guards, async (req, res) => { .post(this.routerPath('settings'), ...guards, async (req, res) => {
const response = await this.dataValidate<GenericBotSettingDto>({ const response = await this.dataValidate<EvolutionBotSettingDto>({
request: req, request: req,
schema: genericSettingSchema, schema: evolutionBotSettingSchema,
ClassRef: GenericBotSettingDto, ClassRef: EvolutionBotSettingDto,
execute: (instance, data) => genericController.settings(instance, data), execute: (instance, data) => evolutionBotController.settings(instance, data),
}); });
res.status(HttpStatus.OK).json(response); res.status(HttpStatus.OK).json(response);
@ -83,7 +83,7 @@ export class GenericRouter extends RouterBroker {
request: req, request: req,
schema: instanceSchema, schema: instanceSchema,
ClassRef: InstanceDto, ClassRef: InstanceDto,
execute: (instance) => genericController.fetchSettings(instance), execute: (instance) => evolutionBotController.fetchSettings(instance),
}); });
res.status(HttpStatus.OK).json(response); res.status(HttpStatus.OK).json(response);
@ -91,19 +91,19 @@ export class GenericRouter extends RouterBroker {
.post(this.routerPath('changeStatus'), ...guards, async (req, res) => { .post(this.routerPath('changeStatus'), ...guards, async (req, res) => {
const response = await this.dataValidate<InstanceDto>({ const response = await this.dataValidate<InstanceDto>({
request: req, request: req,
schema: genericStatusSchema, schema: evolutionBotStatusSchema,
ClassRef: InstanceDto, ClassRef: InstanceDto,
execute: (instance, data) => genericController.changeStatus(instance, data), execute: (instance, data) => evolutionBotController.changeStatus(instance, data),
}); });
res.status(HttpStatus.OK).json(response); res.status(HttpStatus.OK).json(response);
}) })
.get(this.routerPath('fetchSessions/:genericId'), ...guards, async (req, res) => { .get(this.routerPath('fetchSessions/:evolutionBotId'), ...guards, async (req, res) => {
const response = await this.dataValidate<InstanceDto>({ const response = await this.dataValidate<InstanceDto>({
request: req, request: req,
schema: instanceSchema, schema: instanceSchema,
ClassRef: InstanceDto, ClassRef: InstanceDto,
execute: (instance) => genericController.fetchSessions(instance, req.params.genericId), execute: (instance) => evolutionBotController.fetchSessions(instance, req.params.evolutionBotId),
}); });
res.status(HttpStatus.OK).json(response); res.status(HttpStatus.OK).json(response);
@ -111,9 +111,9 @@ export class GenericRouter extends RouterBroker {
.post(this.routerPath('ignoreJid'), ...guards, async (req, res) => { .post(this.routerPath('ignoreJid'), ...guards, async (req, res) => {
const response = await this.dataValidate<IgnoreJidDto>({ const response = await this.dataValidate<IgnoreJidDto>({
request: req, request: req,
schema: genericIgnoreJidSchema, schema: evolutionBotIgnoreJidSchema,
ClassRef: IgnoreJidDto, ClassRef: IgnoreJidDto,
execute: (instance, data) => genericController.ignoreJid(instance, data), execute: (instance, data) => evolutionBotController.ignoreJid(instance, data),
}); });
res.status(HttpStatus.OK).json(response); res.status(HttpStatus.OK).json(response);

View File

@ -4,18 +4,18 @@ import { WAMonitoringService } from '@api/services/monitor.service';
import { Integration } from '@api/types/wa.types'; import { Integration } from '@api/types/wa.types';
import { Auth, ConfigService, HttpServer } from '@config/env.config'; import { Auth, ConfigService, HttpServer } from '@config/env.config';
import { Logger } from '@config/logger.config'; import { Logger } from '@config/logger.config';
import { GenericBot, GenericSetting, IntegrationSession } from '@prisma/client'; import { EvolutionBot, EvolutionBotSetting, IntegrationSession } from '@prisma/client';
import { sendTelemetry } from '@utils/sendTelemetry'; import { sendTelemetry } from '@utils/sendTelemetry';
import axios from 'axios'; import axios from 'axios';
export class GenericService { export class EvolutionBotService {
constructor( constructor(
private readonly waMonitor: WAMonitoringService, private readonly waMonitor: WAMonitoringService,
private readonly configService: ConfigService, private readonly configService: ConfigService,
private readonly prismaRepository: PrismaRepository, private readonly prismaRepository: PrismaRepository,
) {} ) {}
private readonly logger = new Logger('GenericService'); private readonly logger = new Logger('EvolutionBotService');
public async createNewSession(instance: InstanceDto, data: any) { public async createNewSession(instance: InstanceDto, data: any) {
try { try {
@ -28,7 +28,7 @@ export class GenericService {
awaitUser: false, awaitUser: false,
botId: data.botId, botId: data.botId,
instanceId: instance.instanceId, instanceId: instance.instanceId,
type: 'generic', type: 'evolution',
}, },
}); });
@ -46,13 +46,14 @@ export class GenericService {
private async sendMessageToBot( private async sendMessageToBot(
instance: any, instance: any,
session: IntegrationSession, session: IntegrationSession,
bot: GenericBot, bot: EvolutionBot,
remoteJid: string, remoteJid: string,
pushName: string, pushName: string,
content: string, content: string,
) { ) {
const payload: any = { const payload: any = {
inputs: { inputs: {
sessionId: session.id,
remoteJid: remoteJid, remoteJid: remoteJid,
pushName: pushName, pushName: pushName,
instanceName: instance.instanceName, instanceName: instance.instanceName,
@ -108,7 +109,7 @@ export class GenericService {
instance: any, instance: any,
remoteJid: string, remoteJid: string,
session: IntegrationSession, session: IntegrationSession,
settings: GenericSetting, settings: EvolutionBotSetting,
message: string, message: string,
) { ) {
const regex = /!?\[(.*?)\]\((.*?)\)/g; const regex = /!?\[(.*?)\]\((.*?)\)/g;
@ -175,8 +176,8 @@ export class GenericService {
private async initNewSession( private async initNewSession(
instance: any, instance: any,
remoteJid: string, remoteJid: string,
bot: GenericBot, bot: EvolutionBot,
settings: GenericSetting, settings: EvolutionBotSetting,
session: IntegrationSession, session: IntegrationSession,
content: string, content: string,
pushName?: string, pushName?: string,
@ -201,9 +202,9 @@ export class GenericService {
public async processBot( public async processBot(
instance: any, instance: any,
remoteJid: string, remoteJid: string,
bot: GenericBot, bot: EvolutionBot,
session: IntegrationSession, session: IntegrationSession,
settings: GenericSetting, settings: EvolutionBotSetting,
content: string, content: string,
pushName?: string, pushName?: string,
) { ) {

View File

@ -20,7 +20,7 @@ const isNotEmpty = (...propertyNames: string[]): JSONSchema7 => {
}; };
}; };
export const genericSchema: JSONSchema7 = { export const evolutionBotSchema: JSONSchema7 = {
$id: v4(), $id: v4(),
type: 'object', type: 'object',
properties: { properties: {
@ -45,7 +45,7 @@ export const genericSchema: JSONSchema7 = {
...isNotEmpty('enabled', 'apiUrl', 'triggerType'), ...isNotEmpty('enabled', 'apiUrl', 'triggerType'),
}; };
export const genericStatusSchema: JSONSchema7 = { export const evolutionBotStatusSchema: JSONSchema7 = {
$id: v4(), $id: v4(),
type: 'object', type: 'object',
properties: { properties: {
@ -56,7 +56,7 @@ export const genericStatusSchema: JSONSchema7 = {
...isNotEmpty('remoteJid', 'status'), ...isNotEmpty('remoteJid', 'status'),
}; };
export const genericSettingSchema: JSONSchema7 = { export const evolutionBotSettingSchema: JSONSchema7 = {
$id: v4(), $id: v4(),
type: 'object', type: 'object',
properties: { properties: {
@ -95,7 +95,7 @@ export const genericSettingSchema: JSONSchema7 = {
), ),
}; };
export const genericIgnoreJidSchema: JSONSchema7 = { export const evolutionBotIgnoreJidSchema: JSONSchema7 = {
$id: v4(), $id: v4(),
type: 'object', type: 'object',
properties: { properties: {

View File

@ -743,6 +743,10 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
return; return;
} }
if (session && !session.awaitUser) {
return;
}
if (debounceTime && debounceTime > 0) { if (debounceTime && debounceTime > 0) {
this.processDebounce(this.userMessageDebounce, content, remoteJid, debounceTime, async (debouncedContent) => { this.processDebounce(this.userMessageDebounce, content, remoteJid, debounceTime, async (debouncedContent) => {
await this.flowiseService.processBot( await this.flowiseService.processBot(

View File

@ -980,6 +980,10 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
return; return;
} }
if (session && !session.awaitUser) {
return;
}
if (debounceTime && debounceTime > 0) { if (debounceTime && debounceTime > 0) {
this.processDebounce(this.userMessageDebounce, content, remoteJid, debounceTime, async (debouncedContent) => { this.processDebounce(this.userMessageDebounce, content, remoteJid, debounceTime, async (debouncedContent) => {
if (findBot.botType === 'assistant') { if (findBot.botType === 'assistant') {

View File

@ -1056,6 +1056,10 @@ export class TypebotController extends ChatbotController implements ChatbotContr
return; return;
} }
if (session && !session.awaitUser) {
return;
}
if (debounceTime && debounceTime > 0) { if (debounceTime && debounceTime > 0) {
this.processDebounce(this.userMessageDebounce, content, remoteJid, debounceTime, async (debouncedContent) => { this.processDebounce(this.userMessageDebounce, content, remoteJid, debounceTime, async (debouncedContent) => {
await this.typebotService.processTypebot( await this.typebotService.processTypebot(

View File

@ -19,10 +19,10 @@ import { ChatwootController } from './integrations/chatbot/chatwoot/controllers/
import { ChatwootService } from './integrations/chatbot/chatwoot/services/chatwoot.service'; import { ChatwootService } from './integrations/chatbot/chatwoot/services/chatwoot.service';
import { DifyController } from './integrations/chatbot/dify/controllers/dify.controller'; import { DifyController } from './integrations/chatbot/dify/controllers/dify.controller';
import { DifyService } from './integrations/chatbot/dify/services/dify.service'; import { DifyService } from './integrations/chatbot/dify/services/dify.service';
import { EvolutionBotController } from './integrations/chatbot/evolutionBot/controllers/evolutionBot.controller';
import { EvolutionBotService } from './integrations/chatbot/evolutionBot/services/evolutionBot.service';
import { FlowiseController } from './integrations/chatbot/flowise/controllers/flowise.controller'; import { FlowiseController } from './integrations/chatbot/flowise/controllers/flowise.controller';
import { FlowiseService } from './integrations/chatbot/flowise/services/flowise.service'; import { FlowiseService } from './integrations/chatbot/flowise/services/flowise.service';
import { GenericController } from './integrations/chatbot/generic/controllers/generic.controller';
import { GenericService } from './integrations/chatbot/generic/services/generic.service';
import { OpenaiController } from './integrations/chatbot/openai/controllers/openai.controller'; import { OpenaiController } from './integrations/chatbot/openai/controllers/openai.controller';
import { OpenaiService } from './integrations/chatbot/openai/services/openai.service'; import { OpenaiService } from './integrations/chatbot/openai/services/openai.service';
import { TypebotController } from './integrations/chatbot/typebot/controllers/typebot.controller'; import { TypebotController } from './integrations/chatbot/typebot/controllers/typebot.controller';
@ -116,8 +116,8 @@ export const openaiController = new OpenaiController(openaiService, prismaReposi
const difyService = new DifyService(waMonitor, configService, prismaRepository); const difyService = new DifyService(waMonitor, configService, prismaRepository);
export const difyController = new DifyController(difyService, prismaRepository, waMonitor); export const difyController = new DifyController(difyService, prismaRepository, waMonitor);
const genericService = new GenericService(waMonitor, configService, prismaRepository); const evolutionBotService = new EvolutionBotService(waMonitor, configService, prismaRepository);
export const genericController = new GenericController(genericService, prismaRepository, waMonitor); export const evolutionBotController = new EvolutionBotController(evolutionBotService, prismaRepository, waMonitor);
const flowiseService = new FlowiseService(waMonitor, configService, prismaRepository); const flowiseService = new FlowiseService(waMonitor, configService, prismaRepository);
export const flowiseController = new FlowiseController(flowiseService, prismaRepository, waMonitor); export const flowiseController = new FlowiseController(flowiseService, prismaRepository, waMonitor);