| Title: | A Client for 'Evolution Cloud API' |
|---|---|
| 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, media (image/video/document), audio, stickers, geographic locations, contacts, polls, interactive lists and button messages. Also includes number verification and structured CLI logging for debugging. |
| Authors: | Andre Leite [aut, cre], Hugo Vasconcelos [aut], Diogo Bezerra [aut] |
| Maintainer: | Andre Leite <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-28 06:57:39 UTC |
| Source: | https://github.com/strategicprojects/evolution |
Verifies whether one or more phone numbers are registered on WhatsApp using the Evolution API v2 chat controller endpoint.
check_is_whatsapp(client, numbers, verbose = FALSE)check_is_whatsapp(client, numbers, verbose = FALSE)
client |
An |
numbers |
Character vector of phone numbers to check (with country
code, e.g., |
verbose |
Logical. If |
A named list (or data frame) from the API indicating which
numbers are registered. The HTTP status code is stored in
attr(result, "http_status").
## Not run: check_is_whatsapp(client, c("5581999990000", "5511988887777")) ## End(Not run)## Not run: check_is_whatsapp(client, c("5581999990000", "5511988887777")) ## End(Not run)
Creates a preconfigured httr2 client to call Evolution API v2.
It sets the apikey header, a custom User-Agent and basic automatic retries.
The returned object is used by every send_*() function and stores the base
request (req) and the instance name so you don't have to repeat them.
evo_client(base_url, api_key, instance)evo_client(base_url, api_key, instance)
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. |
An object of class evo_client with fields req (httr2 request)
and instance.
send_text(), send_media(), send_location()
## Not run: client <- evo_client( base_url = "https://your-evolution-host.com", api_key = Sys.getenv("EVO_APIKEY"), instance = "myInstance" ) ## End(Not run)## Not run: client <- evo_client( base_url = "https://your-evolution-host.com", api_key = Sys.getenv("EVO_APIKEY"), instance = "myInstance" ) ## End(Not run)
Normalises a raw phone number by removing spaces, dashes,
parentheses, and the leading + sign, then appends
@s.whatsapp.net.
jid(number)jid(number)
number |
Character scalar or vector. Raw phone number(s)
(e.g., |
Character JID(s) (e.g., "[email protected]").
jid("+55 81 99999-0000") #> "[email protected]" jid("5581999990000") #> "[email protected]"jid("+55 81 99999-0000") #> "[email protected]" jid("5581999990000") #> "[email protected]"
Sends a message with interactive buttons via Evolution API v2.
send_buttons( client, number, title, description, footer, buttons, delay = NULL, link_preview = NULL, mentions_everyone = NULL, verbose = FALSE )send_buttons( client, number, title, description, footer, buttons, delay = NULL, link_preview = NULL, mentions_everyone = NULL, verbose = FALSE )
client |
An |
number |
Character. Recipient number with country code
(e.g., |
title |
Character. Button message title. |
description |
Character. Button message description/body. |
footer |
Character. Footer text. |
buttons |
List of buttons. Each button should be a named list following the API specification (see Evolution API docs). |
delay |
Integer (ms). Optional presence delay before sending. Simulates typing before the message is sent. |
link_preview |
Logical. Enable URL link preview in the message. |
mentions_everyone |
Logical. Mention everyone in a group. |
verbose |
Logical. If |
A named list with the API response. The HTTP status code is
stored in attr(result, "http_status").
Baileys connector: Interactive buttons are not supported on
the Baileys (WhatsApp Web) connector and are likely to be discontinued.
This endpoint is fully supported only on the Cloud API connector.
If you are on Baileys, consider using send_poll() as an alternative.
## Not run: send_buttons(client, "5581999990000", title = "Choose", description = "Pick an option:", footer = "Powered by R", buttons = list( list(type = "reply", title = "Option A"), list(type = "reply", title = "Option B") )) ## End(Not run)## Not run: send_buttons(client, "5581999990000", title = "Choose", description = "Pick an option:", footer = "Powered by R", buttons = list( list(type = "reply", title = "Option A"), list(type = "reply", title = "Option B") )) ## End(Not run)
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).
send_contact(client, number, contact, verbose = FALSE)send_contact(client, number, contact, verbose = FALSE)
client |
An |
number |
Recipient number (e.g., |
contact |
Either:
|
verbose |
Logical; if |
Parsed JSON response as list (see .evo_post() for details).
## Not run: send_contact(client, "5581999990000", contact = list( fullName = "Jane Doe", phoneNumber = "+5581999990000", organization = "Company Ltd.", email = "[email protected]", url = "https://company.com" )) ## End(Not run)## Not run: send_contact(client, "5581999990000", contact = list( fullName = "Jane Doe", phoneNumber = "+5581999990000", organization = "Company Ltd.", email = "[email protected]", url = "https://company.com" )) ## End(Not run)
Sends an interactive list message via Evolution API v2. List messages display a menu of selectable options organised into sections.
send_list( client, number, title, description, button_text, sections, footer = "", delay = NULL, verbose = FALSE )send_list( client, number, title, description, button_text, sections, footer = "", delay = NULL, verbose = FALSE )
client |
An |
number |
Character. Recipient number with country code
(e.g., |
title |
Character. List message title. |
description |
Character. List message body text. |
button_text |
Character. Text displayed on the list button
(e.g., |
sections |
A list of section objects. Each section is a named
list with |
footer |
Character. Footer text (required by the API, defaults
to |
delay |
Integer (ms). Optional presence delay before sending. Simulates typing before the message is sent. |
verbose |
Logical. If |
A named list with the API response. The HTTP status code is
stored in attr(result, "http_status").
Baileys connector: Interactive list messages are not supported
on the Baileys (WhatsApp Web) connector and are likely to be
discontinued. This endpoint is fully supported only on the Cloud API
connector. If you are on Baileys, consider using send_poll() as an
alternative.
## Not run: send_list(client, "5581999990000", title = "Our Menu", description = "Select from the options below:", button_text = "View options", footer = "Powered by R", sections = list( list(title = "Drinks", rows = list( list(title = "Coffee", description = "Hot coffee", rowId = "1"), list(title = "Tea", description = "Green tea", rowId = "2") )), list(title = "Food", rows = list( list(title = "Cake", description = "Chocolate cake", rowId = "3") )) )) ## End(Not run)## Not run: send_list(client, "5581999990000", title = "Our Menu", description = "Select from the options below:", button_text = "View options", footer = "Powered by R", sections = list( list(title = "Drinks", rows = list( list(title = "Coffee", description = "Hot coffee", rowId = "1"), list(title = "Tea", description = "Green tea", rowId = "2") )), list(title = "Food", rows = list( list(title = "Cake", description = "Chocolate cake", rowId = "3") )) )) ## End(Not run)
Sends a geographic location pin via Evolution API v2.
send_location( client, number, latitude, longitude, name = NULL, address = NULL, verbose = FALSE )send_location( client, number, latitude, longitude, name = NULL, address = NULL, verbose = FALSE )
client |
An |
number |
Character. Recipient number with country code
(e.g., |
latitude |
Numeric. Latitude coordinate. |
longitude |
Numeric. Longitude coordinate. |
name |
Optional character. Location label name. |
address |
Optional character. Address description. |
verbose |
Logical. If |
A named list with the API response. The HTTP status code is
stored in attr(result, "http_status").
## Not run: send_location(client, "5581999990000", latitude = -8.05, longitude = -34.88, name = "Recife Antigo", address = "Marco Zero") ## End(Not run)## Not run: send_location(client, "5581999990000", latitude = -8.05, longitude = -34.88, name = "Recife Antigo", address = "Marco Zero") ## End(Not run)
Sends an image, video, or document via Evolution API v2.
The media argument is flexible: it accepts an HTTP(S) URL, a local
file path (auto-encoded to base64), raw base64, or a data-URI.
send_media( client, number, mediatype, mimetype, media, file_name, caption = NULL, delay = NULL, link_preview = NULL, verbose = FALSE )send_media( client, number, mediatype, mimetype, media, file_name, caption = NULL, delay = NULL, link_preview = NULL, verbose = FALSE )
client |
An |
number |
Character. Recipient number with country code
(e.g., |
mediatype |
One of |
mimetype |
MIME type string, e.g., |
media |
The media content. Can be: (a) an HTTP/HTTPS URL;
(b) a local file path; (c) raw base64; or
(d) a data-URI ( |
file_name |
Suggested filename for the recipient
(should match the MIME type, e.g., |
caption |
Optional caption text displayed with the media. |
delay |
Integer (ms). Optional presence delay before sending. Simulates typing before the message is sent. |
link_preview |
Logical. Enable URL link preview in the message. |
verbose |
Logical. If |
A named list with the API response. The HTTP status code is
stored in attr(result, "http_status").
## Not run: # From URL send_media(client, "5581999990000", "image", "image/png", media = "https://www.r-project.org/logo/Rlogo.png", file_name = "Rlogo.png", caption = "R Logo") # From local file send_media(client, "5581999990000", "document", "application/pdf", media = "report.pdf", file_name = "report.pdf") ## End(Not run)## Not run: # From URL send_media(client, "5581999990000", "image", "image/png", media = "https://www.r-project.org/logo/Rlogo.png", file_name = "Rlogo.png", caption = "R Logo") # From local file send_media(client, "5581999990000", "document", "application/pdf", media = "report.pdf", file_name = "report.pdf") ## End(Not run)
Sends a poll (question with selectable options) via Evolution API v2.
send_poll(client, number, name, values, selectable_count = 1L, verbose = FALSE)send_poll(client, number, name, values, selectable_count = 1L, verbose = FALSE)
client |
An |
number |
Character. Recipient number with country code
(e.g., |
name |
Question text displayed in the poll. |
values |
Character vector of poll options (minimum 2). |
selectable_count |
Integer. Number of options a user can select
(default |
verbose |
Logical. If |
A named list with the API response. The HTTP status code is
stored in attr(result, "http_status").
## Not run: send_poll(client, "5581999990000", name = "Favourite language?", values = c("R", "Python", "Julia"), selectable_count = 1) ## End(Not run)## Not run: send_poll(client, "5581999990000", name = "Favourite language?", values = c("R", "Python", "Julia"), selectable_count = 1) ## End(Not run)
Sends an emoji reaction to an existing message.
send_reaction(client, key, reaction, verbose = FALSE)send_reaction(client, key, reaction, verbose = FALSE)
client |
An |
key |
List with |
reaction |
Emoji string (e.g., |
verbose |
Logical. If |
A named list with the API response. The HTTP status code is
stored in attr(result, "http_status").
## Not run: send_reaction(client, key = list( remoteJid = "[email protected]", fromMe = TRUE, id = "BAE594145F4C59B4" ), reaction = "\U0001f44d") ## End(Not run)## Not run: send_reaction(client, key = list( remoteJid = "[email protected]", fromMe = TRUE, id = "BAE594145F4C59B4" ), reaction = "\U0001f44d") ## End(Not run)
Posts a status (story) message visible to your contacts. Supports text or media (image, video, document, audio) types.
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 )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 )
client |
An |
type |
One of |
content |
Text (for |
caption |
Optional caption for media types. |
background_color |
Hex colour for text status background
(e.g., |
font |
Integer font id (0–14). |
all_contacts |
Logical. If |
status_jid_list |
Optional character vector of specific JIDs to receive the status. |
verbose |
Logical. If |
A named list with the API response. The HTTP status code is
stored in attr(result, "http_status").
## Not run: send_status(client, type = "text", content = "Hello from R!", background_color = "#317873", font = 2, all_contacts = TRUE) ## End(Not run)## Not run: send_status(client, type = "text", content = "Hello from R!", background_color = "#317873", font = 2, all_contacts = TRUE) ## End(Not run)
Sends a sticker image via Evolution API v2.
send_sticker(client, number, sticker, delay = NULL, verbose = FALSE)send_sticker(client, number, sticker, delay = NULL, verbose = FALSE)
client |
An |
number |
Character. Recipient number with country code
(e.g., |
sticker |
URL, base64-encoded sticker image, or local file path
(auto-encoded to base64). Supports |
delay |
Integer (ms). Optional presence delay before sending. Simulates typing before the message is sent. |
verbose |
Logical. If |
A named list with the API response. The HTTP status code is
stored in attr(result, "http_status").
## Not run: send_sticker(client, "5581999990000", sticker = "https://example.com/sticker.webp") ## End(Not run)## Not run: send_sticker(client, "5581999990000", sticker = "https://example.com/sticker.webp") ## End(Not run)
Sends a plain text WhatsApp message using Evolution API v2.
send_text( client, number, text, delay = NULL, link_preview = NULL, mentions_everyone = NULL, mentioned = NULL, quoted = NULL, verbose = FALSE )send_text( client, number, text, delay = NULL, link_preview = NULL, mentions_everyone = NULL, mentioned = NULL, quoted = NULL, verbose = FALSE )
client |
An |
number |
Character. Recipient number with country code
(e.g., |
text |
Character. Message body. |
delay |
Integer (ms). Optional presence delay before sending. Simulates typing before the message is sent. |
link_preview |
Logical. Enable URL link preview in the message. |
mentions_everyone |
Logical. Mention everyone in a group. |
mentioned |
Character vector of JIDs to mention
(e.g., |
quoted |
Optional list with Baileys message |
verbose |
Logical. If |
A named list parsed from the JSON response returned by Evolution
API, containing the message key (with remoteJid, fromMe, id),
message, messageTimestamp, and status.
The HTTP status code is stored in attr(result, "http_status").
send_media(), send_location(), jid()
## Not run: client <- evo_client("https://my-host", Sys.getenv("EVO_APIKEY"), "myInst") send_text(client, "5581999990000", "Hello from R!", verbose = TRUE) ## End(Not run)## Not run: client <- evo_client("https://my-host", Sys.getenv("EVO_APIKEY"), "myInst") send_text(client, "5581999990000", "Hello from R!", verbose = TRUE) ## End(Not run)
Sends an audio message (push-to-talk / voice note) via Evolution API v2.
send_whatsapp_audio( client, number, audio, delay = NULL, quoted = NULL, verbose = FALSE )send_whatsapp_audio( client, number, audio, delay = NULL, quoted = NULL, verbose = FALSE )
client |
An |
number |
Character. Recipient number with country code
(e.g., |
audio |
URL, base64-encoded audio, or local file path
(auto-encoded to base64). Supports |
delay |
Integer (ms). Optional presence delay before sending. Simulates typing before the message is sent. |
quoted |
Optional list with Baileys message |
verbose |
Logical. If |
A named list with the API response. The HTTP status code is
stored in attr(result, "http_status").
## Not run: send_whatsapp_audio(client, "5581999990000", audio = "https://example.com/note.ogg") ## End(Not run)## Not run: send_whatsapp_audio(client, "5581999990000", audio = "https://example.com/note.ogg") ## End(Not run)