mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-20 12:22:21 -06:00
feat: Integration with Dify
Adds support for Dify integration, including new routes, services, and controllers. The configuration for Dify has been added to the environment file, and the necessary changes have been made to the `.env.example` file. Additionally, the WhatsApp Baileys service has been updated to handle Dify notifications. Modified files: - `.env.example` - `package.json` - `src/api/integrations/openai/services/openai.service.ts` - `src/api/routes/index.router.ts` - `src/api/server.module.ts` - `src/api/services/channel.service.ts` - `src/api/services/channels/whatsapp.baileys.service.ts` - `src/config/env.config.ts` - `src/validate/validate.schema.ts` Introduced files: - `src/api/integrations/dify/` - `src/api/integrations/dify/controllers/dify.controller.ts` - `src/api/integrations/dify/dto/dify.dto.ts` - `src/api/integrations/dify/routes/dify.router.ts` - `src/api/integrations/dify/services/dify.service.ts` - `src/api/integrations/dify/validate/dify.schema.ts`
This commit is contained in:
@@ -26,6 +26,7 @@ import { SettingsDto } from '../dto/settings.dto';
|
||||
import { WebhookDto } from '../dto/webhook.dto';
|
||||
import { ChatwootDto } from '../integrations/chatwoot/dto/chatwoot.dto';
|
||||
import { ChatwootService } from '../integrations/chatwoot/services/chatwoot.service';
|
||||
import { DifyService } from '../integrations/dify/services/dify.service';
|
||||
import { OpenaiService } from '../integrations/openai/services/openai.service';
|
||||
import { RabbitmqDto } from '../integrations/rabbitmq/dto/rabbitmq.dto';
|
||||
import { getAMQP, removeQueues } from '../integrations/rabbitmq/libs/amqp.server';
|
||||
@@ -71,6 +72,8 @@ export class ChannelStartupService {
|
||||
|
||||
public openaiService = new OpenaiService(waMonitor, this.configService, this.prismaRepository);
|
||||
|
||||
public difyService = new DifyService(waMonitor, this.configService, this.prismaRepository);
|
||||
|
||||
public setInstance(instance: InstanceDto) {
|
||||
this.logger.setInstance(instance.instanceName);
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ import {
|
||||
configService,
|
||||
ConfigSessionPhone,
|
||||
Database,
|
||||
Dify,
|
||||
Log,
|
||||
Openai,
|
||||
ProviderSession,
|
||||
@@ -1187,6 +1188,17 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.configService.get<Dify>('DIFY').ENABLED) {
|
||||
if (type === 'notify') {
|
||||
if (messageRaw.messageType !== 'reactionMessage')
|
||||
await this.difyService.sendDify(
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
messageRaw.key.remoteJid,
|
||||
messageRaw,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const contact = await this.prismaRepository.contact.findFirst({
|
||||
where: { remoteJid: received.key.remoteJid, instanceId: this.instanceId },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user