mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
adjusts in typebot
This commit is contained in:
parent
b7a34ec81a
commit
ee9cdc51c0
@ -21,6 +21,12 @@
|
||||
* Changed the .env file configuration, removed the yml version and added .env to the repository root
|
||||
* Removed the mobile type connection with Baileys
|
||||
* Simplified payloads and endpoints
|
||||
* Improved Typebot
|
||||
- Now you can register several typebots
|
||||
- Start configuration by trigger or for all
|
||||
- Session search by typebot or remoteJid
|
||||
- KeepOpen configuration (keeps the session even when the bot ends, to run once per contact)
|
||||
- StopBotFromMe configuration, allows me to stop the bot if I send a chat message.
|
||||
|
||||
# 1.8.0 (2024-05-27 16:10)
|
||||
|
||||
|
@ -935,38 +935,50 @@ export class TypebotService {
|
||||
|
||||
formattedText = formattedText.replace(/\n$/, '');
|
||||
|
||||
await instance.textMessage({
|
||||
await instance.textMessage(
|
||||
{
|
||||
number: remoteJid.split('@')[0],
|
||||
delay: settings?.delayMessage || 1000,
|
||||
text: formattedText,
|
||||
});
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
if (message.type === 'image') {
|
||||
await instance.mediaMessage({
|
||||
await instance.mediaMessage(
|
||||
{
|
||||
number: remoteJid.split('@')[0],
|
||||
delay: settings?.delayMessage || 1000,
|
||||
mediatype: 'image',
|
||||
media: message.content.url,
|
||||
});
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
if (message.type === 'video') {
|
||||
await instance.mediaMessage({
|
||||
await instance.mediaMessage(
|
||||
{
|
||||
number: remoteJid.split('@')[0],
|
||||
delay: settings?.delayMessage || 1000,
|
||||
mediatype: 'video',
|
||||
media: message.content.url,
|
||||
});
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
if (message.type === 'audio') {
|
||||
await instance.audioWhatsapp({
|
||||
await instance.audioWhatsapp(
|
||||
{
|
||||
number: remoteJid.split('@')[0],
|
||||
delay: settings?.delayMessage || 1000,
|
||||
encoding: true,
|
||||
audio: message.content.url,
|
||||
});
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
const wait = findItemAndGetSecondsToWait(clientSideActions, message.id);
|
||||
@ -988,11 +1000,14 @@ export class TypebotService {
|
||||
|
||||
formattedText = formattedText.replace(/\n$/, '');
|
||||
|
||||
await instance.textMessage({
|
||||
await instance.textMessage(
|
||||
{
|
||||
number: remoteJid.split('@')[0],
|
||||
delay: settings?.delayMessage || 1000,
|
||||
text: formattedText,
|
||||
});
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
await prismaRepository.typebotSession.update({
|
||||
@ -1240,11 +1255,14 @@ export class TypebotService {
|
||||
|
||||
if (!content) {
|
||||
if (unknownMessage) {
|
||||
this.waMonitor.waInstances[instance.instanceName].textMessage({
|
||||
this.waMonitor.waInstances[instance.instanceName].textMessage(
|
||||
{
|
||||
number: remoteJid.split('@')[0],
|
||||
delay: delayMessage || 1000,
|
||||
text: unknownMessage,
|
||||
});
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1349,11 +1367,14 @@ export class TypebotService {
|
||||
if (data.messages.length === 0) {
|
||||
if (!content) {
|
||||
if (unknownMessage) {
|
||||
this.waMonitor.waInstances[instance.instanceName].textMessage({
|
||||
this.waMonitor.waInstances[instance.instanceName].textMessage(
|
||||
{
|
||||
number: remoteJid.split('@')[0],
|
||||
delay: delayMessage || 1000,
|
||||
text: unknownMessage,
|
||||
});
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1425,11 +1446,14 @@ export class TypebotService {
|
||||
|
||||
if (!content) {
|
||||
if (unknownMessage) {
|
||||
this.waMonitor.waInstances[instance.instanceName].textMessage({
|
||||
this.waMonitor.waInstances[instance.instanceName].textMessage(
|
||||
{
|
||||
number: remoteJid.split('@')[0],
|
||||
delay: delayMessage || 1000,
|
||||
text: unknownMessage,
|
||||
});
|
||||
},
|
||||
true,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ export class MessageRouter extends RouterBroker {
|
||||
|
||||
return res.status(HttpStatus.CREATED).json(response);
|
||||
})
|
||||
// TODO: Revisar funcionamento do envio de Status
|
||||
.post(this.routerPath('sendStatus'), ...guards, async (req, res) => {
|
||||
const response = await this.dataValidate<SendStatusDto>({
|
||||
request: req,
|
||||
|
@ -1672,7 +1672,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
number: string,
|
||||
message: T,
|
||||
options?: Options,
|
||||
isChatwoot = false,
|
||||
isIntegration = false,
|
||||
) {
|
||||
const isWA = (await this.whatsappNumber({ numbers: [number] }))?.shift();
|
||||
|
||||
@ -1890,10 +1890,19 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && !isChatwoot) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && !isIntegration) {
|
||||
this.chatwootService.eventWhatsapp(Events.SEND_MESSAGE, { instanceName: this.instance.name }, messageRaw);
|
||||
}
|
||||
|
||||
if (this.configService.get<Typebot>('TYPEBOT').ENABLED && !isIntegration) {
|
||||
if (messageRaw.messageType !== 'reactionMessage')
|
||||
await this.typebotService.sendTypebot(
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
messageRaw.key.remoteJid,
|
||||
messageRaw,
|
||||
);
|
||||
}
|
||||
|
||||
await this.prismaRepository.message.create({
|
||||
data: messageRaw,
|
||||
});
|
||||
@ -1966,7 +1975,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
|
||||
// Send Message Controller
|
||||
public async textMessage(data: SendTextDto, isChatwoot = false) {
|
||||
public async textMessage(data: SendTextDto, isIntegration = false) {
|
||||
const text = data.text;
|
||||
|
||||
if (!text || text.trim().length === 0) {
|
||||
@ -1988,7 +1997,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
mentioned: data?.mentioned,
|
||||
},
|
||||
},
|
||||
isChatwoot,
|
||||
isIntegration,
|
||||
);
|
||||
}
|
||||
|
||||
@ -2276,7 +2285,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
return result;
|
||||
}
|
||||
|
||||
public async mediaMessage(data: SendMediaDto, isChatwoot = false) {
|
||||
public async mediaMessage(data: SendMediaDto, isIntegration = false) {
|
||||
const generate = await this.prepareMediaMessage(data);
|
||||
|
||||
return await this.sendMessageWithTyping(
|
||||
@ -2291,7 +2300,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
mentioned: data?.mentioned,
|
||||
},
|
||||
},
|
||||
isChatwoot,
|
||||
isIntegration,
|
||||
);
|
||||
}
|
||||
|
||||
@ -2331,7 +2340,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
});
|
||||
}
|
||||
|
||||
public async audioWhatsapp(data: SendAudioDto, isChatwoot = false) {
|
||||
public async audioWhatsapp(data: SendAudioDto, isIntegration = false) {
|
||||
if (!data?.encoding && data?.encoding !== false) {
|
||||
data.encoding = true;
|
||||
}
|
||||
@ -2348,7 +2357,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
mimetype: 'audio/mp4',
|
||||
},
|
||||
{ presence: 'recording', delay: data?.delay },
|
||||
isChatwoot,
|
||||
isIntegration,
|
||||
);
|
||||
|
||||
fs.unlinkSync(convert);
|
||||
@ -2367,7 +2376,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
mimetype: 'audio/ogg; codecs=opus',
|
||||
},
|
||||
{ presence: 'recording', delay: data?.delay },
|
||||
isChatwoot,
|
||||
isIntegration,
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user