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.messagescope can be used for API operations related to bot messages, menus, and message rooms.- The
botscope can be used for all the API operations. Use this scope to add and manage bots.- The
bot.readscope has read permission only. For more information, see the description of each API operation.
You can send messages from a bot using the following API operations.
| HTTP request | Description |
|---|---|
| POST /bots/{botId}/users/{userId}/messages | Send messages (to a user). This API operation is used to chat with one user. |
| POST /bots/{botId}/channels/{channelId}/messages | Send 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 request | Description |
|---|---|
| POST /bots/{botId}/attachments | Upload content |
You can download images or files sent to a bot using the following API operation.
| HTTP request | Description |
|---|---|
| GET /bots/{botId}/attachments/{fileId} | Download content |
You can manage persistent menus and rich menus using the following API operations.
You can manage persistent menus using the following API operations.
| HTTP request | Description |
|---|---|
| POST /bots/{botId}/persistentmenu | Add persistent menus |
| GET /bots/{botId}/persistentmenu | Get persistent menus |
| DELETE /bots/{botId}/persistentmenu | Delete persistent menus |
You can manage rich menus and rich menu images using the following API operations.
| HTTP request | Description |
|---|---|
| POST /bots/{botId}/richmenus | Create a rich menu |
| GET /bots/{botId}/richmenus | Get 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}/image | Set a rich menu image |
| GET /bots/{botId}/richmenus/{richmenuId}/image | Get 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-default | Set the default rich menu |
| GET /bots/{botId}/richmenus/default | Get the default rich menu |
| DELETE /bots/{botId}/richmenus/default | Delete the default rich menu |
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 request | Description |
|---|---|
| POST /bots/{botId}/channels | Create 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}/members | Get members of a message room |
You can add, update, and delete bots using the following API operations.
For more information about adding a bot, see Overview.
You can manage bots in the LINE WORKS tenant using the following API operations.
| HTTP request | Description |
|---|---|
| POST /bots | Add a bot |
| GET /bots | Get 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}/secret | Reissue a bot secret |
You can manage bots for each LINE WORKS domain using the following API operations.
| HTTP request | Description |
|---|---|
| POST /bots/{botId}/domains/{domainId} | Add a bot domain |
| GET /bots/{botId}/domains | Get 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}/members | Add a bot user |
| GET /bots/{botId}/domains/{domainId}/members | Get bot users |
| DELETE /bots/{botId}/domains/{domainId}/members/{userId} | Delete a bot user |