Bot API

The Bot API helps you send a message from a bot, set a menu, and manage bots.

To use the Bot API, you need an access token that you can get by authenticating with a user account or a service account. The API scopes are bot.message, bot, and bot.read.

API scopes

  • The bot.message scope can be used for API operations related to bot messages, menus, and message rooms.
  • The bot scope can be used for all the API operations. Use this scope to add and manage bots.
  • The bot.read scope has read permission only. For more information, see the description of each API operation.

Message {#bot-message}

You can send messages from a bot using the following API operations.

HTTP requestDescription
POST /bots/{botId}/users/{userId}/messagesSend messages (to a user).
This API operation is used to chat with one user.
POST /bots/{botId}/channels/{channelId}/messagesSend messages (to a channel).
This API operation is used to chat with multiple users.

Note

  • Both a reply to a user's message and a message sent by a bot are not differentiated and are thus handled using "Send messages".
  • If there are more than 500 members in a message room, sending messages works, but push notifications do not.

To send images or files, you need to upload content using the following API operation.

HTTP requestDescription
POST /bots/{botId}/attachmentsUpload content

You can download images or files sent to a bot using the following API operation.

HTTP requestDescription
GET /bots/{botId}/attachments/{fileId}Download content

Menu {#bot-menu}

You can manage persistent menus and rich menus using the following API operations.

Persistent menu {#bot-persistment-menu}

You can manage persistent menus using the following API operations.

HTTP requestDescription
POST /bots/{botId}/persistentmenuAdd persistent menus
GET /bots/{botId}/persistentmenuGet persistent menus
DELETE /bots/{botId}/persistentmenuDelete persistent menus

Rich menu {#bot-rich-menu}

You can manage rich menus and rich menu images using the following API operations.

HTTP requestDescription
POST /bots/{botId}/richmenusCreate a rich menu
GET /bots/{botId}/richmenusGet rich menus
GET /bots/{botId}/richmenus/{richmenuId}Get a rich menu
DELETE /bots/{botId}/richmenus/{richmenuId}Delete a rich menu
POST /bots/{botId}/richmenus/{richmenuId}/imageSet a rich menu image
GET /bots/{botId}/richmenus/{richmenuId}/imageGet a rich menu image
POST /bots/{botId}/richmenus/{richmenuId}/users/{userId}Set a custom rich menu
GET /bots/{botId}/richmenus/users/{userId}Get a custom rich menu
DELETE /bots/{botId}/richmenus/users/{userId}Delete a custom rich menu
POST /bots/{botId}/richmenus/{richmenuId}/set-defaultSet the default rich menu
GET /bots/{botId}/richmenus/defaultGet the default rich menu
DELETE /bots/{botId}/richmenus/defaultDelete the default rich menu

A message room with a bot {#bot-talkroom}

You can create a message room with a bot, leave a message room, and get members of a message room using the following API operations.

HTTP requestDescription
POST /bots/{botId}/channelsCreate a message room
GET /bots/{botId}/channels/{channelId}Get message room details
DELETE /bots/{botId}/channels/{channelId}Leave a message room
GET /bots/{botId}/channels/{channelId}/membersGet members of a message room

Manage bots {#manage-bot}

You can add, update, and delete bots using the following API operations.

For more information about adding a bot, see Overview.

Manage bots in the LINE WORKS tenant {#manage-tenant-bot}

You can manage bots in the LINE WORKS tenant using the following API operations.

HTTP requestDescription
POST /botsAdd a bot
GET /botsGet bots
GET /bots/{botId}Get bot details
PUT /bots/{botId}Update a bot
PATCH /bots/{botId}Update part of a bot
DELETE /bots/{botId}Delete a bot
POST /bots/{botId}/secretReissue a bot secret

Manage bots for each LINE WORKS domain {#manage-domain-bot}

You can manage bots for each LINE WORKS domain using the following API operations.

HTTP requestDescription
POST /bots/{botId}/domains/{domainId}Add a bot domain
GET /bots/{botId}/domainsGet bot domains
PUT /bots/{botId}/domains/{domainId}Update a bot domain
PATCH /bots/{botId}/domains/{domainId}Update part of a bot domain
DELETE /bots/{botId}/domains/{domainId}Delete a bot domain
POST /bots/{botId}/domains/{domainId}/membersAdd a bot user
GET /bots/{botId}/domains/{domainId}/membersGet bot users
DELETE /bots/{botId}/domains/{domainId}/members/{userId}Delete a bot user