Skip to content

Internal helper that prepares mixed action buttons for Whapi interactive messages. It first normalizes input via whapi_coerce_buttons_base() (accepts data.frame/tibble or list, maps aliases to title, auto-creates id with slug + uniqueness) and then validates each button according to its declared type:

  • url -> requires fields: title, id, url

  • call -> requires fields: title, id, phone_number

  • copy -> requires fields: title, id, copy_code

Enforces WhatsApp constraints: 1 to 3 buttons per message.

Usage

whapi_coerce_buttons_mixed(buttons, verbose = TRUE)

Arguments

buttons

A data.frame/tibble (one row per button) or a list of named lists. title is required (or via alias), id is auto-generated when missing by whapi_coerce_buttons_base(). Each button must provide a valid type among {"url","call","copy"}.

verbose

Logical (default TRUE). If TRUE, prints progress messages via cli.

Value

A list-of-lists of buttons, each validated to contain the fields required for its type.

See also

whapi_coerce_buttons_base() for normalization; whapi_coerce_buttons_quick() for quick-reply buttons.

Examples

# Example with a tibble:
# tibble::tribble(
#   ~title,        ~type, ~url,
#   "Website",     "url", "https://example.com",
#   "Call Support","call", NA
# ) |>
#   whapi_coerce_buttons_base() |>
#   whapi_coerce_buttons_mixed()

# Example with a list:
# whapi_coerce_buttons_mixed(list(
#   list(type="url",  title="Website", url="https://example.com"),
#   list(type="call", title="Call us", phone_number="5581999999999"),
#   list(type="copy", title="Copy OTP", copy_code="123456")
# ))