line_bot v0.1.0 LineBot behaviour View Source

A module for sending and receiving messages with the Line Messaging API.

This module:

  • Provides functions for calling the various Line Messaging API endpoints.
  • Specifies a behaviour that defines event handlers which are called to handle webhook event objects from the Messaging API.

Callbacks

If an event contains event-specific data, it is passed as the first argument to the event handler. Each callback is provided with a LineBot.EventInfo.t/0 struct, which contains common metadata for each request. If available, a reply_token for use with the send_reply/3 is included as the final argument.

Unknown events are passed to handle_other/4.

All of the callbacks are optional. If a callback is not implemented, the event will be ignored.

Link to this section Summary

Functions

Callbacks

Called when a Follow event is received.

Called when a Join event is received.

Called when a Leave event is received.

Called when an unknown even it received. The type contains the unknown event type, and the full event is passed as the event argument. If a reply token was not present in the event, reply_token will be nil.

Called when an Unfollow event is received.

Link to this section Types

Link to this type

api_response()

View Source
api_response() ::
  {:ok, map()}
  | {:unauthorized, map()}
  | {:forbidden, map()}
  | {:not_found, map()}
  | {:too_many_requests, map()}
  | {:server_error, map()}
  | {:error, HTTPoison.Error.t()}

Link to this section Functions

Link to this function

get_content(message_id)

View Source
get_content(message_id :: binary()) :: HTTPoison.Response.t()

Calls the Get content API.

Link to this function

get_follower_count(date)

View Source
get_follower_count(date :: String.t()) :: api_response()

Calls the Get number of followers API.

Link to this function

get_follower_demographics()

View Source
get_follower_demographics() :: api_response()

Calls the Get friend demographics API.

Link to this function

get_group_member_ids(group_id, start \\ nil)

View Source
get_group_member_ids(group_id :: String.t(), start :: binary() | nil) ::
  api_response()

Calls the Get group member user IDs API.

Link to this function

get_group_member_profile(group_id, user_id)

View Source
get_group_member_profile(group_id :: String.t(), user_id :: String.t()) ::
  api_response()

Calls the Get group member profile API.

Link to this function

get_profile(user_id)

View Source
get_profile(user_id :: String.t()) :: api_response()

Calls the Get profile API.

Link to this function

get_quota(date)

View Source
get_quota(date :: String.t()) :: api_response()

Calls the Get number of message deliveries API.

Link to this function

get_quota_consumption()

View Source
get_quota_consumption() :: api_response()

Calls the Get number of messages sent this month API.

Link to this function

get_room_member_ids(room_id, start \\ nil)

View Source
get_room_member_ids(room_id :: String.t(), start :: binary() | nil) ::
  api_response()

Calls the Get room member user IDs API.

Link to this function

get_room_member_profile(room_id, user_id)

View Source
get_room_member_profile(room_id :: String.t(), user_id :: String.t()) ::
  api_response()

Calls the Get room member profile API.

Link to this function

get_sent_broadcast_count(date)

View Source
get_sent_broadcast_count(date :: String.t()) :: api_response()

Calls the Get number of sent broadcast messages API.

Link to this function

get_sent_message_count(date)

View Source
get_sent_message_count(date :: String.t()) :: api_response()

Calls the Get number of message deliveries API.

Link to this function

get_sent_multicast_count(date)

View Source
get_sent_multicast_count(date :: String.t()) :: api_response()

Calls the Get number of sent multicast messages API.

Link to this function

get_sent_push_count(date)

View Source
get_sent_push_count(date :: String.t()) :: api_response()

Calls the Get number of sent push messages API.

Link to this function

get_sent_reply_count(date)

View Source
get_sent_reply_count(date :: String.t()) :: api_response()

Calls the Get number of sent reply messages API.

Link to this function

leave_group(group_id)

View Source
leave_group(group_id :: String.t()) :: api_response()

Calls the Leave group API.

Link to this function

leave_room(room_id)

View Source
leave_room(room_id :: String.t()) :: api_response()

