Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@ export class EvolutionBotService {
if (instance.integration === Integration.WHATSAPP_BAILEYS)
await instance.client.sendPresenceUpdate('paused', remoteJid);

const message = response?.data?.message;
let message = response?.data?.message;

if (message && typeof message === 'string' && message.startsWith("'") && message.endsWith("'")) {
const innerContent = message.slice(1, -1);
if (!innerContent.includes("'")) {
message = innerContent;
}
}

return message;
}
Expand Down
6 changes: 3 additions & 3 deletions src/api/integrations/chatbot/n8n/services/n8n.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class N8nService {
}

private async sendMessageWhatsApp(instance: any, remoteJid: string, message: string, settings: N8nSetting) {
const linkRegex = /(!?)\[(.*?)\]\((.*?)\)/g;
const linkRegex = /!?\[(.*?)\]\((.*?)\)/g;
let textBuffer = '';
let lastIndex = 0;
let match: RegExpExecArray | null;
Expand All @@ -211,7 +211,7 @@ export class N8nService {
return null;
};
while ((match = linkRegex.exec(message)) !== null) {
const [altText, url] = match;
const [fullMatch, altText, url] = match;
const mediaType = getMediaType(url);
const beforeText = message.slice(lastIndex, match.index);
if (beforeText) {
Expand Down Expand Up @@ -282,7 +282,7 @@ export class N8nService {
);
}
} else {
textBuffer += `[${altText}](${url})`;
textBuffer += fullMatch;
}
lastIndex = linkRegex.lastIndex;
}
Expand Down