Skip to content
Cliente de Whatsapp para Elixir
Elixir
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
config
lib
test
.formatter.exs
.gitignore
README.md
mix.exs
mix.lock

README.md

Elixir CI

Whatsapp Api

Cliente para comunicar con el servicio de Whatsapp https://developers.facebook.com/docs/whatsapp

  • Login
  • Logout
  • Create account
  • Verify account
  • Check contact
  • Send text messages
  • Send hsm messages
  • Send media messages
  • Download media
  • Get application medatada
  • Update application metadata
  • Two step verification
  • Get health
  • Stats
  • Support

Installation

If available in Hex, the package can be installed by adding whatsapp_api to your list of dependencies in mix.exs:

def deps do
  [
    {:wax, "~> 0.4.1}
  ]
end

Setup default parser in config.ex

config :whatsapp_api, parser: Whatsapp.Parser

Using GenServer Auth

defmodule MyApp.Application do
  use Application

  alias Whatsapp.Models.WhatsappProvider

  # See https://hexdocs.pm/elixir/Application.html
  # for more information on OTP Applications
  def start(_type, _args) do
    import Supervisor.Spec

    children = [
      worker(Whatsapp.Auth.Server, [[
        %WhatsappProvider{
          name: "My company",
          url: "https://wa.io:9090/v1",
          username: "username",
          password: "password"
        }
      ]])
    ]

    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

Now you can use the provider name to authenticate

iex> %{"contacts" => [%{"wa_id" => wa_id}] = WhatsappApi.check("5566295500", "My company")
iex> message = MessageOutbound.new(to: wa_id, body: "Hi!")
iex> WhatsappApi.send(message, "My company")

Without GenServer Auth

iex> message = MessageOutbound.new(to: "wa_id", body: "Hi!")
iex> auth_header = [{"Authorization", "Bearer #{token}"}]
iex> Whatsapp.Api.Messages.send({"https://wa.io:9090/v1", auth_header, message)

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/wax.

You can’t perform that action at this time.