
Coerce and validate MIXED buttons (url / call / copy) for Whapi
Source:R/utils.R
whapi_coerce_buttons_mixed.RdInternal 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,urlcall-> requires fields:title,id,phone_numbercopy-> requires fields:title,id,copy_code
Enforces WhatsApp constraints: 1 to 3 buttons per message.
Arguments
A
data.frame/tibble(one row per button) or a list of named lists.titleis required (or via alias),idis auto-generated when missing bywhapi_coerce_buttons_base(). Each button must provide a validtypeamong{"url","call","copy"}.- verbose
Logical (default
TRUE). IfTRUE, prints progress messages via cli.
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")
# ))