Skip to content
/ wax Public
forked from resuelve/wax

Cliente de Whatsapp para Elixir

Notifications You must be signed in to change notification settings

soyondori/wax

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhatsappApi

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

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.1.7}
  ]
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/whatsapp_api.

About

Cliente de Whatsapp para Elixir

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%