mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-25 18:08:40 -06:00
Added webhooks for typebot events
This commit is contained in:
parent
10c7e81e02
commit
706cc6f49c
@ -7,6 +7,7 @@ import { Logger } from '../../config/logger.config';
|
|||||||
import { ChamaaiDto } from '../dto/chamaai.dto';
|
import { ChamaaiDto } from '../dto/chamaai.dto';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { ChamaaiRaw } from '../models';
|
import { ChamaaiRaw } from '../models';
|
||||||
|
import { Events } from '../types/wa.types';
|
||||||
import { WAMonitoringService } from './monitor.service';
|
import { WAMonitoringService } from './monitor.service';
|
||||||
|
|
||||||
export class ChamaaiService {
|
export class ChamaaiService {
|
||||||
@ -88,6 +89,32 @@ export class ChamaaiService {
|
|||||||
return speakingTimeInSeconds;
|
return speakingTimeInSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getRegexPatterns() {
|
||||||
|
const patternsToCheck = [
|
||||||
|
'.*atend.*humano.*',
|
||||||
|
'.*falar.*com.*um.*humano.*',
|
||||||
|
'.*fala.*humano.*',
|
||||||
|
'.*atend.*humano.*',
|
||||||
|
'.*fala.*atend.*',
|
||||||
|
'.*preciso.*ajuda.*',
|
||||||
|
'.*quero.*suporte.*',
|
||||||
|
'.*preciso.*assiste.*',
|
||||||
|
'.*ajuda.*atend.*',
|
||||||
|
'.*chama.*atendente.*',
|
||||||
|
'.*suporte.*urgente.*',
|
||||||
|
'.*atend.*por.*favor.*',
|
||||||
|
'.*quero.*falar.*com.*alguém.*',
|
||||||
|
'.*falar.*com.*um.*humano.*',
|
||||||
|
'.*transfer.*humano.*',
|
||||||
|
'.*transfer.*atend.*',
|
||||||
|
'.*equipe.*humano.*',
|
||||||
|
'.*suporte.*humano.*',
|
||||||
|
];
|
||||||
|
|
||||||
|
const regexPatterns = patternsToCheck.map((pattern) => new RegExp(pattern, 'iu'));
|
||||||
|
return regexPatterns;
|
||||||
|
}
|
||||||
|
|
||||||
public async sendChamaai(instance: InstanceDto, remoteJid: string, msg: any) {
|
public async sendChamaai(instance: InstanceDto, remoteJid: string, msg: any) {
|
||||||
const content = this.getConversationMessage(msg.message);
|
const content = this.getConversationMessage(msg.message);
|
||||||
const msgType = msg.messageType;
|
const msgType = msg.messageType;
|
||||||
@ -189,6 +216,15 @@ export class ChamaaiService {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.getRegexPatterns().some((pattern) => pattern.test(answer))) {
|
||||||
|
this.waMonitor.waInstances[instance.instanceName].sendDataWebhook(Events.CHAMA_AI_ACTION, {
|
||||||
|
remoteJid: remoteJid,
|
||||||
|
message: msg,
|
||||||
|
answer: answer,
|
||||||
|
action: 'transfer',
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user