Skip to content

Send a text message via Whapi.Cloud

Usage

whapi_send_text(
  to,
  body,
  token = Sys.getenv("WHAPI_TOKEN", unset = ""),
  quoted = NULL,
  edit = NULL,
  typing_time = NULL,
  no_link_preview = NULL,
  wide_link_preview = NULL,
  mentions = NULL,
  view_once = NULL,
  timeout = 30,
  verbose = TRUE
)

Arguments

to

Character. WhatsApp number in full international format WITHOUT "+" (digits only, e.g. "5581999999999"), or an existing group/channel id.

body

Character. Text of the message (UTF-8).

token

Character. Whapi Bearer token. By default, taken from the environment variable WHAPI_TOKEN if not provided.

quoted, edit

Character (optional). Message IDs to quote or edit.

typing_time

Numeric (optional). Seconds to simulate typing.

Logical (optional). TRUE to disable link preview.

Logical (optional). TRUE to enable wide preview for links.

mentions

Character vector (optional). Numbers to mention (without "+"). Remember to include @ inside the message body as well.

view_once

Logical (optional). TRUE to mark message as "view once".

timeout

Numeric. Request timeout in seconds. Default: 30.

verbose

Logical. Print messages via cli? Default: TRUE.

Value

A tibble with essential information (id, to, status, timestamp) and the full API response in column resp (as list).

Examples

if (FALSE) { # \dontrun{
# Make sure you set WHAPI_TOKEN in your environment or pass via argument
 Sys.setenv(WHAPI_TOKEN = "your_token_here")

# Simple example:
 whapi_send_text("5581999999999", "Hello! Test message via API")

# With extra options:
 whapi_send_text(
   to = "5581999999999",
   body = "Hello, @5581999999999 Ola",
   mentions = c("5581999999999"),
   typing_time = 2, no_link_preview = TRUE
 )
 } # }