Package 'waservix'

Title: Client for the 'WAservix' 'WhatsApp' API Gateway
Description: Client for the 'WAservix' 'WhatsApp' API Gateway <https://tekservix.com/waservix/>, which sends 'WhatsApp' messages from your own number connected by QR code. Send texts, images, documents and locations to numbers and groups, check message status, edit, delete and resend messages, check whether a number uses 'WhatsApp', list contacts and groups, and verify incoming event notifications. A 'Tekservix' account with 'WAservix' and a device API key are required.
Authors: Joseph Niyogushimwa [aut, cre], Tekservix [cph, fnd]
Maintainer: Joseph Niyogushimwa <[email protected]>
License: MIT + file LICENSE
Version: 1.0.1
Built: 2026-12-04 20:10:58 UTC
Source: https://github.com/cran/waservix

Help Index


Create a WAservix client

Description

Create a WAservix client

Usage

waservix_client(
  key = Sys.getenv("WASERVIX_API_KEY"),
  base_url = "https://tekservix.com/waservix/api"
)

Arguments

key

The device API key of your WhatsApp number (starts with wpk_). Defaults to the WASERVIX_API_KEY environment variable.

base_url

API base URL. Change it only for tests or a proxy.

Value

An object of class waservix_client, used by every other function.

Examples

client <- waservix_client("wpk_your_device_key")

Delete a message for everyone

Description

Delete a message for everyone

Usage

waservix_delete_message(client, message_id)

Arguments

client

A client from waservix_client().

message_id

Message ID.

Value

The API confirmation.

Examples

## Not run: 
waservix_delete_message(waservix_client("wpk_your_device_key"), 5473)

## End(Not run)

Edit a sent text

Description

WhatsApp allows edits for about 15 minutes after sending.

Usage

waservix_edit_message(client, message_id, text)

Arguments

client

A client from waservix_client().

message_id

Message ID.

text

The new text.

Value

The API confirmation.

Examples

## Not run: 
waservix_edit_message(waservix_client("wpk_your_device_key"), 5473, "Corrected text")

## End(Not run)

Get one contact

Description

Get one contact

Usage

waservix_get_contact(client, phone)

Arguments

client

A client from waservix_client().

phone

Phone number in international format.

Value

The contact.

Examples

## Not run: 
waservix_get_contact(waservix_client("wpk_your_device_key"), "+250788123456")

## End(Not run)

Get a group's details

Description

Get a group's details

Usage

waservix_get_group_metadata(client, group_id)

Arguments

client

A client from waservix_client().

group_id

Group ID, ending in ⁠@g.us⁠.

Value

The group's name, participants and settings.

Examples

## Not run: 
waservix_get_group_metadata(waservix_client("wpk_your_device_key"),
                            "[email protected]")

## End(Not run)

Get a sent message's status

Description

Get a sent message's status

Usage

waservix_get_message_info(client, message_id)

Arguments

client

A client from waservix_client().

message_id

Message ID.

Value

The message and its status (queued, sent, delivered, read, played or failed).

Examples

## Not run: 
waservix_get_message_info(waservix_client("wpk_your_device_key"), 5473)

## End(Not run)

Get your number's connection status

Description

Get your number's connection status

Usage

waservix_get_status(client)

Arguments

client

A client from waservix_client().

Value

The connection status of the number behind the API key.

Examples

## Not run: 
waservix_get_status(waservix_client("wpk_your_device_key"))

## End(Not run)

List contacts

Description

List contacts

Usage

waservix_list_contacts(client)

Arguments

client

A client from waservix_client().

Value

A list of your number's contacts.

Examples

## Not run: 
waservix_list_contacts(waservix_client("wpk_your_device_key"))

## End(Not run)

List groups

Description

List groups

Usage

waservix_list_groups(client)

Arguments

client

A client from waservix_client().

Value

The groups your number is in; IDs end in ⁠@g.us⁠.

Examples

## Not run: 
waservix_list_groups(waservix_client("wpk_your_device_key"))

## End(Not run)

Check whether a number uses WhatsApp

Description

Check whether a number uses WhatsApp

Usage

waservix_on_whatsapp(client, phone)

Arguments

client

A client from waservix_client().

phone

Phone number in international format.

Value

