ExLine.Message.Action (ExLine v0.1.0)

Copy Markdown View Source

Builders for LINE action objects (used in templates, quick replies, imagemaps).

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

Summary

Functions

Camera action — opens the camera screen.

Camera roll action — opens the photo library.

Clipboard action — copies clipboard_text (max 1000 chars) when tapped.

Datetime picker action. mode is :date | :time | :datetime.

Location action — opens the location screen.

Message action — sends text as the user when tapped.

Postback action — delivers data to your webhook as a postback event.

Rich menu switch action — switches to the rich menu with rich_menu_alias_id.

URI action — opens uri when tapped.

Functions

camera(label)

@spec camera(String.t()) :: map()

Camera action — opens the camera screen.

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

iex> ExLine.Message.Action.camera("Camera")
%{type: "camera", label: "Camera"}

camera_roll(label)

@spec camera_roll(String.t()) :: map()

Camera roll action — opens the photo library.

Ref: https://developers.line.biz/en/reference/messaging-api/#camera-roll-action

iex> ExLine.Message.Action.camera_roll("Album")
%{type: "cameraRoll", label: "Album"}

clipboard(label, clipboard_text)

@spec clipboard(String.t(), String.t()) :: map()

Clipboard action — copies clipboard_text (max 1000 chars) when tapped.

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

iex> ExLine.Message.Action.clipboard("Copy", "copied")
%{type: "clipboard", label: "Copy", clipboardText: "copied"}

datetimepicker(label, data, mode, opts \\ [])

@spec datetimepicker(String.t(), String.t(), :date | :time | :datetime, keyword()) ::
  map()

Datetime picker action. mode is :date | :time | :datetime.

Options: :initial, :max, :min.

Ref: https://developers.line.biz/en/reference/messaging-api/#datetime-picker-action

iex> ExLine.Message.Action.datetimepicker("Pick", "d", :datetime)
%{type: "datetimepicker", label: "Pick", data: "d", mode: "datetime"}

location(label)

@spec location(String.t()) :: map()

Location action — opens the location screen.

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

iex> ExLine.Message.Action.location("Location")
%{type: "location", label: "Location"}

message(label, text)

@spec message(String.t(), String.t()) :: map()

Message action — sends text as the user when tapped.

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

iex> ExLine.Message.Action.message("Label", "sent text")
%{type: "message", label: "Label", text: "sent text"}

postback(label, data, opts \\ [])

@spec postback(String.t(), String.t(), keyword()) :: map()

Postback action — delivers data to your webhook as a postback event.

Options: :display_text, :input_option, :fill_in_text.

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

iex> ExLine.Message.Action.postback("Buy", "action=buy&id=1")
%{type: "postback", label: "Buy", data: "action=buy&id=1"}

iex> ExLine.Message.Action.postback("Buy", "action=buy", display_text: "Buying")
%{type: "postback", label: "Buy", data: "action=buy", displayText: "Buying"}

richmenu_switch(label, rich_menu_alias_id, data)

@spec richmenu_switch(String.t(), String.t(), String.t()) :: map()

Rich menu switch action — switches to the rich menu with rich_menu_alias_id.

Ref: https://developers.line.biz/en/reference/messaging-api/#richmenu-switch-action

iex> ExLine.Message.Action.richmenu_switch("Next", "menu-b", "switched")
%{type: "richmenuswitch", label: "Next", richMenuAliasId: "menu-b", data: "switched"}

uri(label, uri)

@spec uri(String.t(), String.t()) :: map()

URI action — opens uri when tapped.

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

iex> ExLine.Message.Action.uri("Open", "https://example.com")
%{type: "uri", label: "Open", uri: "https://example.com"}