LINE Messaging API send endpoints.
Every function takes an ExLine.Client as its first argument. Messages may be a
single message map or a list (max 5 per request).
Ref: https://developers.line.biz/en/reference/messaging-api/#messages
Summary
Functions
Sends messages to all friends of the official account.
Displays a loading animation in a one-on-one chat for up to seconds (5–60, in
multiples of 5).
Marks messages from a user as read (partner feature; requires the chat's user id).
Marks messages as read using a markAsReadToken from a message event.
Sends the same messages to multiple users at once (max 500 user IDs).
Sends messages to a filtered segment of friends (by audience/demographic).
Gets the delivery status of a narrowcast request (phase: waiting / sending /
succeeded / failed, plus counts).
Sends push messages to a user, group, or room.
Sends a LINE notification message to a phone number hash (PNP; partner feature).
to is the hashed phone number. Shares push's send-result handling.
Gets this month's message-sending quota (%{"type" => "limited"|"none", "value" => n}).
Gets this month's number of sent messages counted toward the quota.
Sends reply messages using the replyToken from a webhook event.
Gets the number of messages sent on date ("yyyyMMdd") for the given kind
(:reply | :push | :multicast | :broadcast | :pnp).
Types
Functions
@spec broadcast(ExLine.Client.t(), messages(), keyword()) :: {:ok, map()} | {:error, ExLine.Error.t()}
Sends messages to all friends of the official account.
Like push/4, opts[:retry_key] enables idempotent retries and
opts[:notification_disabled] suppresses the push notification.
Ref: https://developers.line.biz/en/reference/messaging-api/#send-broadcast-message
@spec display_loading_animation(ExLine.Client.t(), String.t(), pos_integer()) :: {:ok, map()} | {:error, ExLine.Error.t()}
Displays a loading animation in a one-on-one chat for up to seconds (5–60, in
multiples of 5).
Ref: https://developers.line.biz/en/reference/messaging-api/#display-a-loading-indicator
@spec mark_as_read(ExLine.Client.t(), String.t()) :: {:ok, term()} | {:error, ExLine.Error.t()}
Marks messages from a user as read (partner feature; requires the chat's user id).
Ref: https://developers.line.biz/en/reference/partner-docs/#mark-messages-from-users-as-read
@spec mark_as_read_by_token(ExLine.Client.t(), String.t()) :: {:ok, term()} | {:error, ExLine.Error.t()}
Marks messages as read using a markAsReadToken from a message event.
Ref: https://developers.line.biz/en/reference/messaging-api/#mark-as-read
@spec multicast(ExLine.Client.t(), [String.t()], messages(), keyword()) :: {:ok, map()} | {:error, ExLine.Error.t()}
Sends the same messages to multiple users at once (max 500 user IDs).
to is a list of user IDs; group/room IDs are not allowed. Like push/4,
opts[:retry_key] enables idempotent retries (409 is treated as success) and
HTTP 429 maps to %ExLine.Error{kind: :quota_exceeded}. opts[:notification_disabled]
suppresses the push notification.
Ref: https://developers.line.biz/en/reference/messaging-api/#send-multicast-message
@spec narrowcast(ExLine.Client.t(), messages(), keyword()) :: {:ok, String.t() | nil} | {:error, ExLine.Error.t()}
Sends messages to a filtered segment of friends (by audience/demographic).
Targeting is passed via opts: :recipient (audience/operator object), :filter
(demographic object), :limit (%{max: n}). Also :retry_key,
:notification_disabled.
Narrowcast is asynchronous: on success this returns {:ok, request_id} (from the
X-Line-Request-Id header); poll narrowcast_progress/2 with it.
Ref: https://developers.line.biz/en/reference/messaging-api/#send-narrowcast-message
@spec narrowcast_progress(ExLine.Client.t(), String.t()) :: {:ok, map()} | {:error, ExLine.Error.t()}
Gets the delivery status of a narrowcast request (phase: waiting / sending /
succeeded / failed, plus counts).
Ref: https://developers.line.biz/en/reference/messaging-api/#get-narrowcast-progress-status
@spec push(ExLine.Client.t(), String.t(), messages(), keyword()) :: {:ok, map()} | {:error, ExLine.Error.t()}
Sends push messages to a user, group, or room.
opts[:retry_key] (a UUID) is sent as the X-Line-Retry-Key header so LINE
deduplicates retried requests; a deduplicated retry returns HTTP 409, which is
treated here as success ({:ok, body}). HTTP 429 maps to a
%ExLine.Error{kind: :quota_exceeded}.
Ref: https://developers.line.biz/en/reference/messaging-api/#send-push-message
@spec push_by_phone(ExLine.Client.t(), String.t(), messages(), keyword()) :: {:ok, map()} | {:error, ExLine.Error.t()}
Sends a LINE notification message to a phone number hash (PNP; partner feature).
to is the hashed phone number. Shares push's send-result handling.
Ref: https://developers.line.biz/en/reference/partner-docs/#send-line-notification-message
@spec quota(ExLine.Client.t()) :: {:ok, map()} | {:error, ExLine.Error.t()}
Gets this month's message-sending quota (%{"type" => "limited"|"none", "value" => n}).
Ref: https://developers.line.biz/en/reference/messaging-api/#get-quota
@spec quota_consumption(ExLine.Client.t()) :: {:ok, map()} | {:error, ExLine.Error.t()}
Gets this month's number of sent messages counted toward the quota.
Ref: https://developers.line.biz/en/reference/messaging-api/#get-consumption
@spec reply(ExLine.Client.t(), String.t(), messages(), keyword()) :: {:ok, map()} | {:error, ExLine.Error.t()}
Sends reply messages using the replyToken from a webhook event.
Returns {:ok, body} on success, or {:error, ExLine.Error.t()}.
Ref: https://developers.line.biz/en/reference/messaging-api/#send-reply-message
@spec sent_count( ExLine.Client.t(), :reply | :push | :multicast | :broadcast | :pnp, String.t() ) :: {:ok, map()} | {:error, ExLine.Error.t()}
Gets the number of messages sent on date ("yyyyMMdd") for the given kind
(:reply | :push | :multicast | :broadcast | :pnp).
:pnp returns the number of sent LINE notification messages (PNP); the others
cover the corresponding send endpoints.
Ref: https://developers.line.biz/en/reference/messaging-api/#get-number-of-reply-messages Ref (PNP): https://developers.line.biz/en/reference/partner-docs/#get-number-of-sent-line-notification-messages
@spec validate( ExLine.Client.t(), :reply | :push | :multicast | :broadcast | :narrowcast, messages(), keyword() ) :: {:ok, term()} | {:error, ExLine.Error.t()}
Validates message objects without sending them. kind is :reply | :push | |
:multicast | :broadcast | :narrowcast; for :narrowcast, :recipient / |
:filter / :limit opts are included. Returns {:ok, _} if valid.
Ref: https://developers.line.biz/en/reference/messaging-api/#validate-message-objects-of-push-message