Merge branch 'develop' of https://github.com/codephix/evolution-api into develop

This commit is contained in:
CodePhix 2023-12-06 20:19:10 -03:00
commit 760b3f5fc5
45 changed files with 14278 additions and 14267 deletions

5
dev-env Normal file
View File

@ -0,0 +1,5 @@
# OPENAI_API_KEY=""
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
REDIS_PASS=0

0
src/config.ts Executable file → Normal file
View File

0
src/config/env.config.ts Executable file → Normal file
View File

2
src/dev-env.yml Executable file → Normal file
View File

@ -150,7 +150,7 @@ WEBHOOK:
CONFIG_SESSION_PHONE: CONFIG_SESSION_PHONE:
# Name that will be displayed on smartphone connection # Name that will be displayed on smartphone connection
CLIENT: "Evolution API" CLIENT: "Chat API"
NAME: Chrome # Chrome | Firefox | Edge | Opera | Safari NAME: Chrome # Chrome | Firefox | Edge | Opera | Safari
# Set qrcode display limit # Set qrcode display limit

0
src/docs/swagger.yaml Executable file → Normal file
View File

0
src/libs/amqp.server.ts Executable file → Normal file
View File

0
src/libs/db.connect.ts Executable file → Normal file
View File

0
src/libs/openai.ts Executable file → Normal file
View File

0
src/libs/redis.client.ts Executable file → Normal file
View File

0
src/libs/redis.ts Executable file → Normal file
View File

0
src/libs/sqs.server.ts Executable file → Normal file
View File

0
src/main.ts Executable file → Normal file
View File

0
src/prompts/contabilAgent.ts Executable file → Normal file
View File

0
src/prompts/pizzaAgent.ts Executable file → Normal file
View File

0
src/utils/initPrompt.ts Executable file → Normal file
View File

2
src/utils/use-multi-file-auth-state-db.ts Executable file → Normal file
View File

@ -106,7 +106,7 @@ export async function useMultiFileAuthStateDb(
}, },
}, },
saveCreds: async () => { saveCreds: async () => {
return writeData(creds, 'creds'); return await writeData(creds, 'creds');
}, },
}; };
} }

0
src/validate/validate.schema.ts Executable file → Normal file
View File

0
src/whatsapp/controllers/instance.controller.ts Executable file → Normal file
View File

0
src/whatsapp/controllers/openai.controller.ts Executable file → Normal file
View File

0
src/whatsapp/controllers/sqs.controller.ts Executable file → Normal file
View File

0
src/whatsapp/dto/contactopenai.dto.ts Executable file → Normal file
View File

0
src/whatsapp/dto/instance.dto.ts Executable file → Normal file
View File

0
src/whatsapp/dto/openai.dto.ts Executable file → Normal file
View File

0
src/whatsapp/dto/sqs.dto.ts Executable file → Normal file
View File

0
src/whatsapp/guards/instance.guard.ts Executable file → Normal file
View File

0
src/whatsapp/models/contactOpenai.model.ts Executable file → Normal file
View File

0
src/whatsapp/models/index.ts Executable file → Normal file
View File

0
src/whatsapp/models/openai.model.ts Executable file → Normal file
View File

0
src/whatsapp/models/sqs.model.ts Executable file → Normal file
View File

0
src/whatsapp/repository/openai.repository.ts Executable file → Normal file
View File

0
src/whatsapp/repository/repository.manager.ts Executable file → Normal file
View File

0
src/whatsapp/repository/sqs.repository.ts Executable file → Normal file
View File

0
src/whatsapp/routers/index.router.ts Executable file → Normal file
View File

0
src/whatsapp/routers/instance.router.ts Executable file → Normal file
View File

0
src/whatsapp/routers/openai.router.ts Executable file → Normal file
View File

0
src/whatsapp/routers/sqs.router.ts Executable file → Normal file
View File

Binary file not shown.

