ExLine.Message.Template (ExLine v0.1.0)

Copy Markdown View Source

Builders for LINE template messages.

Ref: https://developers.line.biz/en/reference/messaging-api/#template-messages

Summary

Functions

Carousel template — up to 10 columns built with carousel_column/3.

A carousel column. text and actions are required.

Confirm template — two actions (yes/no).

Image carousel template — columns built with image_carousel_column/2.

An image carousel column: an image with a single action.

Functions

buttons(text, actions, opts \\ [])

@spec buttons(String.t(), [map()], keyword()) :: map()

Buttons template.

Options: :alt_text (defaults to text), :thumbnail_image_url, :image_aspect_ratio, :image_size, :image_background_color, :title, :default_action.

Ref: https://developers.line.biz/en/reference/messaging-api/#buttons

iex> ExLine.Message.Template.buttons("Pick one", [ExLine.Message.Action.message("A", "a")])
%{
  type: "template",
  altText: "Pick one",
  template: %{type: "buttons", text: "Pick one", actions: [%{type: "message", label: "A", text: "a"}]}
}

carousel(columns, opts \\ [])

@spec carousel(
  [map()],
  keyword()
) :: map()

Carousel template — up to 10 columns built with carousel_column/3.

Options: :alt_text, :image_aspect_ratio, :image_size.

Ref: https://developers.line.biz/en/reference/messaging-api/#carousel

confirm(text, actions, opts \\ [])

@spec confirm(String.t(), [map()], keyword()) :: map()

Confirm template — two actions (yes/no).

Ref: https://developers.line.biz/en/reference/messaging-api/#confirm

iex> ExLine.Message.Template.confirm("OK?", [ExLine.Message.Action.message("Yes", "y"), ExLine.Message.Action.message("No", "n")])
%{
  type: "template",
  altText: "OK?",
  template: %{type: "confirm", text: "OK?", actions: [
    %{type: "message", label: "Yes", text: "y"},
    %{type: "message", label: "No", text: "n"}
  ]}
}

image_carousel(columns, opts \\ [])

@spec image_carousel(
  [map()],
  keyword()
) :: map()

Image carousel template — columns built with image_carousel_column/2.

Ref: https://developers.line.biz/en/reference/messaging-api/#image-carousel