Sends a WhatsApp sticker via POST /messages/sticker.
The sticker must be in WebP format (image/webp).
Usage
whapi_send_sticker(
to,
sticker,
type = c("file", "url", "base64"),
token = Sys.getenv("WHAPI_TOKEN", unset = ""),
timeout = 30,
verbose = TRUE
)Arguments
- to
Character(1). WhatsApp target (E.164 digits only, no "+") or chat id.
- sticker
Character(1).
If type = "file": local
.webpfile path (will be read and encoded to Base64 data-URI).If type = "url": direct http(s) URL to the
.webpfile.If type = "base64": full data-URI string (e.g. "data:image/webp;name=st.webp;base64,<...>").
- type
One of c("file","url","base64"). Default = "file".
- token
Bearer token (env var WHAPI_TOKEN if not provided).
- timeout
Numeric. Request timeout (seconds). Default 30.
- verbose
Logical. Print CLI messages? Default TRUE.
Examples
if (FALSE) { # \dontrun{
Sys.setenv(WHAPI_TOKEN = "your_token_here")
# 1) Local file
whapi_send_sticker("558191812121",
sticker = "sticker.webp", type = "file")
# 2) Remote URL
whapi_send_sticker("558191812121",
sticker = "https://example.com/condepe.webp", type = "url")
# 3) Pre-encoded Base64
b64 <- openssl::base64_encode(readBin("sticker.webp","raw",file.info("sticker.webp")$size))
data_uri <- sprintf("data:image/webp;name=%s;base64,%s", basename("sticker.webp"), b64)
whapi_send_sticker("558191812121", sticker = data_uri, type = "base64")
} # }