38
src/whatsapp/services/chatwoot.service.ts Executable file → Normal file
View File

@ -1023,6 +1023,10 @@ export class ChatwootService {
const state = waInstance?.connectionStatus?.state; const state = waInstance?.connectionStatus?.state;
if (state !== 'open') { if (state !== 'open') {
if (state === 'close') {
this.logger.verbose('request cleaning up instance: ' + instance.instanceName);
await this.waMonitor.cleaningUp(instance.instanceName);
}
this.logger.verbose('connect to whatsapp'); this.logger.verbose('connect to whatsapp');
const number = command.split(':')[1]; const number = command.split(':')[1];
await waInstance.connectToWhatsapp(number); await waInstance.connectToWhatsapp(number);
@ -1331,13 +1335,6 @@ export class ChatwootService {
public async eventWhatsapp(event: string, instance: InstanceDto, body: any) { public async eventWhatsapp(event: string, instance: InstanceDto, body: any) {
this.logger.verbose('event whatsapp to instance: ' + instance.instanceName); this.logger.verbose('event whatsapp to instance: ' + instance.instanceName);
try { try {
const client = await this.clientCw(instance);
if (!client) {
this.logger.warn('client not found');
return null;
}
const waInstance = this.waMonitor.waInstances[instance.instanceName]; const waInstance = this.waMonitor.waInstances[instance.instanceName];
if (!waInstance) { if (!waInstance) {
@ -1345,6 +1342,13 @@ export class ChatwootService {
return null; return null;
} }
const client = await this.clientCw(instance);
if (!client) {
this.logger.warn('client not found');
return null;
}
if (event === 'messages.upsert' || event === 'send.message') { if (event === 'messages.upsert' || event === 'send.message') {
this.logger.verbose('event messages.upsert'); this.logger.verbose('event messages.upsert');
@ -1600,16 +1604,18 @@ export class ChatwootService {
await this.createBotMessage(instance, msgStatus, 'incoming'); await this.createBotMessage(instance, msgStatus, 'incoming');
} }
// if (event === 'connection.update') { if (event === 'connection.update') {
// this.logger.verbose('event connection.update'); this.logger.verbose('event connection.update');
// if (body.status === 'open') { if (body.status === 'open') {
// const msgConnection = `🚀 Connection successfully established!`; // if we have qrcode count then we understand that a new connection was established
if (this.waMonitor.waInstances[instance.instanceName].qrCode.count > 0) {
// this.logger.verbose('send message to chatwoot'); const msgConnection = `🚀 Connection successfully established!`;
// await this.createBotMessage(instance, msgConnection, 'incoming'); this.logger.verbose('send message to chatwoot');
// } await this.createBotMessage(instance, msgConnection, 'incoming');
// } }
}
}
if (event === 'qrcode.updated') { if (event === 'qrcode.updated') {
this.logger.verbose('event qrcode.updated'); this.logger.verbose('event qrcode.updated');

0
src/whatsapp/services/monitor.service.ts Executable file → Normal file
View File

0
src/whatsapp/services/openai.service.ts Executable file → Normal file
View File

0
src/whatsapp/services/sqs.service.ts Executable file → Normal file
View File

2
src/whatsapp/services/typebot.service.ts Executable file → Normal file
View File

@ -263,7 +263,7 @@ export class TypebotService {
prefilledVariables: { prefilledVariables: {
...data.prefilledVariables, ...data.prefilledVariables,
remoteJid: data.remoteJid, remoteJid: data.remoteJid,
pushName: data.pushName || '', pushName: data.pushName || data.prefilledVariables?.pushName || '',
instanceName: instance.instanceName, instanceName: instance.instanceName,
}, },
}, },

0
src/whatsapp/services/whatsapp.service.ts Executable file → Normal file
View File

0
src/whatsapp/types/wa.types.ts Executable file → Normal file
View File

0
src/whatsapp/whatsapp.module.ts Executable file → Normal file
View File