-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Description
Reviewer's Guide
Adds Typebot support for sending file/embed blocks as WhatsApp media/audio and introduces active URL scraping to reliably generate WhatsApp link previews, wiring the preview context into the Baileys send flow while preserving explicit linkPreview disabling.
Sequence diagram for WhatsApp active link preview generation
sequenceDiagram
actor User
participant ClientApp
participant BaileysStartupService
participant LinkPreviewJS
participant WhatsAppServer
User ->> ClientApp: Send text message with URL
ClientApp ->> BaileysStartupService: sendMessage(sender, message, options, group)
activate BaileysStartupService
BaileysStartupService ->> BaileysStartupService: determine linkPreview flag
alt linkPreview explicitly disabled
BaileysStartupService ->> WhatsAppServer: send message without previewContext
else linkPreview enabled or undefined
BaileysStartupService ->> BaileysStartupService: generateLinkPreview(text)
activate BaileysStartupService
BaileysStartupService ->> LinkPreviewJS: getLinkPreview(url, headers)
LinkPreviewJS -->> BaileysStartupService: previewData(title, description, images)
BaileysStartupService ->> BaileysStartupService: build externalAdReply context
deactivate BaileysStartupService
BaileysStartupService ->> WhatsAppServer: send message with previewContext
end
WhatsAppServer -->> User: Deliver message with rich link preview
Sequence diagram for Typebot file and embed message handling to WhatsApp
sequenceDiagram
actor TypebotFlow
participant TypebotService
participant WhatsAppInstance
participant WhatsAppServer
TypebotFlow ->> TypebotService: Emit outgoing message
TypebotService ->> TypebotService: Inspect message.type
alt message.type is file or embed
TypebotService ->> TypebotService: Extract content.url and content.name
TypebotService ->> TypebotService: mediaType = getMediaType(mediaUrl)
TypebotService ->> TypebotService: Derive fileName if missing
alt mediaType is audio
TypebotService ->> WhatsAppInstance: audioWhatsapp(number, delay, encoding, audioUrl)
else other media type
TypebotService ->> WhatsAppInstance: mediaMessage(number, delay, mediatype, mediaUrl, fileName)
end
TypebotService ->> TypebotService: sendTelemetry(/message/sendMedia)
else other message types
TypebotService ->> WhatsAppInstance: Existing handling for text, image, etc.
end
WhatsAppInstance ->> WhatsAppServer: Forward WhatsApp message
WhatsAppServer -->> TypebotFlow: Message delivered to end user
Updated class diagram for BaileysStartupService and TypebotService message handling
classDiagram
class BaileysStartupService {
+sendMessage(sender:string, message:any, options:any, group:any, previewContext:any) Promise~any~
-generateLinkPreview(text:string) Promise~any~
}
class TypebotService {
+handleTypebotMessage(instance:any, session:any, message:any, settings:any) Promise~any~
-getMediaType(mediaUrl:string) string
}
TypebotService --> BaileysStartupService : uses for WhatsApp delivery
class LinkPreviewJS {
+getLinkPreview(url:string, options:any) Promise~any~
}
BaileysStartupService --> LinkPreviewJS : generates link previews using
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Implement active link preview generation for WhatsApp text messages and inject result into sent message context. |
|
src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts |
| Add Typebot support for file and embed message types by routing them through existing WhatsApp media/audio send helpers. |
|
src/api/integrations/chatbot/typebot/services/typebot.service.ts |
| Minor formatting/indentation adjustments in BaileysStartupService. |
|
src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts |
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon 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 issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull
request title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment@sourcery-ai summaryon the pull request to
(re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull
request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon 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 dismisson 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 reviewto 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.
Originally posted by @sourcery-ai in #2347 (comment)
Metadata
Metadata
Assignees
Labels
No labels