mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-25 01:48:39 -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 { InstanceDto } from '../dto/instance.dto';
|
||||
import { ChamaaiRaw } from '../models';
|
||||
import { Events } from '../types/wa.types';
|
||||
import { WAMonitoringService } from './monitor.service';
|
||||
|
||||
export class ChamaaiService {
|
||||
@ -88,6 +89,32 @@ export class ChamaaiService {
|
||||
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) {
|
||||
const content = this.getConversationMessage(msg.message);
|
||||
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