| Type: | Package |
| Title: | A Client for 'Evolution Cloud API' |
| Date: | 2025-11-17 |
| Version: | 0.0.1 |
| Description: | Provides an 'R' interface to the 'Evolution API' https://evoapicloud.com, enabling sending and receiving 'WhatsApp' messages directly from 'R'. Functions include sending text, images, documents, stickers, geographic locations, and interactive messages (lists). Also includes 'webhook' parsing utilities and channel health checks. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/StrategicProjects/evolution/ |
| BugReports: | https://github.com/StrategicProjects/evolution/issues/ |
| Depends: | R (≥ 4.2.0) |
| Imports: | httr2 (≥ 1.0.0), cli (≥ 3.6.0), base64enc |
| Suggests: | testthat (≥ 3.0.0), knitr, rmarkdown, pkgdown |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2025-11-17 13:06:46 UTC; leite |
| Author: | Andre Leite [aut, cre], Hugo Vaconcelos [aut], Diogo Bezerra [aut] |
| Maintainer: | Andre Leite <leite@castlab.org> |
| Repository: | CRAN |
| Date/Publication: | 2025-11-20 15:30:07 UTC |
Compact a list removing NULL elements
Description
Compact a list removing NULL elements
Usage
.compact(x)
Arguments
x |
A list possibly containing |
Value
The same list with all NULL elements removed.
Build internal API path
Description
Build internal API path
Usage
.evo_path(...)
Arguments
... |
Character path segments. |
Value
A single character scalar with segments concatenated by "/".
Perform a JSON POST request (internal)
Description
Perform a JSON POST request (internal)
Usage
.evo_post(client, path, body, verbose = FALSE)
Arguments
client |
An |
path |
Character. Path to append to the base URL. |
body |
List to be JSON-encoded as the request body. |
verbose |
Logical. If TRUE, print request/response debug via cli + httr2::req_verbose(). |
Value
Parsed JSON as list (with raw HTTP status stored in attribute http_status).
Create an Evolution API client
Description
Creates a preconfigured httr2 client to call Evolution API v2.
It sets the apikey header, a custom User-Agent and basic automatic retries.
Usage
evo_client(base_url, api_key, instance)
Arguments
base_url |
Character. Server base URL (no trailing slash), e.g. |
api_key |
Character. API key (sent as |
instance |
Character. Instance name/ID used in endpoint paths. |
Value
An object of class evo_client with fields req (httr2 request) and instance.
Examples
## Not run:
client <- evo_client("https://evolution_api_host", "KEY", "chatArgus")
## End(Not run)
Build a WhatsApp JID from a raw number
Description
Normalizes a raw number (remove espaces, -, (, )) and add @s.whatsapp.net.
Usage
jid(number)
Arguments
number |
Character. raw number (eg., |
Value
Character JID.
Examples
jid("+5581999...")
Send Buttons
Description
Send Buttons
Usage
send_buttons(
client,
number,
title,
description,
footer,
buttons,
delay = NULL,
link_preview = NULL,
mentions_everyone = NULL,
verbose = FALSE
)
Arguments
client |
An |
number |
Character. Recipient in E.164 format (e.g., |
title, description, footer |
Character. |
buttons |
List of buttons (see API docs). |
delay |
Integer (ms). Optional presence delay before sending. |
link_preview |
Logical. Enable URL link preview. |
mentions_everyone |
Logical. Mention everyone (if applicable). |
verbose |
Logical. If TRUE, logs request/response details. |
Details
Buttons may be discontinued on Baileys mode; supported on Cloud API.
Value
A named list parsed from the Evolution API JSON response, with metadata
describing the button message (IDs, timestamps, queue details, and
button structure as accepted by the server). Note: Buttons may be discontinued on Baileys mode; supported on Cloud API.
The HTTP status code is stored in attr(result, "http_status").
This output reflects the server acknowledgement of the button message send.
Send a WhatsApp contact (auto-generate wuid as @s.whatsapp.net)
Description
Sends one or more contacts following the Evolution API v2 format.
Automatically generates the wuid field as <digits>@s.whatsapp.net
from each contact's phone number (or from number if not provided).
Usage
send_contact(client, number, contact, verbose = FALSE)
Arguments
client |
An |
number |
Recipient number (E.164, e.g. "+55819..."). |
contact |
Either:
|
verbose |
Logical; if TRUE, shows detailed logs (cli + httr2 verbose). |
Value
Parsed JSON response as list (see .evo_post() for details).
Examples
## Not run:
send_contact(
client,
number = "+55819...",
contact = list(
fullName = "Your Name",
phoneNumber = "+55819...",
organization = "Company Name",
email = "andre@example.com",
url = "https://company_site.tec.br"
),
verbose = TRUE
)
## End(Not run)
Send a location
Description
Send a location
Usage
send_location(
client,
number,
latitude,
longitude,
name = NULL,
address = NULL,
verbose = FALSE
)
Arguments
client |
An |
number |
Character. Recipient in E.164 format (e.g., |
latitude, longitude |
Numeric coordinates. |
name, address |
Optional character (label/description). |
verbose |
Logical. If TRUE, logs request/response details. |
Value
A named list parsed from the JSON output of Evolution API, describing the
location message sent (message ID, queue info, timestamps, etc.).
The HTTP status code is stored in attr(result, "http_status").
This return value is the official server acknowledgement of the location dispatch.
Send media (image, video, document) - robust for base64
Description
Send media (image, video, document) - robust for base64
Usage
send_media(
client,
number,
mediatype,
mimetype,
caption = NULL,
media,
file_name,
delay = NULL,
link_preview = NULL,
verbose = FALSE
)
Arguments
client |
An |
number |
Character. Recipient in E.164 format (e.g., |
mediatype |
One of "image", "video", "document". |
mimetype |
e.g., "image/png", "video/mp4", "application/pdf". |
caption |
Caption text (optional). |
media |
Can be: (a) HTTP/HTTPS URL; (b) raw base64 (no prefix); (c) base64 in the format data:*;base64,<…>; (d) local file path. |
file_name |
Suggested filename (consistent with the mimetype). |
delay |
Integer (ms). Optional presence delay before sending. |
link_preview |
Logical. Enable URL link preview. |
verbose |
Detailed log output (cli + req_verbose()). |
Value
A named list parsed from the Evolution API JSON response.
The list typically contains message metadata (IDs, timestamps, queue info),
and any additional fields defined by the API for media messages.
The HTTP status code is stored in attr(result, "http_status").
This return value represents the server acknowledgement of the media upload/send.
Send a poll
Description
Send a poll
Usage
send_poll(client, number, name, values, selectable_count = 1L, verbose = FALSE)
Arguments
client |
An |
number |
Character. Recipient in E.164 format (e.g., |
name |
Question text. |
values |
Character vector of options. |
selectable_count |
Integer (# options a user can select). |
verbose |
Logical. If TRUE, logs request/response details. |
Value
A named list parsed from the JSON response issued by Evolution API,
including fields describing the created poll message (ID, timestamp,
poll options, metadata).
The HTTP status code is stored in attr(result, "http_status").
This output represents the API confirmation that the poll was created and dispatched.
React to a message
Description
React to a message
Usage
send_reaction(client, key, reaction, verbose = FALSE)
Arguments
client |
An |
key |
List with |
reaction |
Emoji like |
verbose |
Logical. If TRUE, logs request/response details. |
Value
A named list parsed from the JSON response of the Evolution API.
Typical fields include message identifiers and acknowledgement metadata.
The HTTP status code is stored in attr(result, "http_status").
This return value indicates that the reaction was successfully sent.
Send a WhatsApp Status (story)
Description
Send a WhatsApp Status (story)
Usage
send_status(
client,
type = c("text", "image", "video", "document", "audio"),
content,
caption = NULL,
background_color = NULL,
font = NULL,
all_contacts = FALSE,
status_jid_list = NULL,
verbose = FALSE
)
Arguments
client |
An |
type |
One of |
content |
Text (for |
caption |
Optional caption for media. |
background_color |
Hex color for text status background. |
font |
Integer font id. |
all_contacts |
Logical. Send to all contacts. |
status_jid_list |
Optional character vector of JIDs. |
verbose |
Logical. If TRUE, logs request/response details. |
Value
A named list parsed from the JSON response returned by Evolution API.
The object contains fields such as status, message, queueId, or
other elements depending on the API endpoint.
The HTTP status code of the request is stored in attr(result, "http_status").
This output represents the API-level confirmation of the status message sent.
Send a sticker
Description
Send a sticker
Usage
send_sticker(client, number, sticker, delay = NULL, verbose = FALSE)
Arguments
client |
An |
number |
Character. Recipient in E.164 format (e.g., |
sticker |
URL or base64 image. |
delay |
Integer (ms). Optional presence delay before sending. |
verbose |
Logical. If TRUE, logs request/response details. |
Value
A named list parsed from the Evolution API JSON response, containing
identifiers and metadata about the sticker message.
The HTTP status code is stored in attr(result, "http_status").
This output confirms the sticker was accepted and queued/sent by the server.
Send a plain text message
Description
Sends a plain text WhatsApp message using Evolution API v2.
Usage
send_text(
client,
number,
text,
delay = NULL,
link_preview = NULL,
mentions_everyone = NULL,
mentioned = NULL,
quoted = NULL,
verbose = FALSE
)
Arguments
client |
An |
number |
Character. Recipient in E.164 format (e.g., |
text |
Character. Message body. |
delay |
Integer (ms). Optional presence delay before sending. |
link_preview |
Logical. Enable URL link preview. |
mentions_everyone |
Logical. Mention everyone (if applicable). |
mentioned |
Character vector of JIDs to mention (e.g., |
quoted |
Optional list with Baileys message |
verbose |
Logical. If TRUE, logs request/response details with |
Value
A named list parsed from the JSON response returned by Evolution API,
containing message metadata (IDs, timestamps, queue information) and any
additional fields defined by the endpoint.
The HTTP status code is stored in attr(result, "http_status").
This output represents the API confirmation that the text message was processed.
Examples
## Not run:
client <- evo_client("https://evolution_api_host", Sys.getenv("EVO_APIKEY"), "chatArgus")
send_text(client, "+55819...", "Ola", delay = 123, link_preview = FALSE, verbose = TRUE)
## End(Not run)
Send WhatsApp audio (voice note)
Description
Send WhatsApp audio (voice note)
Usage
send_whatsapp_audio(
client,
number,
audio,
delay = NULL,
link_preview = NULL,
mentions_everyone = NULL,
mentioned = NULL,
quoted = NULL,
verbose = FALSE
)
Arguments
client |
An |
number |
Character. Recipient in E.164 format (e.g., |
audio |
URL or base64. |
delay |
Integer (ms). Optional presence delay before sending. |
link_preview |
Logical. Enable URL link preview. |
mentions_everyone |
Logical. Mention everyone (if applicable). |
mentioned |
Character vector of JIDs to mention (e.g., |
quoted |
Optional list with Baileys message |
verbose |
Logical. If TRUE, logs request/response details. |
Value
A named list parsed from the JSON response produced by the Evolution API for
audio messages.
The list may include message ID, queue metadata, and delivery-related fields.
The HTTP status code is stored in attr(result, "http_status").
This output indicates that the audio message request was accepted by the API.