
Coerce and normalize button specs for Whapi interactive messages
Source:R/utils.R
whapi_coerce_buttons_base.RdInternal helper that converts a data.frame/tibble or list of button
definitions into a normalized list-of-lists, applying a few rules:
Accepts aliases
label/nameand maps them totitle;Requires a non-empty
title;Auto-generates
idwhen missing using slugification plus uniqueness enforcement (e.g.,"Buy Now" -> "buy_now", duplicates become"buy_now_2","buy_now_3", ...).
This is useful before building payloads for Whapi interactive endpoints (e.g., buttons, mixed actions, etc.).
Value
A list of named lists (one per button), each guaranteed to have
at least title (non-empty). If a button had no id, a slugified,
unique id is created.
Examples
# From tibble (title only -> ids auto-generated)
# tibble::tribble(~title, "Buy Now", "Buy Now", "Learn More") |>
# whapi_coerce_buttons_base()
# From list (mix with/without id)
# whapi_coerce_buttons_base(list(
# list(title = "Website", url = "https://example.com"),
# list(title = "Website") # will get an auto id too
# ))