| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
On the Cloud API (WhatsApp Business) channel, sendButtons hardcoded every
button to type "reply", so a button with type "url" failed with
"interactive.action.buttons.0.reply is required: id" (code 100). This made it
impossible to send a link (CTA URL) button in a free-form session message,
even though the Cloud API supports it via the interactive "cta_url" type.
This preserves url buttons through buttonMessage and, when a cta_url button is
present, builds an interactive cta_url message
(action.name = "cta_url", parameters = { display_text, url }) instead of the
reply-button payload. Per the Cloud API, cta_url allows a single link button and
cannot be combined with reply buttons, so the first url button wins.
The reply-button path is unchanged. The internal text echo now falls back to the
button displayText so cta_url buttons no longer render as "undefined".
Closes evolution-foundation#1249
Reviewer's GuideSupport CTA URL (link) buttons in Cloud API WhatsApp sendButtons by mapping URL buttons to WhatsApp interactive cta_url messages and preserving their display text in internal echoes, while keeping existing reply-button behavior unchanged. Sequence diagram for WhatsApp Cloud API sendButtons CTA URL handlingsequenceDiagram
participant Client
participant BusinessStartupService
participant MetaCloudAPI
Client->>BusinessStartupService: sendMessageWithTyping(message_with_buttons)
alt [cta_url button present]
BusinessStartupService->>BusinessStartupService: build cta_url interactive content
BusinessStartupService->>MetaCloudAPI: post(content, messages)
MetaCloudAPI-->>BusinessStartupService: response with wamid
else [no cta_url button]
BusinessStartupService->>BusinessStartupService: build reply interactive content
BusinessStartupService->>MetaCloudAPI: post(content, messages)
MetaCloudAPI-->>BusinessStartupService: response with wamid
end
Flow diagram for buttonMessage URL to cta_url mappingflowchart TD
A[buttonMessage receives data.buttons] --> B{button.type === url?}
B -->|Yes| C[Create button with type cta_url]
C --> D[Set displayText and url]
D --> F[Return mapped buttons]
B -->|No| E[Create button with type reply and reply.title]
E --> F[Return mapped buttons]
File-Level Changes
Possibly linked issues
Tips and commands Interacting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Sorry, something went wrong.
There was a problem hiding this comment.
Hey - I've left some high level feedback:
Please address the comments from this code review:
## Overall Comments
- The `quoted ? (content.context = { message_id: quoted.id }) : content;` ternary in the new cta_url branch is a no-op on the false path and harder to read; consider replacing it with a simple `if (quoted) { content.context = { message_id: quoted.id }; }` for clarity.
- In the cta_url mapping within `sendButtons`, you are assuming `displayText` and `url` are always present; if these can be user-provided, consider guarding against undefined values or falling back consistently (similar to the `reply?.title ?? displayText` echo).
Sorry, something went wrong.
Address review: use an if for the quoted context instead of the no-op ternary, only treat a url button as cta_url when it actually has a url, and fall back display_text to the url when displayText is absent.
|
@gomessguii @pastoriniMatheus |
Sorry, something went wrong.
|
@gomessguii Ajuda a gente, cara! Isso é muito bom pra o uso da WCloud na evolution! hahaha |
Sorry, something went wrong.
|
Some extra context for whoever picks this up, because this PR fixes a defect the tracker currently believes is already fixed. Issue #1249 (Feb 2025) reports exactly the payload this PR handles: {
"number": "{{ remoteJid }}",
"buttons": [
{ "type": "url", "displayText": "Google", "url": "https://google.com" }
]
}It was closed as completed on 2025-09-09, with no closing comment and no linked fix commit. 355 issues in this repo were closed that same day, so it reads as a backlog sweep rather than a resolution. The defect is still on develop today. In src/api/integrations/channel/meta/whatsapp.business.service.ts (L1538), every button is mapped with a hardcoded type: buttons: data.buttons.map((button) => {
return {
type: 'reply',
reply: {
title: button.displayText,
id: button.id,
},
};
}),There is no cta_url path there. Across the whole repository cta_url appears in exactly one file — whatsapp.baileys.service.ts, the QR-code channel. So on the Cloud API channel a URL button has never been representable: it is coerced into a reply button (with id undefined for a type: "url" input) and handed to Meta in a shape it will not accept. The exact error string may have shifted since the v2.2.3 the reporter was on; the structural gap is what I verified against current develop. That is what these 39 lines add: detect a URL button, emit the interactive / cta_url payload the Cloud API actually expects, and leave the reply-button path untouched. CI is green and both points from the Sourcery review were addressed in dd7d91c. cc @dpaes @agasalhem — you both asked about this one. If #1249 is worth reopening or linking, the pointer above is the evidence. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What
Add support for CTA URL (link) buttons in sendButtons on the Cloud API (WhatsApp Business) channel.
Why
On the Cloud API channel, buttonMessage mapped every button to type: 'reply', so sending a button with type: 'url' failed at Meta with:
This made it impossible to send a link button in a free-form (session) message, even though the Cloud API supports it through the interactive cta_url type. Reported in #1249.
How
Request example
POST /message/sendButtons/{instance} { "number": "5599999999999", "title": "Your gallery is ready!", "buttons": [ { "type": "url", "displayText": "Open gallery", "url": "https://example.com/g/abc" } ] }Testing
Tested against a live WhatsApp Business (Cloud API) number: the button is accepted by Meta (returns a wamid) and renders as a tappable link button inside the 24h session window. Existing reply-button sends are unaffected.
Closes #1249
Summary by Sourcery
Add support for CTA URL buttons in WhatsApp Cloud API sendButtons so link buttons can be sent as interactive messages in session conversations.
New Features:
Enhancements: