fix(evolutionbot): Fixing the correct message sending method so that messages are split. by dersonbsb2022 · Pull Request #1986 · EvolutionAPI/evolution-api · GitHub
Skip to content

fix(evolutionbot): Fixing the correct message sending method so that messages are split.#1986

Merged
DavidsonGomes merged 3 commits intoEvolutionAPI:developfrom
dersonbsb2022:main
Sep 22, 2025
Merged

fix(evolutionbot): Fixing the correct message sending method so that messages are split.#1986
DavidsonGomes merged 3 commits intoEvolutionAPI:developfrom
dersonbsb2022:main

Conversation

@dersonbsb2022
Copy link
Copy Markdown
Contributor

@dersonbsb2022 dersonbsb2022 commented Sep 20, 2025

  • 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

📋 Description

After adding linkpreview: false, messages were no longer being split correctly. Now it has been fixed, messages are being split, debouce time tested, linkpreview tested with true and false and working.

Summary by Sourcery

Improve messaging reliability by switching to the proper sendMessageWhatsApp method, re-enabling message splitting with delays and typing indicators, and fixing linkPreview support while cleaning up debug logging

New Features:

  • Support toggling link preview via webhook response

Bug Fixes:

  • Restore message splitting behavior and ensure messages are split at double line breaks
  • Fix linkPreview parameter propagation to messaging methods
  • Use the correct sendMessageWhatsApp method instead of textMessage to respect splitMessages settings

Enhancements:

  • Add typing indicators and delays between split messages
  • Remove unnecessary debug logs for cleaner output

DavidsonGomes and others added 2 commits September 18, 2025 14:55
- 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
Copilot AI review requested due to automatic review settings September 20, 2025 14:07
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Sep 20, 2025

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes message handling in the EvolutionBot by switching from direct instance.textMessage() calls to the base class sendMessageWhatsApp() method, enabling proper message splitting functionality and linkPreview parameter handling.

  • Replace direct textMessage() calls with base class method to enable message splitting
  • Add linkPreview parameter support throughout the message sending chain
  • Remove unnecessary debug logging for cleaner output

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/api/integrations/chatbot/evolutionBot/services/evolutionBot.service.ts Replaced direct textMessage() call with base class sendMessageWhatsApp() method and removed debug logs
src/api/integrations/chatbot/base-chatbot.service.ts Added linkPreview parameter to sendMessageWhatsApp() and sendFormattedText() methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Centralize the double-line-break message splitting logic into a dedicated helper to keep sendMessageWhatsApp focused and make the split behavior easier to unit-test.
  • Since most debug logs were removed, add back targeted, log-level-gated statements around key events (like before/after splitting and sending messages) to retain observability without clutter.
  • Ensure the new linkPreview parameter is reflected in all type definitions, mocks, and any callers of sendMessageWhatsApp, so the default-true behavior is consistently enforced.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Centralize the double-line-break message splitting logic into a dedicated helper to keep sendMessageWhatsApp focused and make the split behavior easier to unit-test.
- Since most debug logs were removed, add back targeted, log-level-gated statements around key events (like before/after splitting and sending messages) to retain observability without clutter.
- Ensure the new linkPreview parameter is reflected in all type definitions, mocks, and any callers of sendMessageWhatsApp, so the default-true behavior is consistently enforced.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

…istency

- 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
@DavidsonGomes DavidsonGomes changed the base branch from main to develop September 20, 2025 14:37
@dersonbsb2022
Copy link
Copy Markdown
Contributor Author

@dersonbsb2022 dersonbsb2022 changed the title fix(evolutionbot): Correcting to the correct message sending method so that messages are split correctly fix(evolutionbot): Fixing the correct message sending method so that messages are split. Sep 21, 2025
@DavidsonGomes DavidsonGomes merged commit d8b4378 into EvolutionAPI:develop Sep 22, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants