Skip to content

Internal helper that constructs the standard structure shared by Whapi interactive messages (button, list, mixed actions, etc.).

It automatically normalizes the recipient (to) using whapi_normalize_to(), and creates header, body, and footer blocks only if the corresponding text is provided.

Usage

whapi_common_blocks(to, body_text, header_text = NULL, footer_text = NULL)

Arguments

to

Character(1). Recipient phone number in international format (digits only, no +), or a group/channel id.

body_text

Character(1). Main text of the interactive message body.

header_text

Character(1), optional. Optional header text.

Character(1), optional. Optional footer text.

Value

A named list ready to be merged into a Whapi interactive message payload, containing elements: to, header (if provided), body, and footer (if provided).

Details

Many Whapi interactive endpoints (e.g., messages/interactive) require the same basic structure:

  • to: target number or chat id;

  • header: optional text shown above the body;

  • body: main message text (required);

  • footer: optional small text shown below the body.

This helper ensures consistency and avoids repeating boilerplate code when building different interactive message payloads.

Examples

if (FALSE) { # \dontrun{
# Minimal body only

whapi_common_blocks("5581999999999", body_text = "Choose an option below")

# With header and footer
whapi_common_blocks(
  to = "5581999999999",
  body_text   = "Do you confirm?",
  header_text = "Booking Confirmation",
  footer_text = "Reply now"
)
} # }