Calls the Leave room API.

Link to this function

send_broadcast(messages, notification_disabled \\ false)

View Source
send_broadcast(
  messages :: [LineBot.Message.t()] | LineBot.Message.t(),
  notification_disabled :: boolean()
) :: api_response()

Sends one or more broadcast messages.

Link to this function

send_multicast(to, messages, notification_disabled \\ false)

View Source
send_multicast(
  to :: [String.t()],
  messages :: [LineBot.Message.t()] | LineBot.Message.t(),
  notification_disabled :: boolean()
) :: api_response()

Sends one or more multicast messages.

Link to this function

send_push(to, messages, notification_disabled \\ false)

View Source
send_push(
  to :: String.t(),
  messages :: [LineBot.Message.t()] | LineBot.Message.t(),
  notification_disabled :: boolean()
) :: api_response()

Sends one or more push messages.

Link to this function

send_reply(reply_token, messages, notification_disabled \\ false)

View Source
send_reply(
  reply_token :: String.t(),
  messages :: [LineBot.Message.t()] | LineBot.Message.t(),
  notification_disabled :: boolean()
) :: api_response()

Sends one or more reply messages.

Link to this section Callbacks

Link to this callback

handle_account_link(data, info, reply_token)

View Source (optional)
handle_account_link(
  data :: map(),
  info :: LineBot.EventInfo.t(),
  reply_token :: binary()
) :: any()

Called when an Account Link event is received.

Link to this callback

handle_beacon(data, info, reply_token)

View Source (optional)
handle_beacon(
  data :: map(),
  info :: LineBot.EventInfo.t(),
  reply_token :: binary()
) :: any()

Called when a Beacon event is received.

Link to this callback

handle_follow(info, reply_token)

View Source (optional)
handle_follow(info :: LineBot.EventInfo.t(), reply_token :: binary()) :: any()

Called when a Follow event is received.

Link to this callback

handle_join(info, reply_token)

View Source (optional)
handle_join(info :: LineBot.EventInfo.t(), reply_token :: binary()) :: any()

Called when a Join event is received.

Link to this callback

handle_leave(info)

View Source (optional)
handle_leave(info :: LineBot.EventInfo.t()) :: any()

Called when a Leave event is received.

Link to this callback

handle_member_joined(members, info, reply_token)

View Source (optional)
handle_member_joined(
  members :: list(),
  info :: LineBot.EventInfo.t(),
  reply_token :: binary()
) :: any()

Called when a Member Joined event is received.

Link to this callback

handle_member_left(members, info)

View Source (optional)
handle_member_left(members :: list(), info :: LineBot.EventInfo.t()) :: any()

Called when a Member Left event is received.

Link to this callback

handle_message(message, info, reply_token)

View Source (optional)
handle_message(
  message :: map(),
  info :: LineBot.EventInfo.t(),
  reply_token :: binary()
) :: any()

Called when a Message event is received.

Link to this callback

handle_other(type, event, info, reply_token)

View Source (optional)
handle_other(
  type :: binary(),
  event :: map(),
  info :: LineBot.EventInfo.t(),
  reply_token :: binary() | nil
) :: any()

Called when an unknown even it received. The type contains the unknown event type, and the full event is passed as the event argument. If a reply token was not present in the event, reply_token will be nil.

Link to this callback

handle_postback(data, info, reply_token)

View Source (optional)
handle_postback(
  data :: any(),
  info :: LineBot.EventInfo.t(),
  reply_token :: binary()
) :: any()

Called when a Postback event is received.

Link to this callback

handle_things(data, info, reply_token)

View Source (optional)
handle_things(
  data :: map(),
  info :: LineBot.EventInfo.t(),
  reply_token :: binary()
) :: any()

Called when a LINE Things Scenario Execution event is received.

Link to this callback

handle_unfollow(info)

View Source (optional)
handle_unfollow(info :: LineBot.EventInfo.t()) :: any()

Called when an Unfollow event is received.