Learn R Programming

whapi (version 0.0.2)

whapi_send_mixed_actions: Send a WhatsApp interactive message mixing URL/CALL/COPY buttons (Whapi.Cloud)

Description

Sends an interactive buttons message that mixes url, call, and/or copy actions. Input buttons are normalized/validated by whapi_coerce_buttons_mixed() (aliases mapped to title, auto id creation, required fields per type).

Usage

whapi_send_mixed_actions(
  to,
  body_text,
  buttons,
  header_text = NULL,
  footer_text = NULL,
  token = Sys.getenv("WHAPI_TOKEN", unset = ""),
  timeout = 30,
  verbose = TRUE
)

Value

A tibble with fields id, to, status, timestamp, and the raw response in resp.

Arguments

to

Character(1). Phone in E.164 digits (without "+") or group id.

body_text

Character(1). Main body text.

buttons

Data frame or list. Up to 3 items; each must define a type in {'url','call','copy'} and include the fields:

  • url: title, id, url

  • call: title, id, phone_number

  • copy: title, id, copy_code (id is auto-generated if missing; title required)

header_text, footer_text

Character (optional). Header/footer texts.

token

Bearer token. Defaults to env var WHAPI_TOKEN.

timeout

Numeric. Request timeout (seconds). Default 30.

verbose

Logical. Print CLI messages? Default TRUE.

See Also

whapi_coerce_buttons_mixed(), whapi_common_blocks(), whapi_perform_request()

Examples

Run this code
if (FALSE) {
 Sys.setenv(WHAPI_TOKEN = "your_token_here")
 whapi_send_mixed_actions(
   to = "5581999999999",
   body_text = "Pick an option:",
   buttons = 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")
   )
 )
}

Run the code above in your browser using DataLab