Learn R Programming

whapi (version 0.0.2)

whapi_common_blocks: Build common message blocks for Whapi interactive messages

Description

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)

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

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.

footer_text

Character(1), optional. Optional footer text.

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.

See Also

whapi_send_quick_reply(), whapi_send_list(), whapi_send_mixed_actions()

Examples

Run this code
if (FALSE) {
# 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"
)
}

Run the code above in your browser using DataLab