-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Feature/quote message n8n #2238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Feature/quote message n8n #2238
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis 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 webhooksequenceDiagram
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 structureclassDiagram
class N8nService {
+sendWebhookPayload(msg, instance)
}
class Message {
+key
+contextInfo
}
class ContextInfo {
+quotedMessage
}
N8nService --> Message : uses
Message --> ContextInfo : has
ContextInfo : quotedMessage
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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 and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/utils/makeProxyAgent.ts:63-64` </location>
<code_context>
- const auth = username && password ? `${username}:${password}@` : ''
- proxyUrl = `${protocol}://${auth}${host}:${port}`
+ const auth = username && password ? `${username}:${password}@` : '';
+ proxyUrl = `${protocol}://${auth}${host}:${port}`;
}
</code_context>
<issue_to_address>
**suggestion:** Authentication string construction may not handle special characters in username or password.
Encoding the username and password will prevent malformed URLs when special characters are present.
```suggestion
const encodedUsername = username ? encodeURIComponent(username) : '';
const encodedPassword = password ? encodeURIComponent(password) : '';
const auth = encodedUsername && encodedPassword ? `${encodedUsername}:${encodedPassword}@` : '';
proxyUrl = `${protocol}://${auth}${host}:${port}`;
```
</issue_to_address>
### Comment 2
<location> `src/utils/makeProxyAgent.ts:79-80` </location>
<code_context>
default:
- throw new Error(`Unsupported proxy protocol: ${protocol}`)
+ throw new Error(`Unsupported proxy protocol: ${protocol}`);
}
}
</code_context>
<issue_to_address>
**suggestion:** Error message could include the original input for better debugging.
Adding the full proxy input to the error message will make it easier to diagnose issues with malformed or unexpected input.
```suggestion
default:
throw new Error(`Unsupported proxy protocol: ${protocol}. Full proxy input: ${typeof proxy === 'string' ? proxy : JSON.stringify(proxy)}`);
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| const auth = username && password ? `${username}:${password}@` : ''; | ||
| proxyUrl = `${protocol}://${auth}${host}:${port}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Authentication string construction may not handle special characters in username or password.
Encoding the username and password will prevent malformed URLs when special characters are present.
| const auth = username && password ? `${username}:${password}@` : ''; | |
| proxyUrl = `${protocol}://${auth}${host}:${port}`; | |
| const encodedUsername = username ? encodeURIComponent(username) : ''; | |
| const encodedPassword = password ? encodeURIComponent(password) : ''; | |
| const auth = encodedUsername && encodedPassword ? `${encodedUsername}:${encodedPassword}@` : ''; | |
| proxyUrl = `${protocol}://${auth}${host}:${port}`; |
|
|
||
| default: | ||
| throw new Error(`Unsupported proxy protocol: ${protocol}`) | ||
| throw new Error(`Unsupported proxy protocol: ${protocol}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Error message could include the original input for better debugging.
Adding the full proxy input to the error message will make it easier to diagnose issues with malformed or unexpected input.
| default: | |
| throw new Error(`Unsupported proxy protocol: ${protocol}`) | |
| throw new Error(`Unsupported proxy protocol: ${protocol}`); | |
| default: | |
| throw new Error(`Unsupported proxy protocol: ${protocol}. Full proxy input: ${typeof proxy === 'string' ? proxy : JSON.stringify(proxy)}`); |
There was a problem hiding this 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 adds support for quoted message context in N8N webhook payloads. When a user replies to a message in WhatsApp, the N8N workflow now receives the quotedMessage field containing the original message content, aligning the N8N integration with standard webhook behavior.
- Adds
quotedMessagefield to N8N webhook payload extracted frommsg.contextInfo.quotedMessage - Includes code formatting improvements (semicolon additions) in makeProxyAgent.ts
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/utils/makeProxyAgent.ts | Code formatting improvements - added missing semicolons throughout the file for consistency |
| src/api/integrations/chatbot/n8n/services/n8n.service.ts | Added quotedMessage field to the N8N webhook payload to provide reply context |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else { | ||
| const { host, password, port, protocol: proto, username } = proxy | ||
| protocol = (proto || 'http').replace(':', '') | ||
| const { host, password, port, protocol: proto, username } = proxy; |
Check failure
Code scanning / CodeQL
Insecure randomness High
Math.random()
| } else { | ||
| const { host, password, port, protocol: proto, username } = proxy | ||
| protocol = (proto || 'http').replace(':', '') | ||
| const { host, password, port, protocol: proto, username } = proxy; |
Check failure
Code scanning / CodeQL
Insecure randomness High
Math.random()
| } else { | ||
| const { host, password, port, protocol: proto, username } = proxy | ||
| protocol = (proto || 'http').replace(':', '') | ||
| const { host, password, port, protocol: proto, username } = proxy; |
Check failure
Code scanning / CodeQL
Insecure randomness High
Math.random()
| } else { | ||
| const { host, password, port, protocol: proto, username } = proxy | ||
| protocol = (proto || 'http').replace(':', '') | ||
| const { host, password, port, protocol: proto, username } = proxy; |
Check failure
Code scanning / CodeQL
Insecure randomness High
Math.random()
| } else { | ||
| const { host, password, port, protocol: proto, username } = proxy | ||
| protocol = (proto || 'http').replace(':', '') | ||
| const { host, password, port, protocol: proto, username } = proxy; |
Check failure
Code scanning / CodeQL
Insecure randomness High
Math.random()
|
fix the lint please, use |


📋 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)

✅ 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:
Enhancements: