KapsoEx.WhatsApp.Calls (kapso_ex v0.1.0)

Copy Markdown View Source

WhatsApp Calling: call logs, call actions and call permissions.

Calls are negotiated with WebRTC SDP: you send an SDP offer to start an outbound call, and an SDP answer to accept an inbound one (received in the call webhook).

Summary

Functions

Accepts an inbound call with an SDP answer. Options as in connect/5.

Performs a raw call action. attrs needs at least :action ("connect", "pre_accept", "accept", "reject" or "terminate").

Starts an outbound call to to with an SDP offer.

Gets the call permission state with a user. Params: user_wa_id (phone number) or recipient (business-scoped user ID).

Lists calls. Params: call_id, direction, status, since, until, limit, before, after, fields.

Pre-accepts an inbound call with an SDP answer, to start media setup early.

Rejects an inbound call.

Types

result()

@type result() :: {:ok, map()} | {:error, KapsoEx.Error.t()}

Functions

accept(client, phone_number_id, call_id, sdp_answer, opts \\ [])

@spec accept(KapsoEx.Client.t(), String.t(), String.t(), String.t(), keyword()) ::
  result()

Accepts an inbound call with an SDP answer. Options as in connect/5.

action(client, phone_number_id, attrs)

@spec action(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()

Performs a raw call action. attrs needs at least :action ("connect", "pre_accept", "accept", "reject" or "terminate").

connect(client, phone_number_id, to, sdp_offer, opts \\ [])

@spec connect(KapsoEx.Client.t(), String.t(), String.t(), String.t(), keyword()) ::
  result()

Starts an outbound call to to with an SDP offer.

Check get_permissions/3 first: the user must have granted permission.

Options

  • :biz_opaque_callback_data - echoed back in call webhooks.
  • :recording - e.g. %{status: "ENABLED"}.
  • :transcription - e.g. %{status: "ENABLED"}.

get_permissions(client, phone_number_id, params)

@spec get_permissions(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()

Gets the call permission state with a user. Params: user_wa_id (phone number) or recipient (business-scoped user ID).

Before dialing, check that actions has start_call with can_perform_action: true.

list(client, phone_number_id, params \\ [])

@spec list(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()

Lists calls. Params: call_id, direction, status, since, until, limit, before, after, fields.

pre_accept(client, phone_number_id, call_id, sdp_answer)

@spec pre_accept(KapsoEx.Client.t(), String.t(), String.t(), String.t()) :: result()

Pre-accepts an inbound call with an SDP answer, to start media setup early.

reject(client, phone_number_id, call_id)

@spec reject(KapsoEx.Client.t(), String.t(), String.t()) :: result()

Rejects an inbound call.

terminate(client, phone_number_id, call_id)

@spec terminate(KapsoEx.Client.t(), String.t(), String.t()) :: result()

Ends an ongoing call.