Learn R Programming

whapi (version 0.0.2)

whapi_send_text: Send a text message via Whapi.Cloud

Description

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
)

Value

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

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.

no_link_preview

Logical (optional). TRUE to disable link preview.

wide_link_preview

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

mentions

Character vector (optional). Numbers to mention (without "+").

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.

Examples

Run this code
if (FALSE) {
# 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
 )
 }

Run the code above in your browser using DataLab