Skip to content

Latest commit

 

History

History
681 lines (486 loc) · 19.7 KB

BotApi.md

File metadata and controls

681 lines (486 loc) · 19.7 KB

BotApi

All URIs are relative to https://api-APP_ID.sendbird.com

Method HTTP request Description
createBot POST /v3/bots Create a bot
deleteBotById DELETE /v3/bots/{bot_userid} Delete a bot
joinChannels POST /v3/bots/{bot_userid}/channels Join channels
leaveChannels DELETE /v3/bots/{bot_userid}/channels Leave channels - When leaving all channels
leaveChannelsByUrl DELETE /v3/bots/{bot_userid}/channels/{channel_url} Leave channels - When leaving a channel by its channel URL
listBots GET /v3/bots List bots
sendBotsMessage POST /v3/bots/{bot_userid}/send Send a bot's message
updateBotById PUT /v3/bots/{bot_userid} Update a bot
viewBotById GET /v3/bots/{bot_userid} View a bot

createBot

CreateBotResponse createBot(apiToken, createBotData)

Create a bot

Create a bot

Creates a new bot within the application. Creating a bot is similar to creating a normal user, except that a callback URL is specified in order for the bot to receive events.

Note: The bot must join a group channel first to interact with users. In group channels, you can invite a bot through the invite as members action instead.

https://sendbird.com/docs/chat/v3/platform-api/guides/bot-interface#2-create-a-bot

Example

