KapsoEx.Platform.Flows (kapso_ex v0.1.0)

Copy Markdown View Source

WhatsApp Flows managed by Kapso: versions, publishing, encryption and data endpoints (serverless functions that serve dynamic flow data).

See Flows in Kapso. To send a flow, use KapsoEx.WhatsApp.Messages.send_flow/6.

Summary

Functions

Attaches an existing deployed function as the flow's data endpoint and registers it with Meta. Several flows can share one function.

Creates a flow. Attributes: phone_number_id (required), name, flow_json (a map; defaults to a basic welcome screen) and publish.

Uploads new flow JSON as a new version and syncs it with Meta.

Deploys the data endpoint function.

Gets recent invocations of the data endpoint function. Params: status, limit.

Gets logs of the data endpoint function (shared functions include every flow's activity). Params: limit.

Gets a flow.

Gets the data endpoint function of a flow.

Gets a flow version, including its flow JSON.

Lists flows, most recent first.

Lists flow versions, most recent first. Params: page, per_page.

Publishes a draft flow. Published flows cannot be unpublished. Attributes: phone_number_id.

Creates or updates the data endpoint function code (JavaScript). Deploy it with deploy_data_endpoint/2 and register it with register_data_endpoint/2.

Registers the deployed data endpoint URL with Meta. Requires flows encryption.

Sets up flows encryption for the flow's WABA, required by data endpoints. Attributes: phone_number_id.

Types

result()

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

Functions

attach_data_endpoint(client, flow_id, function_id)

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

Attaches an existing deployed function as the flow's data endpoint and registers it with Meta. Several flows can share one function.

create(client, attrs)

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

Creates a flow. Attributes: phone_number_id (required), name, flow_json (a map; defaults to a basic welcome screen) and publish.

create_version(client, flow_id, flow_json, opts \\ [])

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

Uploads new flow JSON as a new version and syncs it with Meta.

Options

  • :phone_number_id

deploy_data_endpoint(client, flow_id)

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

Deploys the data endpoint function.

function_invocations(client, flow_id, params \\ [])

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

Gets recent invocations of the data endpoint function. Params: status, limit.

function_logs(client, flow_id, params \\ [])

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

Gets logs of the data endpoint function (shared functions include every flow's activity). Params: limit.

get(client, flow_id)

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

Gets a flow.

get_data_endpoint(client, flow_id)

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

Gets the data endpoint function of a flow.

get_version(client, flow_id, version_id)

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

Gets a flow version, including its flow JSON.

list(client, params \\ [])

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

Lists flows, most recent first.

Params: status, business_account_id, phone_number_id, name_contains, created_after, created_before, page, per_page.

list_versions(client, flow_id, params \\ [])

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

Lists flow versions, most recent first. Params: page, per_page.

publish(client, flow_id, attrs \\ %{})

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

Publishes a draft flow. Published flows cannot be unpublished. Attributes: phone_number_id.

put_data_endpoint(client, flow_id, code)

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

Creates or updates the data endpoint function code (JavaScript). Deploy it with deploy_data_endpoint/2 and register it with register_data_endpoint/2.

register_data_endpoint(client, flow_id)

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

Registers the deployed data endpoint URL with Meta. Requires flows encryption.

setup_encryption(client, flow_id, attrs \\ %{})

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

Sets up flows encryption for the flow's WABA, required by data endpoints. Attributes: phone_number_id.