From b0ca79cd116b483c153ed95176ec80d08169ebb0 Mon Sep 17 00:00:00 2001 From: Anderson Silva Date: Sat, 20 Sep 2025 10:57:03 -0300 Subject: [PATCH 1/2] fix(evolutionbot): implement splitMessages and linkPreview functionality - Replace instance.textMessage() with sendMessageWhatsApp() method - Enable message splitting by double line breaks (\n\n) - Add proper delay and typing indicators between split messages - Fix linkPreview parameter passing to base class methods - Support linkPreview: false/true from webhook response - Remove unnecessary debug logs for cleaner output Fixes: EvolutionBot was not respecting splitMessages and linkPreview configurations --- .../chatbot/base-chatbot.service.ts | 8 +++++-- .../services/evolutionBot.service.ts | 22 ++----------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/api/integrations/chatbot/base-chatbot.service.ts b/src/api/integrations/chatbot/base-chatbot.service.ts index f19cb9d4..616d7c57 100644 --- a/src/api/integrations/chatbot/base-chatbot.service.ts +++ b/src/api/integrations/chatbot/base-chatbot.service.ts @@ -180,6 +180,7 @@ export abstract class BaseChatbotService { remoteJid: string, message: string, settings: SettingsType, + linkPreview: boolean = true, ): Promise { if (!message) return; @@ -202,7 +203,7 @@ export abstract class BaseChatbotService { 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 = ''; } @@ -252,7 +253,7 @@ export abstract class BaseChatbotService { // 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); } } @@ -265,6 +266,7 @@ export abstract class BaseChatbotService { text: string, settings: any, splitMessages: boolean, + linkPreview: boolean = true, ): Promise { const timePerChar = settings?.timePerChar ?? 0; const minDelay = 1000; @@ -290,6 +292,7 @@ export abstract class BaseChatbotService { number: remoteJid.split('@')[0], delay: settings?.delayMessage || 1000, text: message, + linkPreview, }, false, ); @@ -316,6 +319,7 @@ export abstract class BaseChatbotService { number: remoteJid.split('@')[0], delay: settings?.delayMessage || 1000, text: text, + linkPreview, }, false, ); diff --git a/src/api/integrations/chatbot/evolutionBot/services/evolutionBot.service.ts b/src/api/integrations/chatbot/evolutionBot/services/evolutionBot.service.ts index b82e8fe1..be7e8040 100644 --- a/src/api/integrations/chatbot/evolutionBot/services/evolutionBot.service.ts +++ b/src/api/integrations/chatbot/evolutionBot/services/evolutionBot.service.ts @@ -115,15 +115,10 @@ export class EvolutionBotService extends BaseChatbotService Date: Sat, 20 Sep 2025 11:35:15 -0300 Subject: [PATCH 2/2] refactor(chatbot): centralize split logic and ensure linkPreview consistency - Centralize double-line-break message splitting logic into dedicated helper methods - Add targeted debug logs for better observability without clutter - Ensure linkPreview parameter is consistently passed across all chatbot services - Extract splitMessageByDoubleLineBreaks() and sendSingleMessage() helpers - Update all chatbot services to explicitly pass linkPreview: true - Improve code testability and maintainability Services updated: - BaseChatbotService: Refactored split logic and added debug logs - TypebotService: Added linkPreview parameter to all sendMessageWhatsApp calls - OpenAIService: Added linkPreview parameter to all sendMessageWhatsApp calls - N8nService: Added linkPreview parameter to sendMessageWhatsApp call - FlowiseService: Added linkPreview parameter to sendMessageWhatsApp call - EvoaiService: Added linkPreview parameter to sendMessageWhatsApp call - DifyService: Added linkPreview parameter to all sendMessageWhatsApp calls --- env.example | 302 ++++++++++++++++++ .../chatbot/base-chatbot.service.ts | 115 +++---- .../chatbot/dify/services/dify.service.ts | 6 +- .../chatbot/evoai/services/evoai.service.ts | 2 +- .../flowise/services/flowise.service.ts | 2 +- .../chatbot/n8n/services/n8n.service.ts | 2 +- .../chatbot/openai/services/openai.service.ts | 3 +- .../typebot/services/typebot.service.ts | 70 ++-- 8 files changed, 413 insertions(+), 89 deletions(-) create mode 100644 env.example diff --git a/env.example b/env.example new file mode 100644 index 00000000..5fe448b8 --- /dev/null +++ b/env.example @@ -0,0 +1,302 @@ +# =========================================== +# EVOLUTION API - CONFIGURAÇÃO DE AMBIENTE +# =========================================== + +# =========================================== +# SERVIDOR +# =========================================== +SERVER_NAME=evolution +SERVER_TYPE=http +SERVER_PORT=8080 +SERVER_URL=http://localhost:8080 +SERVER_DISABLE_DOCS=false +SERVER_DISABLE_MANAGER=false + +# =========================================== +# CORS +# =========================================== +CORS_ORIGIN=* +CORS_METHODS=POST,GET,PUT,DELETE +CORS_CREDENTIALS=true + +# =========================================== +# SSL (opcional) +# =========================================== +SSL_CONF_PRIVKEY= +SSL_CONF_FULLCHAIN= + +# =========================================== +# BANCO DE DADOS +# =========================================== +DATABASE_PROVIDER=postgresql +DATABASE_CONNECTION_URI=postgresql://username:password@localhost:5432/evolution_api +DATABASE_CONNECTION_CLIENT_NAME=evolution + +# Configurações de salvamento de dados +DATABASE_SAVE_DATA_INSTANCE=true +DATABASE_SAVE_DATA_NEW_MESSAGE=true +DATABASE_SAVE_MESSAGE_UPDATE=true +DATABASE_SAVE_DATA_CONTACTS=true +DATABASE_SAVE_DATA_CHATS=true +DATABASE_SAVE_DATA_HISTORIC=true +DATABASE_SAVE_DATA_LABELS=true +DATABASE_SAVE_IS_ON_WHATSAPP=true +DATABASE_SAVE_IS_ON_WHATSAPP_DAYS=7 +DATABASE_DELETE_MESSAGE=false + +# =========================================== +# REDIS +# =========================================== +CACHE_REDIS_ENABLED=true +CACHE_REDIS_URI=redis://localhost:6379 +CACHE_REDIS_PREFIX_KEY=evolution-cache +CACHE_REDIS_TTL=604800 +CACHE_REDIS_SAVE_INSTANCES=true + +# Cache local (fallback) +CACHE_LOCAL_ENABLED=true +CACHE_LOCAL_TTL=86400 + +# =========================================== +# AUTENTICAÇÃO +# =========================================== +AUTHENTICATION_API_KEY=BQYHJGJHJ +AUTHENTICATION_EXPOSE_IN_FETCH_INSTANCES=false + +# =========================================== +# LOGS +# =========================================== +LOG_LEVEL=ERROR,WARN,DEBUG,INFO,LOG,VERBOSE,DARK,WEBHOOKS,WEBSOCKET +LOG_COLOR=true +LOG_BAILEYS=error + +# =========================================== +# INSTÂNCIAS +# =========================================== +DEL_INSTANCE=false +DEL_TEMP_INSTANCES=true + +# =========================================== +# IDIOMA +# =========================================== +LANGUAGE=pt-BR + +# =========================================== +# WEBHOOK +# =========================================== +WEBHOOK_GLOBAL_URL= +WEBHOOK_GLOBAL_ENABLED=false +WEBHOOK_GLOBAL_WEBHOOK_BY_EVENTS=false + +# Eventos de webhook +WEBHOOK_EVENTS_APPLICATION_STARTUP=false +WEBHOOK_EVENTS_INSTANCE_CREATE=false +WEBHOOK_EVENTS_INSTANCE_DELETE=false +WEBHOOK_EVENTS_QRCODE_UPDATED=false +WEBHOOK_EVENTS_MESSAGES_SET=false +WEBHOOK_EVENTS_MESSAGES_UPSERT=false +WEBHOOK_EVENTS_MESSAGES_EDITED=false +WEBHOOK_EVENTS_MESSAGES_UPDATE=false +WEBHOOK_EVENTS_MESSAGES_DELETE=false +WEBHOOK_EVENTS_SEND_MESSAGE=false +WEBHOOK_EVENTS_SEND_MESSAGE_UPDATE=false +WEBHOOK_EVENTS_CONTACTS_SET=false +WEBHOOK_EVENTS_CONTACTS_UPDATE=false +WEBHOOK_EVENTS_CONTACTS_UPSERT=false +WEBHOOK_EVENTS_PRESENCE_UPDATE=false +WEBHOOK_EVENTS_CHATS_SET=false +WEBHOOK_EVENTS_CHATS_UPDATE=false +WEBHOOK_EVENTS_CHATS_UPSERT=false +WEBHOOK_EVENTS_CHATS_DELETE=false +WEBHOOK_EVENTS_CONNECTION_UPDATE=false +WEBHOOK_EVENTS_LABELS_EDIT=false +WEBHOOK_EVENTS_LABELS_ASSOCIATION=false +WEBHOOK_EVENTS_GROUPS_UPSERT=false +WEBHOOK_EVENTS_GROUPS_UPDATE=false +WEBHOOK_EVENTS_GROUP_PARTICIPANTS_UPDATE=false +WEBHOOK_EVENTS_CALL=false +WEBHOOK_EVENTS_TYPEBOT_START=false +WEBHOOK_EVENTS_TYPEBOT_CHANGE_STATUS=false +WEBHOOK_EVENTS_ERRORS=false +WEBHOOK_EVENTS_ERRORS_WEBHOOK= + +# Configurações de webhook +WEBHOOK_REQUEST_TIMEOUT_MS=30000 +WEBHOOK_RETRY_MAX_ATTEMPTS=10 +WEBHOOK_RETRY_INITIAL_DELAY_SECONDS=5 +WEBHOOK_RETRY_USE_EXPONENTIAL_BACKOFF=true +WEBHOOK_RETRY_MAX_DELAY_SECONDS=300 +WEBHOOK_RETRY_JITTER_FACTOR=0.2 +WEBHOOK_RETRY_NON_RETRYABLE_STATUS_CODES=400,401,403,404,422 + +# =========================================== +# WEBSOCKET +# =========================================== +WEBSOCKET_ENABLED=true +WEBSOCKET_GLOBAL_EVENTS=true +WEBSOCKET_ALLOWED_HOSTS= + +# =========================================== +# RABBITMQ +# =========================================== +RABBITMQ_ENABLED=false +RABBITMQ_GLOBAL_ENABLED=false +RABBITMQ_PREFIX_KEY= +RABBITMQ_EXCHANGE_NAME=evolution_exchange +RABBITMQ_URI= +RABBITMQ_FRAME_MAX=8192 + +# =========================================== +# NATS +# =========================================== +NATS_ENABLED=false +NATS_GLOBAL_ENABLED=false +NATS_PREFIX_KEY= +NATS_EXCHANGE_NAME=evolution_exchange +NATS_URI= + +# =========================================== +# SQS +# =========================================== +SQS_ENABLED=false +SQS_GLOBAL_ENABLED=false +SQS_GLOBAL_FORCE_SINGLE_QUEUE=false +SQS_GLOBAL_PREFIX_NAME=global +SQS_ACCESS_KEY_ID= +SQS_SECRET_ACCESS_KEY= +SQS_ACCOUNT_ID= +SQS_REGION= +SQS_MAX_PAYLOAD_SIZE=1048576 + +# =========================================== +# PUSHER +# =========================================== +PUSHER_ENABLED=false +PUSHER_GLOBAL_ENABLED=false +PUSHER_GLOBAL_APP_ID= +PUSHER_GLOBAL_KEY= +PUSHER_GLOBAL_SECRET= +PUSHER_GLOBAL_CLUSTER= +PUSHER_GLOBAL_USE_TLS=false + +# =========================================== +# WHATSAPP BUSINESS +# =========================================== +WA_BUSINESS_TOKEN_WEBHOOK=evolution +WA_BUSINESS_URL=https://graph.facebook.com +WA_BUSINESS_VERSION=v18.0 +WA_BUSINESS_LANGUAGE=en + +# =========================================== +# CONFIGURAÇÕES DE SESSÃO +# =========================================== +CONFIG_SESSION_PHONE_CLIENT=Evolution API +CONFIG_SESSION_PHONE_NAME=Chrome + +# =========================================== +# QR CODE +# =========================================== +QRCODE_LIMIT=30 +QRCODE_COLOR=#198754 + +# =========================================== +# INTEGRAÇÕES +# =========================================== + +# Typebot +TYPEBOT_ENABLED=false +TYPEBOT_API_VERSION=old +TYPEBOT_SEND_MEDIA_BASE64=false + +# Chatwoot +CHATWOOT_ENABLED=false +CHATWOOT_MESSAGE_DELETE=false +CHATWOOT_MESSAGE_READ=false +CHATWOOT_BOT_CONTACT=true +CHATWOOT_IMPORT_DATABASE_CONNECTION_URI= +CHATWOOT_IMPORT_PLACEHOLDER_MEDIA_MESSAGE=false + +# OpenAI +OPENAI_ENABLED=false +OPENAI_API_KEY_GLOBAL= + +# Dify +DIFY_ENABLED=false + +# N8N +N8N_ENABLED=false + +# EvoAI +EVOAI_ENABLED=false + +# Flowise +FLOWISE_ENABLED=false + +# =========================================== +# S3 / MINIO +# =========================================== +S3_ENABLED=false +S3_ACCESS_KEY= +S3_SECRET_KEY= +S3_ENDPOINT= +S3_BUCKET= +S3_PORT=9000 +S3_USE_SSL=false +S3_REGION= +S3_SKIP_POLICY=false +S3_SAVE_VIDEO=false + +# =========================================== +# MÉTRICAS +# =========================================== +PROMETHEUS_METRICS=false +METRICS_AUTH_REQUIRED=false +METRICS_USER= +METRICS_PASSWORD= +METRICS_ALLOWED_IPS= + +# =========================================== +# TELEMETRIA +# =========================================== +TELEMETRY_ENABLED=true +TELEMETRY_URL= + +# =========================================== +# PROXY +# =========================================== +PROXY_HOST= +PROXY_PORT= +PROXY_PROTOCOL= +PROXY_USERNAME= +PROXY_PASSWORD= + +# =========================================== +# CONVERSOR DE ÁUDIO +# =========================================== +API_AUDIO_CONVERTER= +API_AUDIO_CONVERTER_KEY= + +# =========================================== +# FACEBOOK +# =========================================== +FACEBOOK_APP_ID= +FACEBOOK_CONFIG_ID= +FACEBOOK_USER_TOKEN= + +# =========================================== +# SENTRY +# =========================================== +SENTRY_DSN= + +# =========================================== +# EVENT EMITTER +# =========================================== +EVENT_EMITTER_MAX_LISTENERS=50 + +# =========================================== +# PROVIDER +# =========================================== +PROVIDER_ENABLED=false +PROVIDER_HOST= +PROVIDER_PORT=5656 +PROVIDER_PREFIX=evolution diff --git a/src/api/integrations/chatbot/base-chatbot.service.ts b/src/api/integrations/chatbot/base-chatbot.service.ts index 616d7c57..5ae43ffa 100644 --- a/src/api/integrations/chatbot/base-chatbot.service.ts +++ b/src/api/integrations/chatbot/base-chatbot.service.ts @@ -257,6 +257,55 @@ export abstract class BaseChatbotService { } } + /** + * Split message by double line breaks and return array of message parts + */ + private splitMessageByDoubleLineBreaks(message: string): string[] { + return message.split('\n\n').filter((part) => part.trim().length > 0); + } + + /** + * Send a single message with proper typing indicators and delays + */ + private async sendSingleMessage( + instance: any, + remoteJid: string, + message: string, + settings: any, + linkPreview: boolean = true, + ): Promise { + const timePerChar = settings?.timePerChar ?? 0; + const minDelay = 1000; + const maxDelay = 20000; + const delay = Math.min(Math.max(message.length * timePerChar, minDelay), maxDelay); + + this.logger.debug(`[BaseChatbot] Sending single message with linkPreview: ${linkPreview}`); + + if (instance.integration === Integration.WHATSAPP_BAILEYS) { + await instance.client.presenceSubscribe(remoteJid); + await instance.client.sendPresenceUpdate('composing', remoteJid); + } + + await new Promise((resolve) => { + setTimeout(async () => { + await instance.textMessage( + { + number: remoteJid.split('@')[0], + delay: settings?.delayMessage || 1000, + text: message, + linkPreview, + }, + false, + ); + resolve(); + }, delay); + }); + + if (instance.integration === Integration.WHATSAPP_BAILEYS) { + await instance.client.sendPresenceUpdate('paused', remoteJid); + } + } + /** * Helper method to send formatted text with proper typing indicators and delays */ @@ -268,68 +317,22 @@ export abstract class BaseChatbotService { splitMessages: boolean, linkPreview: boolean = true, ): Promise { - const timePerChar = settings?.timePerChar ?? 0; - const minDelay = 1000; - const maxDelay = 20000; - if (splitMessages) { - const multipleMessages = text.split('\n\n'); - for (let index = 0; index < multipleMessages.length; index++) { - const message = multipleMessages[index]; - if (!message.trim()) continue; + const messageParts = this.splitMessageByDoubleLineBreaks(text); - const delay = Math.min(Math.max(message.length * timePerChar, minDelay), maxDelay); + this.logger.debug(`[BaseChatbot] Splitting message into ${messageParts.length} parts`); - if (instance.integration === Integration.WHATSAPP_BAILEYS) { - await instance.client.presenceSubscribe(remoteJid); - await instance.client.sendPresenceUpdate('composing', remoteJid); - } + for (let index = 0; index < messageParts.length; index++) { + const message = messageParts[index]; - await new Promise((resolve) => { - setTimeout(async () => { - await instance.textMessage( - { - number: remoteJid.split('@')[0], - delay: settings?.delayMessage || 1000, - text: message, - linkPreview, - }, - false, - ); - resolve(); - }, delay); - }); - - if (instance.integration === Integration.WHATSAPP_BAILEYS) { - await instance.client.sendPresenceUpdate('paused', remoteJid); - } + this.logger.debug(`[BaseChatbot] Sending message part ${index + 1}/${messageParts.length}`); + await this.sendSingleMessage(instance, remoteJid, message, settings, linkPreview); } + + this.logger.debug(`[BaseChatbot] All message parts sent successfully`); } else { - const delay = Math.min(Math.max(text.length * timePerChar, minDelay), maxDelay); - - if (instance.integration === Integration.WHATSAPP_BAILEYS) { - await instance.client.presenceSubscribe(remoteJid); - await instance.client.sendPresenceUpdate('composing', remoteJid); - } - - await new Promise((resolve) => { - setTimeout(async () => { - await instance.textMessage( - { - number: remoteJid.split('@')[0], - delay: settings?.delayMessage || 1000, - text: text, - linkPreview, - }, - false, - ); - resolve(); - }, delay); - }); - - if (instance.integration === Integration.WHATSAPP_BAILEYS) { - await instance.client.sendPresenceUpdate('paused', remoteJid); - } + this.logger.debug(`[BaseChatbot] Sending single message`); + await this.sendSingleMessage(instance, remoteJid, text, settings, linkPreview); } } diff --git a/src/api/integrations/chatbot/dify/services/dify.service.ts b/src/api/integrations/chatbot/dify/services/dify.service.ts index 773efe49..dbf46e8f 100644 --- a/src/api/integrations/chatbot/dify/services/dify.service.ts +++ b/src/api/integrations/chatbot/dify/services/dify.service.ts @@ -107,7 +107,7 @@ export class DifyService extends BaseChatbotService { const conversationId = response?.data?.conversation_id; if (message) { - await this.sendMessageWhatsApp(instance, remoteJid, message, settings); + await this.sendMessageWhatsApp(instance, remoteJid, message, settings, true); } await this.prismaRepository.integrationSession.update({ @@ -169,7 +169,7 @@ export class DifyService extends BaseChatbotService { const conversationId = response?.data?.conversation_id; if (message) { - await this.sendMessageWhatsApp(instance, remoteJid, message, settings); + await this.sendMessageWhatsApp(instance, remoteJid, message, settings, true); } await this.prismaRepository.integrationSession.update({ @@ -246,7 +246,7 @@ export class DifyService extends BaseChatbotService { await instance.client.sendPresenceUpdate('paused', remoteJid); if (answer) { - await this.sendMessageWhatsApp(instance, remoteJid, answer, settings); + await this.sendMessageWhatsApp(instance, remoteJid, answer, settings, true); } await this.prismaRepository.integrationSession.update({ diff --git a/src/api/integrations/chatbot/evoai/services/evoai.service.ts b/src/api/integrations/chatbot/evoai/services/evoai.service.ts index 173ebe34..f901964f 100644 --- a/src/api/integrations/chatbot/evoai/services/evoai.service.ts +++ b/src/api/integrations/chatbot/evoai/services/evoai.service.ts @@ -174,7 +174,7 @@ export class EvoaiService extends BaseChatbotService { this.logger.debug(`[EvoAI] Extracted message to send: ${message}`); if (message) { - await this.sendMessageWhatsApp(instance, remoteJid, message, settings); + await this.sendMessageWhatsApp(instance, remoteJid, message, settings, true); } } catch (error) { this.logger.error( diff --git a/src/api/integrations/chatbot/flowise/services/flowise.service.ts b/src/api/integrations/chatbot/flowise/services/flowise.service.ts index 5505189c..4ee8c2e5 100644 --- a/src/api/integrations/chatbot/flowise/services/flowise.service.ts +++ b/src/api/integrations/chatbot/flowise/services/flowise.service.ts @@ -130,7 +130,7 @@ export class FlowiseService extends BaseChatbotService { if (message) { // Use the base class method to send the message to WhatsApp - await this.sendMessageWhatsApp(instance, remoteJid, message, settings); + await this.sendMessageWhatsApp(instance, remoteJid, message, settings, true); } } diff --git a/src/api/integrations/chatbot/n8n/services/n8n.service.ts b/src/api/integrations/chatbot/n8n/services/n8n.service.ts index 5bb40890..f1a6c387 100644 --- a/src/api/integrations/chatbot/n8n/services/n8n.service.ts +++ b/src/api/integrations/chatbot/n8n/services/n8n.service.ts @@ -78,7 +78,7 @@ export class N8nService extends BaseChatbotService { const message = response?.data?.output || response?.data?.answer; // Use base class method instead of custom implementation - await this.sendMessageWhatsApp(instance, remoteJid, message, settings); + await this.sendMessageWhatsApp(instance, remoteJid, message, settings, true); await this.prismaRepository.integrationSession.update({ where: { diff --git a/src/api/integrations/chatbot/openai/services/openai.service.ts b/src/api/integrations/chatbot/openai/services/openai.service.ts index dd00b04c..272d57fd 100644 --- a/src/api/integrations/chatbot/openai/services/openai.service.ts +++ b/src/api/integrations/chatbot/openai/services/openai.service.ts @@ -85,6 +85,7 @@ export class OpenaiService extends BaseChatbotService remoteJid, "Sorry, I couldn't transcribe your audio message. Could you please type your message instead?", settings, + true, ); return; } @@ -233,7 +234,7 @@ export class OpenaiService extends BaseChatbotService // Send the response if (message) { this.logger.log('Sending message to WhatsApp'); - await this.sendMessageWhatsApp(instance, remoteJid, message, settings); + await this.sendMessageWhatsApp(instance, remoteJid, message, settings, true); } else { this.logger.error('No message to send to WhatsApp'); } diff --git a/src/api/integrations/chatbot/typebot/services/typebot.service.ts b/src/api/integrations/chatbot/typebot/services/typebot.service.ts index 2e780dbf..68320367 100644 --- a/src/api/integrations/chatbot/typebot/services/typebot.service.ts +++ b/src/api/integrations/chatbot/typebot/services/typebot.service.ts @@ -318,7 +318,7 @@ export class TypebotService extends BaseChatbotService { } else if (formattedText.includes('[buttons]')) { await this.processButtonMessage(instance, formattedText, session.remoteJid); } else { - await this.sendMessageWhatsApp(instance, session.remoteJid, formattedText, settings); + await this.sendMessageWhatsApp(instance, session.remoteJid, formattedText, settings, true); } sendTelemetry('/message/sendText'); @@ -393,7 +393,7 @@ export class TypebotService extends BaseChatbotService { } else if (formattedText.includes('[buttons]')) { await this.processButtonMessage(instance, formattedText, session.remoteJid); } else { - await this.sendMessageWhatsApp(instance, session.remoteJid, formattedText, settings); + await this.sendMessageWhatsApp(instance, session.remoteJid, formattedText, settings, true); } sendTelemetry('/message/sendText'); @@ -642,15 +642,21 @@ export class TypebotService extends BaseChatbotService { if (!content) { if (unknownMessage) { - await this.sendMessageWhatsApp(waInstance, remoteJid, unknownMessage, { - delayMessage, - expire, - keywordFinish, - listeningFromMe, - stopBotFromMe, - keepOpen, + await this.sendMessageWhatsApp( + waInstance, + remoteJid, unknownMessage, - }); + { + delayMessage, + expire, + keywordFinish, + listeningFromMe, + stopBotFromMe, + keepOpen, + unknownMessage, + }, + true, + ); sendTelemetry('/message/sendText'); } return; @@ -801,15 +807,21 @@ export class TypebotService extends BaseChatbotService { if (!data?.messages || data.messages.length === 0) { if (!content) { if (unknownMessage) { - await this.sendMessageWhatsApp(waInstance, remoteJid, unknownMessage, { - delayMessage, - expire, - keywordFinish, - listeningFromMe, - stopBotFromMe, - keepOpen, + await this.sendMessageWhatsApp( + waInstance, + remoteJid, unknownMessage, - }); + { + delayMessage, + expire, + keywordFinish, + listeningFromMe, + stopBotFromMe, + keepOpen, + unknownMessage, + }, + true, + ); sendTelemetry('/message/sendText'); } return; @@ -903,15 +915,21 @@ export class TypebotService extends BaseChatbotService { if (!content) { if (unknownMessage) { - await this.sendMessageWhatsApp(waInstance, remoteJid, unknownMessage, { - delayMessage, - expire, - keywordFinish, - listeningFromMe, - stopBotFromMe, - keepOpen, + await this.sendMessageWhatsApp( + waInstance, + remoteJid, unknownMessage, - }); + { + delayMessage, + expire, + keywordFinish, + listeningFromMe, + stopBotFromMe, + keepOpen, + unknownMessage, + }, + true, + ); sendTelemetry('/message/sendText'); } return;