Overview
BaseBuilder is inherited by Button, ButtonV2, Carousel, andAIRich. It stores common fields and provides addPayload() for raw fields.
_title_subtitle_body_footer_contextInfo_extraPayloadawait new Button(sock)
.setTitle('Announcement')
.setSubtitle('Quick update')
.setBody('The server will undergo maintenance at 11:00 PM UTC.')
.setFooter('Operations team')
.setContextInfo({ forwardingScore: 1, isForwarded: true })
.addReply('Understood', 'ok')
.send(jid);Methods
setTitle
chainable.setTitle(title)Sets the message header title.
Parameter
| Parameter | Type | Default | Description |
|---|---|---|---|
titlerequired | string | — | Header title. |
this- Throws a TypeError when the value is not a string.
setSubtitle
chainable.setSubtitle(subtitle)Sets the message header subtitle.
Parameter
| Parameter | Type | Default | Description |
|---|---|---|---|
subtitlerequired | string | — | Header subtitle. |
thissetBody
chainable.setBody(body)Sets the main message body.
Parameter
| Parameter | Type | Default | Description |
|---|---|---|---|
bodyrequired | string | — | Body text. |
thissetContextInfo
chainable.setContextInfo(obj)Replaces the entire contextInfo object, for example for quoted messages, mentions, or forwarding metadata.
Parameter
| Parameter | Type | Default | Description |
|---|---|---|---|
objrequired | object | — | A plain contextInfo object. |
this- Throws a TypeError when the value is not a plain object.
addPayload
chainable.addPayload(obj)Merges additional fields into the final root payload. Useful for raw WhatsApp fields without a dedicated method.
Parameter
| Parameter | Type | Default | Description |
|---|---|---|---|
objrequired | object | — | Fields merged with Object.assign. |
thisbutton.addPayload({ messageContextInfo: { deviceListMetadataVersion: 2 } });Notes
Chainable
Every setter returns this, so calls can be chained in a single expression.
Order matters mainly for lists
Setters can be called at any point before build(). For lists, the addSelection → makeSection → makeRow order is important.
Do not rely on order for lists
addSelection(), makeSection(), and makeRow() depend on active state. General setters can still be called at any time.