A list telling whether the number is on WhatsApp.

Examples

## Not run: 
waservix_on_whatsapp(waservix_client("wpk_your_device_key"), "+250788123456")

## End(Not run)

Call any WAservix endpoint

Description

Low-level access for endpoints that have no helper of their own.

Usage

waservix_request(client, method, path, body = NULL, query = NULL)

Arguments

client

A client from waservix_client().

method

HTTP method, e.g. "GET" or "POST".

path

Path after the base URL, e.g. "/status".

body

Optional list sent as JSON.

query

Optional named list of query parameters.

Value

The data part of the API answer, as a list.

Examples

## Not run: 
client <- waservix_client("wpk_your_device_key")
waservix_request(client, "GET", "/status")

## End(Not run)

Resend a failed message

Description

Resend a failed message

Usage

waservix_resend_message(client, message_id)

Arguments

client

A client from waservix_client().

message_id

Message ID.

Value

The new send attempt.

Examples

## Not run: 
waservix_resend_message(waservix_client("wpk_your_device_key"), 5473)

## End(Not run)

Send a document

Description

Send a document

Usage

waservix_send_document(client, to, url, file_name = NULL, caption = NULL)

Arguments

client

A client from waservix_client().

to

Phone number in international format, or a group ID.

url

Public URL of the file.

file_name

Optional file name shown to the recipient.

caption

Optional caption.

Value

A list with the queued message ID and status.

Examples

## Not run: 
waservix_send_document(waservix_client("wpk_your_device_key"), "+250788123456",
                       "https://example.com/inv-1042.pdf",
                       file_name = "Invoice-1042.pdf", caption = "Your invoice")

## End(Not run)

Send an image

Description

Send an image

Usage

waservix_send_image(client, to, url, caption = NULL)

Arguments

client

A client from waservix_client().

to

Phone number in international format, or a group ID.

url

Public URL of the image.

caption

Optional caption.

Value

A list with the queued message ID and status.

Examples

## Not run: 
waservix_send_image(waservix_client("wpk_your_device_key"), "+250788123456",
                    "https://example.com/catalogue.jpg", caption = "New arrivals")

## End(Not run)

Send a location pin

Description

Send a location pin

Usage

waservix_send_location(client, to, latitude, longitude, name = NULL)

Arguments

client

A client from waservix_client().

to

Phone number in international format, or a group ID.

latitude, longitude

Coordinates in decimal degrees.

name

Optional place name.

Value

A list with the queued message ID and status.

Examples

## Not run: 
waservix_send_location(waservix_client("wpk_your_device_key"), "+250788123456",
                       -1.9441, 30.0619, name = "Our shop")

## End(Not run)

Send any WhatsApp message

Description

Sends to a number ("+250788123456") or a group ID (ending in ⁠@g.us⁠). Field names follow the API: text, imageUrl, videoUrl, audioUrl, documentUrl, fileName, location, poll, replyTo, mentions, viewOnce.

Usage

waservix_send_message(client, to, ...)

Arguments

client

A client from waservix_client().

to

Phone number in international format, or a group ID.

...

Message fields, named as in the API. NULL fields are dropped.

Value

A list with the queued message ID and status.

Examples

## Not run: 
client <- waservix_client("wpk_your_device_key")
waservix_send_message(client, "+250788123456",
                      videoUrl = "https://example.com/demo.mp4", text = "Demo")

## End(Not run)

Send a text message

Description

Send a text message

Usage

waservix_send_text(client, to, text)

Arguments

client

A client from waservix_client().

to

Phone number in international format, or a group ID.

text

The message text.

Value

A list with the queued message ID and status.

Examples

## Not run: 
waservix_send_text(waservix_client("wpk_your_device_key"),
                   "+250788123456", "Your order #1042 has shipped.")

## End(Not run)

Verify a webhook delivery

Description

Compares the X-Webhook-Signature header with your number's webhook secret. The comparison takes the same time whether or not they match.

Usage

waservix_verify_webhook(signature, secret)

Arguments

signature

Value of the X-Webhook-Signature header.

secret

Your number's webhook secret.

Value

TRUE when the header matches the secret, otherwise FALSE.

Examples

waservix_verify_webhook("my-secret", "my-secret")
waservix_verify_webhook("wrong", "my-secret")