Skip to content

Conversation

dersonbsb2022
Copy link
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 Copilot AI review requested due to automatic review settings September 20, 2025 14:07
Copy link
Contributor

sourcery-ai bot commented Sep 20, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR refactors EvolutionBot’s WhatsApp messaging flow to use the unified sendMessageWhatsApp method (enabling proper splitting on double line breaks with delays and typing indicators), ensures linkPreview is parsed and passed correctly, and removes unnecessary debug logs.

File-Level Changes

Change Details Files
Migrate messaging to sendMessageWhatsApp and clean up debug logs
  • Replaced instance.textMessage calls with sendMessageWhatsApp
  • Removed redundant logger.debug statements around request/response/message
  • Updated BaseChatbotService methods to accept linkPreview parameter
evolutionBot.service.ts
base-chatbot.service.ts
Ensure correct linkPreview parsing and propagation
  • Validate rawLinkPreview as boolean or default to true
  • Support linkPreview: false/true from webhook
  • Propagate linkPreview through all sendFormattedText/sendMessageWhatsApp calls
evolutionBot.service.ts
base-chatbot.service.ts
Enable message splitting with delays and presence updates
  • Split messages on double line breaks in sendFormattedText
  • Apply configured delay between chunks
  • Maintain typing indicator via sendPresenceUpdate before sending each batch
evolutionBot.service.ts
base-chatbot.service.ts

Possibly linked issues

  • Docker folder is deleted #1: PR's message sending method refactor, enabling correct splitting and link preview, resolves the Typebot integration applyFormatting error.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@Copilot 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
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
Contributor Author

Desculpe @DavidsonGomes, acabei esquecendo de selecionar o branch develop :(

@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
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.

2 participants