Builders for LINE message objects.
Functions return plain maps conforming to the LINE Messaging API message object
spec, ready to pass to ExLine.Api.Messaging.reply/4 / push/4. Template, action,
flex and imagemap sub-objects live in ExLine.Message.Template,
ExLine.Message.Action, ExLine.Message.Flex and ExLine.Message.Imagemap.
Ref: https://developers.line.biz/en/reference/messaging-api/#message-objects
Summary
Functions
Audio message. duration is in milliseconds.
Coupon message. Option :delivery_tag (route tag for LINE OA Manager analysis).
Image message.
Imagemap message — a tappable image divided into action areas.
Location message.
Sticker message.
Text message.
Text message v2 — supports mentions/emoji via {placeholder} substitutions.
Video message. Option :tracking_id correlates with the video viewing complete event.
Attaches quick reply actions to a message object.
Overrides the display name and icon of a single message (the "sender" / icon switch).
Functions
Audio message. duration is in milliseconds.
Ref: https://developers.line.biz/en/reference/messaging-api/#audio-message
iex> ExLine.Message.audio("https://x/a.m4a", 60000)
%{type: "audio", originalContentUrl: "https://x/a.m4a", duration: 60000}
Coupon message. Option :delivery_tag (route tag for LINE OA Manager analysis).
Ref: https://developers.line.biz/en/reference/messaging-api/#coupon-message
iex> ExLine.Message.coupon("cpn-1")
%{type: "coupon", couponId: "cpn-1"}
Image message.
Ref: https://developers.line.biz/en/reference/messaging-api/#image-message
iex> ExLine.Message.image("https://x/o.jpg", "https://x/p.jpg")
%{type: "image", originalContentUrl: "https://x/o.jpg", previewImageUrl: "https://x/p.jpg"}
Imagemap message — a tappable image divided into action areas.
base_size is %{width: w, height: h}; actions are built with
ExLine.Message.Imagemap. Option :video.
Ref: https://developers.line.biz/en/reference/messaging-api/#imagemap-message
Location message.
Ref: https://developers.line.biz/en/reference/messaging-api/#location-message
iex> ExLine.Message.location("Office", "Taipei", 25.0, 121.5)
%{type: "location", title: "Office", address: "Taipei", latitude: 25.0, longitude: 121.5}
Sticker message.
Ref: https://developers.line.biz/en/reference/messaging-api/#sticker-message
iex> ExLine.Message.sticker("446", "1988")
%{type: "sticker", packageId: "446", stickerId: "1988"}
Text message.
Options: :emojis (list of LINE emoji objects), :quote_token (quote a message).
Ref: https://developers.line.biz/en/reference/messaging-api/#text-message
iex> ExLine.Message.text("hello")
%{type: "text", text: "hello"}
iex> ExLine.Message.text("hi", quote_token: "qt")
%{type: "text", text: "hi", quoteToken: "qt"}
Text message v2 — supports mentions/emoji via {placeholder} substitutions.
Options: :substitution (map of placeholder => substitution object),
:quote_token.
Ref: https://developers.line.biz/en/reference/messaging-api/#text-message-v2
iex> ExLine.Message.text_v2("hello {user}")
%{type: "textV2", text: "hello {user}"}
Video message. Option :tracking_id correlates with the video viewing complete event.
Ref: https://developers.line.biz/en/reference/messaging-api/#video-message
iex> ExLine.Message.video("https://x/o.mp4", "https://x/p.jpg")
%{type: "video", originalContentUrl: "https://x/o.mp4", previewImageUrl: "https://x/p.jpg"}
Attaches quick reply actions to a message object.
Ref: https://developers.line.biz/en/docs/messaging-api/using-quick-reply/
iex> "hi" |> ExLine.Message.text() |> ExLine.Message.with_quick_reply([ExLine.Message.Action.message("Yes", "yes")])
%{
type: "text",
text: "hi",
quickReply: %{items: [%{type: "action", action: %{type: "message", label: "Yes", text: "yes"}}]}
}
Overrides the display name and icon of a single message (the "sender" / icon switch).
Ref: https://developers.line.biz/en/reference/messaging-api/#icon-nickname-switch
iex> "hi" |> ExLine.Message.text() |> ExLine.Message.with_sender("Bot", "https://example.com/i.png")
%{type: "text", text: "hi", sender: %{name: "Bot", iconUrl: "https://example.com/i.png"}}