Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 6 additions & 2 deletions src/api/integrations/chatbot/base-chatbot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export abstract class BaseChatbotService<BotType = any, SettingsType = any> {
remoteJid: string,
message: string,
settings: SettingsType,
linkPreview: boolean = true,
): Promise<void> {
if (!message) return;

Expand All @@ -202,7 +203,7 @@ export abstract class BaseChatbotService<BotType = any, SettingsType = any> {
if (mediaType) {
// Send accumulated text before sending media
if (textBuffer.trim()) {
await this.sendFormattedText(instance, remoteJid, textBuffer.trim(), settings, splitMessages);
await this.sendFormattedText(instance, remoteJid, textBuffer.trim(), settings, splitMessages, linkPreview);
textBuffer = '';
}

Expand Down Expand Up @@ -252,7 +253,7 @@ export abstract class BaseChatbotService<BotType = any, SettingsType = any> {

// Send any remaining text
if (textBuffer.trim()) {
await this.sendFormattedText(instance, remoteJid, textBuffer.trim(), settings, splitMessages);
await this.sendFormattedText(instance, remoteJid, textBuffer.trim(), settings, splitMessages, linkPreview);
}
}

Expand All @@ -265,6 +266,7 @@ export abstract class BaseChatbotService<BotType = any, SettingsType = any> {
text: string,
settings: any,
splitMessages: boolean,
linkPreview: boolean = true,
): Promise<void> {
const timePerChar = settings?.timePerChar ?? 0;
const minDelay = 1000;
Expand All @@ -290,6 +292,7 @@ export abstract class BaseChatbotService<BotType = any, SettingsType = any> {
number: remoteJid.split('@')[0],
delay: settings?.delayMessage || 1000,
text: message,
linkPreview,
},
false,
);
Expand All @@ -316,6 +319,7 @@ export abstract class BaseChatbotService<BotType = any, SettingsType = any> {
number: remoteJid.split('@')[0],
delay: settings?.delayMessage || 1000,
text: text,
linkPreview,
},
false,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,10 @@ export class EvolutionBotService extends BaseChatbotService<EvolutionBot, Evolut
},
};

this.logger.debug(`[EvolutionBot] Sending request to endpoint: ${endpoint}`);
this.logger.debug(`[EvolutionBot] Request payload: ${JSON.stringify(sanitizedPayload, null, 2)}`);

const response = await axios.post(endpoint, payload, {
headers,
});

this.logger.debug(`[EvolutionBot] Response received - Status: ${response.status}`);

if (instance.integration === Integration.WHATSAPP_BAILEYS) {
await instance.client.sendPresenceUpdate('paused', remoteJid);
}
Expand All @@ -134,10 +129,6 @@ export class EvolutionBotService extends BaseChatbotService<EvolutionBot, Evolut
// Validate linkPreview is boolean and default to true for backward compatibility
const linkPreview = typeof rawLinkPreview === 'boolean' ? rawLinkPreview : true;

this.logger.debug(
`[EvolutionBot] Processing response - Message length: ${message?.length || 0}, LinkPreview: ${linkPreview}`,
);

if (message && typeof message === 'string' && message.startsWith("'") && message.endsWith("'")) {
const innerContent = message.slice(1, -1);
if (!innerContent.includes("'")) {
Expand All @@ -146,17 +137,8 @@ export class EvolutionBotService extends BaseChatbotService<EvolutionBot, Evolut
}

if (message) {
// Send message directly with validated linkPreview option
await instance.textMessage(
{
number: remoteJid.split('@')[0],
delay: settings?.delayMessage || 1000,
text: message,
linkPreview, // Always boolean, defaults to true
},
false,
);
this.logger.debug(`[EvolutionBot] Message sent successfully with linkPreview: ${linkPreview}`);
// Use the base class method that handles splitMessages functionality
await this.sendMessageWhatsApp(instance, remoteJid, message, settings, linkPreview);
} else {
this.logger.warn(`[EvolutionBot] No message content received from bot response`);
}
Expand Down
Loading