Sends an interactive LIST message via Whapi.
Sections/rows are validated by whapi_validate_list_sections(). The payload
reuses whapi_common_blocks() to keep structure consistent across interactive
message types.
Usage
whapi_send_list(
to,
body_text,
list_sections,
list_label = "Choose...",
header_text = NULL,
footer_text = NULL,
token = Sys.getenv("WHAPI_TOKEN", unset = ""),
timeout = 30,
verbose = TRUE
)Arguments
- to
Character(1). Phone in E.164 digits (without "+") or group id.
- body_text
Character(1). Main body text.
- list_sections
A list of sections. Each section is a named list:
list(title = <chr>, rows = list(list(id=<chr>, title=<chr>, description=<chr>?), ...)).- list_label
Character(1), optional. Button label that opens the list. Default:
"Choose..."Character(1), optional. Header/footer texts.
- token
Bearer token. Defaults to env var
WHAPI_TOKEN.- timeout
Numeric. Request timeout in seconds. Default 30.
- verbose
Logical. Print CLI messages? Default TRUE.
Examples
if (FALSE) { # \dontrun{
Sys.setenv(WHAPI_TOKEN = "your_token_here")
sections <- list(
list(
title = "Burgers",
rows = list(
list(id="b1", title="Plain", description="No cheese, no sauce"),
list(id="b2", title="Cheese", description="With melted cheese")
)
),
list(
title = "Drinks",
rows = list(
list(id="d1", title="Water"),
list(id="d2", title="Soda", description="Assorted flavors")
)
)
)
whapi_send_list(
to = "5581999999999",
body_text = "Choose your order:",
list_sections = sections,
list_label = "Open menu",
header_text = "Our Menu",
footer_text = "Thanks!"
)
} # }
