Elixir client for the WAservix WhatsApp API Gateway.
WAservix links your own WhatsApp number by QR code (the same way WhatsApp Web does) and gives you a REST API to send text, images, documents, locations, polls and more.
client = WAservix.new(System.fetch_env!("WASERVIX_KEY"))
{:ok, %{"msgId" => id, "status" => "in_progress"}} =
WAservix.send_text(client, "+15551234567", "Hello Aline, your order is ready")Every function returns {:ok, data} (the decoded data field of the answer) or
{:error, %WAservix.Error{}}. Keep the API key on your server.
API reference: https://tekservix.com/waservix/docs/
Summary
Functions
Connects a session by QR code, or by pairing code with phone: "+1555...".
Creates a session.
Deletes a message.
Edits one of your own text messages (about 15 minutes after sending).
One contact.
Group name, participants and settings.
Message status: queued, sent, delivered, read, played or failed.
One session.
QR code for linking the number.
Connection status: connected, connecting, need_scan, disconnected, logged_out or expired.
The linked WhatsApp account.
Your contacts.
Groups the number belongs to.
Sessions (need a personal access token, not a device key).
Creates a client with a device API key (Devices -> API key), or a personal access token for session management.
Is this number on WhatsApp? Returns {:ok, %{"exists" => true, "jid" => ...}}.
Calls any documented endpoint, e.g. request(client, :get, "/groups").
Returns the data field of the answer.
Resends a failed message.
Saves or renames a contact.
Sends a document by URL. Options: :file_name, :caption.
Sends an image by URL. Option: :caption.
Sends a location pin. Option: :name.
Sends any message type to a number or group JID (...@g.us). fields uses the API names:
text, imageUrl, videoUrl, audioUrl, documentUrl, fileName, stickerUrl,
contact, location, poll, replyTo, mentions, viewOnce.
Sends a text message.
Constant-time check of the X-Webhook-Signature header against your device's webhook secret.
Types
@type result() :: {:ok, term()} | {:error, WAservix.Error.t()}
Result of every API call.
@type t() :: %WAservix{req: Req.Request.t()}
A client. Create one with new/2 and reuse it.
Functions
Connects a session by QR code, or by pairing code with phone: "+1555...".
Creates a session.
Deletes a message.
Edits one of your own text messages (about 15 minutes after sending).
One contact.
Group name, participants and settings.
Message status: queued, sent, delivered, read, played or failed.
One session.
QR code for linking the number.
Connection status: connected, connecting, need_scan, disconnected, logged_out or expired.
The linked WhatsApp account.
Your contacts.
Groups the number belongs to.
Sessions (need a personal access token, not a device key).
Creates a client with a device API key (Devices -> API key), or a personal access token for session management.
Options:
:base_url- change only for testing:receive_timeout- milliseconds to wait for an answer (default 30_000):req_options- extra options passed toReq.new/1(proxy, plug for tests, ...)
Is this number on WhatsApp? Returns {:ok, %{"exists" => true, "jid" => ...}}.
Calls any documented endpoint, e.g. request(client, :get, "/groups").
Returns the data field of the answer.
Resends a failed message.
Saves or renames a contact.
Sends a document by URL. Options: :file_name, :caption.
Sends an image by URL. Option: :caption.
Sends a location pin. Option: :name.
Sends any message type to a number or group JID (...@g.us). fields uses the API names:
text, imageUrl, videoUrl, audioUrl, documentUrl, fileName, stickerUrl,
contact, location, poll, replyTo, mentions, viewOnce.
WAservix.send_message(client, "120363040000000000@g.us", %{text: "Team meeting at 3pm"})
Sends a text message.
Constant-time check of the X-Webhook-Signature header against your device's webhook secret.
WAservix.verify_webhook(get_req_header(conn, "x-webhook-signature") |> List.first(), secret)