// Import classes:
import org.sendbird.client.ApiClient;
import org.sendbird.client.ApiException;
import org.sendbird.client.Configuration;
import org.sendbird.client.model.*;
import org.sendbird.client.api.BotApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api-APP_ID.sendbird.com");

        BotApi apiInstance = new BotApi(defaultClient);
        String apiToken = "{{API_TOKEN}}"; // String | 
        CreateBotData createBotData = new CreateBotData(); // CreateBotData | 
        try {
            CreateBotResponse result = apiInstance.createBot(apiToken, createBotData);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling BotApi#createBot");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
apiToken String
createBotData CreateBotData [optional]

Return type

CreateBotResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful response -

deleteBotById

Object deleteBotById(apiToken, botUserid)

Delete a bot

Delete a bot

Deletes a bot from an application.

Example

// Import classes:
import org.sendbird.client.ApiClient;
import org.sendbird.client.ApiException;
import org.sendbird.client.Configuration;
import org.sendbird.client.model.*;
import org.sendbird.client.api.BotApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api-APP_ID.sendbird.com");

        BotApi apiInstance = new BotApi(defaultClient);
        String apiToken = "{{API_TOKEN}}"; // String | 
        String botUserid = "botUserid_example"; // String | 
        try {
            Object result = apiInstance.deleteBotById(apiToken, botUserid);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling BotApi#deleteBotById");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
apiToken String
botUserid String

Return type

Object

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful response -

joinChannels

JoinChannelsResponse joinChannels(apiToken, botUserid, joinChannelsData)

Join channels

Join channels

Makes a bot join one or more channels.

Example

// Import classes:
import org.sendbird.client.ApiClient;
import org.sendbird.client.ApiException;
import org.sendbird.client.Configuration;
import org.sendbird.client.model.*;
import org.sendbird.client.api.BotApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api-APP_ID.sendbird.com");

        BotApi apiInstance = new BotApi(defaultClient);
        String apiToken = "{{API_TOKEN}}"; // String | 
        String botUserid = "botUserid_example"; // String | 
        JoinChannelsData joinChannelsData = new JoinChannelsData(); // JoinChannelsData | 
        try {
            JoinChannelsResponse result = apiInstance.joinChannels(apiToken, botUserid, joinChannelsData);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling BotApi#joinChannels");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
apiToken String
botUserid String
joinChannelsData JoinChannelsData [optional]

Return type

JoinChannelsResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful response -

leaveChannels

leaveChannels(apiToken, botUserid, channelUrl)

Leave channels - When leaving all channels

Leave channels

Makes a bot leave one or more group channels.

Example

// Import classes:
import org.sendbird.client.ApiClient;
import org.sendbird.client.ApiException;
import org.sendbird.client.Configuration;
import org.sendbird.client.model.*;
import org.sendbird.client.api.BotApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api-APP_ID.sendbird.com");

        BotApi apiInstance = new BotApi(defaultClient);
        String apiToken = "{{API_TOKEN}}"; // String | 
        String botUserid = "botUserid_example"; // String | 
        String channelUrl = "channelUrl_example"; // String | 
        try {
            apiInstance.leaveChannels(apiToken, botUserid, channelUrl);
        } catch (ApiException e) {
            System.err.println("Exception when calling BotApi#leaveChannels");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
apiToken String
botUserid String
channelUrl String [optional]

Return type

null (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

HTTP response details

Status code Description Response headers
200 Successful response -

leaveChannelsByUrl

Object leaveChannelsByUrl(apiToken, botUserid, channelUrl)

Leave channels - When leaving a channel by its channel URL

Leave channels

Makes a bot leave one or more group channels.

Example

// Import classes:
import org.sendbird.client.ApiClient;
import org.sendbird.client.ApiException;
import org.sendbird.client.Configuration;
import org.sendbird.client.model.*;
import org.sendbird.client.api.BotApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api-APP_ID.sendbird.com");

        BotApi apiInstance = new BotApi(defaultClient);
        String apiToken = "{{API_TOKEN}}"; // String | 
        String botUserid = "botUserid_example"; // String | 
        String channelUrl = "channelUrl_example"; // String | 
        try {
            Object result = apiInstance.leaveChannelsByUrl(apiToken, botUserid, channelUrl);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling BotApi#leaveChannelsByUrl");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
apiToken String
botUserid String
channelUrl String

Return type

Object

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful response -

listBots

ListBotsResponse listBots(apiToken, token, limit)

List bots

List bots

Retrieves a list of all bots within an application.

Example

// Import classes:
import org.sendbird.client.ApiClient;
import org.sendbird.client.ApiException;
import org.sendbird.client.Configuration;
import org.sendbird.client.model.*;
import org.sendbird.client.api.BotApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api-APP_ID.sendbird.com");

        BotApi apiInstance = new BotApi(defaultClient);
        String apiToken = "{{API_TOKEN}}"; // String | 
        String token = "token_example"; // String | 
        Integer limit = 56; // Integer | 
        try {
            ListBotsResponse result = apiInstance.listBots(apiToken, token, limit);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling BotApi#listBots");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
apiToken String
token String [optional]
limit Integer [optional]

Return type

ListBotsResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful response -

sendBotsMessage

SendBirdMessageResponse sendBotsMessage(apiToken, botUserid, sendBotSMessageData)

Send a bot's message

Send a bot's message

Sends a bot's message to a channel.

bot_userid Type: string Description: Specifies the ID of the bot to send a message.

Example

// Import classes:
import org.sendbird.client.ApiClient;
import org.sendbird.client.ApiException;
import org.sendbird.client.Configuration;
import org.sendbird.client.model.*;
import org.sendbird.client.api.BotApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api-APP_ID.sendbird.com");

        BotApi apiInstance = new BotApi(defaultClient);
        String apiToken = "{{API_TOKEN}}"; // String | 
        String botUserid = "botUserid_example"; // String | 
        SendBotSMessageData sendBotSMessageData = new SendBotSMessageData(); // SendBotSMessageData | 
        try {
            SendBirdMessageResponse result = apiInstance.sendBotsMessage(apiToken, botUserid, sendBotSMessageData);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling BotApi#sendBotsMessage");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
apiToken String
botUserid String
sendBotSMessageData SendBotSMessageData [optional]

Return type

SendBirdMessageResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful response -

updateBotById

UpdateBotByIdResponse updateBotById(apiToken, botUserid, updateBotByIdData)

Update a bot

Update a bot

Updates information on a bot.

Example

// Import classes:
import org.sendbird.client.ApiClient;
import org.sendbird.client.ApiException;
import org.sendbird.client.Configuration;
import org.sendbird.client.model.*;
import org.sendbird.client.api.BotApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api-APP_ID.sendbird.com");

        BotApi apiInstance = new BotApi(defaultClient);
        String apiToken = "{{API_TOKEN}}"; // String | 
        String botUserid = "botUserid_example"; // String | 
        UpdateBotByIdData updateBotByIdData = new UpdateBotByIdData(); // UpdateBotByIdData | 
        try {
            UpdateBotByIdResponse result = apiInstance.updateBotById(apiToken, botUserid, updateBotByIdData);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling BotApi#updateBotById");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
apiToken String
botUserid String
updateBotByIdData UpdateBotByIdData [optional]

Return type

UpdateBotByIdResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful response -

viewBotById

ViewBotByIdResponse viewBotById(apiToken, botUserid)

View a bot

View a bot

Retrieves information on a bot.

Example

// Import classes:
import org.sendbird.client.ApiClient;
import org.sendbird.client.ApiException;
import org.sendbird.client.Configuration;
import org.sendbird.client.model.*;
import org.sendbird.client.api.BotApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api-APP_ID.sendbird.com");

        BotApi apiInstance = new BotApi(defaultClient);
        String apiToken = "{{API_TOKEN}}"; // String | 
        String botUserid = "botUserid_example"; // String | 
        try {
            ViewBotByIdResponse result = apiInstance.viewBotById(apiToken, botUserid);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling BotApi#viewBotById");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
apiToken String
botUserid String

Return type

ViewBotByIdResponse

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful response -