Amarula.Content.Options (amarula v0.4.2)

View Source

An incoming interactive message that presents a set of choices — a list menu, a buttons message, a template-button message, or a native-flow interactive message. These are what WhatsApp Business / call-center / automated flows send to ask "pick one of these". A normal linked-device client can't send them, but it receives them; the user's reply comes back as an %Amarula.Content.Response{}.

The four proto shapes are unified into one:

  • :kind:list | :buttons | :template | :interactive.

  • :title — header/title text, if any.
  • :body — the main prompt text.
  • :footer — footer text, if any.
  • :button_text — the label that opens the option list (list messages only).
  • :options — the choices, each %{id, text, description} (description is nil for kinds that don't carry one). id is what your app keys the user's selection off; it matches the id of the later %Amarula.Content.Response{}.

For anything beyond the choices (media headers, native-flow param JSON, …), read msg.raw.

Summary

Functions

Normalize one of the four interactive-presentation protos into a %Amarula.Content.Options{}. kind says which proto m is.

Types

kind()

@type kind() :: :list | :buttons | :template | :interactive

option()

@type option() :: %{
  id: String.t() | nil,
  text: String.t() | nil,
  description: String.t() | nil
}

t()

@type t() :: %Amarula.Content.Options{
  body: String.t() | nil,
  button_text: String.t() | nil,
  footer: String.t() | nil,
  kind: kind(),
  options: [option()],
  title: String.t() | nil
}

Functions

from_proto(atom, m)

@spec from_proto(
  kind(),
  struct()
) :: t()

Normalize one of the four interactive-presentation protos into a %Amarula.Content.Options{}. kind says which proto m is.