evolution-api icon indicating copy to clipboard operation
evolution-api copied to clipboard

Feature/quote message n8n

Open jamesjhonatan123 opened this issue 1 month ago • 3 comments

📋 Description This PR addresses an issue where the quotedMessage information was missing from the payload sent to N8N webhooks. When a user replied to a message, the N8N workflow received the new message content but lacked the context of the quoted message, unlike the standard webhook behavior.

This change adds the quotedMessage field to the N8N payload, extracting it from msg.contextInfo.quotedMessage, ensuring that workflows can properly handle replies and context.

🧪 Type of Change ✨ New feature (non-breaking change which adds functionality) Manual testing completed Functionality verified in development environment and production environment No breaking changes introduced Tested with different connection types (if applicable) Testing Details: Verified that when a message is replied to in WhatsApp, the N8N webhook now receives the quotedMessage object containing the original message content.

📸 Screenshots (if applicable) Captura de tela de 2025-11-19 00-00-15

✅ Checklist My code follows the project's style guidelines I have performed a self-review of my code I have commented my code, particularly in hard-to-understand areas I have made corresponding changes to the documentation My changes generate no new warnings I have manually tested my changes thoroughly I have verified the changes work with different scenarios Any dependent changes have been merged and published 📝 Additional Notes This aligns the N8N integration payload more closely with the standard webhook payload regarding quoted messages.

Summary by Sourcery

Enable N8N workflows to receive quoted message context when relaying WhatsApp replies and clean up code formatting in the proxy agent utility.

New Features:

  • Include the quotedMessage field from msg.contextInfo in the payload sent to N8N webhooks

Enhancements:

  • Standardize formatting and semicolon usage in the makeProxyAgent implementation with no functional changes

jamesjhonatan123 avatar Nov 19 '25 03:11 jamesjhonatan123

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR ensures that when handling WhatsApp message replies, the original quoted message context is propagated through the N8N integration by extracting and including the quotedMessage field in the webhook payload, while also standardizing code style in the proxy agent utility.

Sequence diagram for WhatsApp reply message payload to N8N webhook

sequenceDiagram
    participant User as actor User
    participant WhatsApp
    participant "Chatbot Service"
    participant N8N
    User->>WhatsApp: Reply to a message
    WhatsApp->>"Chatbot Service": Send message with contextInfo.quotedMessage
    "Chatbot Service"->>N8N: Send webhook payload (includes quotedMessage)
    N8N->>"Chatbot Service": Process payload (now with quotedMessage)

Class diagram for updated N8nService payload structure

classDiagram
    class N8nService {
        +sendWebhookPayload(msg, instance)
    }
    class Message {
        +key
        +contextInfo
    }
    class ContextInfo {
        +quotedMessage
    }
    N8nService --> Message : uses
    Message --> ContextInfo : has
    ContextInfo : quotedMessage

File-Level Changes

Change Details Files
Include quotedMessage in N8N webhook payload
  • Extract quotedMessage from msg.contextInfo
  • Add quotedMessage property to payload object
src/api/integrations/chatbot/n8n/services/n8n.service.ts
Standardize formatting and semicolon usage in proxy agent utility
  • Add missing semicolons after declarations
  • Reformat import and variable declarations for consistency
src/utils/makeProxyAgent.ts

Possibly linked issues

  • #Issue-1: PR ensures N8N webhooks receive quoted message context, directly addressing the reported N8N automation breakdown.

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

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Nov 19 '25 03:11 sourcery-ai[bot]

fix the lint please, use npm run lint

DavidsonGomes avatar Nov 19 '25 20:11 DavidsonGomes

I ran npm run lint and fixed all lint issues — that’s why the changes above appeared.

In that specific section:

image
module.exports = {
  semi: true,
  trailingComma: 'all',
  singleQuote: true,
  printWidth: 120,
  arrowParens: 'always',
  tabWidth: 2,
  useTabs: false,
  bracketSameLine: false,
  bracketSpacing: true,
  parser: 'typescript'
}

The project’s ESLint config has "semi": true, so semicolons are required.

image

jamesjhonatan123 avatar Nov 19 '25 20:11 jamesjhonatan123