Descarga de la fuente abierta Bot Libre de la Comunidad de Edición e instalar el Bot Libre en tu propio servidor
Bot Libre Forum

Create your own bot app with the Bot Libre SDK

por admin publicado May 13 2014, 15:03

The Bot Libre SDK is a Software Development Kit that makes it simple to add a chat bot to your own mobile application or website.

Bot Libre provides SDKs for several languages and platforms including, JavaScript, Android, Java, and iOS/iPhone. See SDK

The SDKs provides two components. The first is a Java Connection API that makes it easy to access Bot Libre web API. The second component is a set of interface components that you can add to your own application or website, or copy/customize in your own application or website.

The SDK is developed under BotLibre.og an open source project hosted on GitHub
https://github.com/BotLibre

Connection API

You can create a connection to the Bot Libre server using the SDKConnection class. You need to pass your connection Credentials, which includes your application ID. You can obtain an application from the Bot Libre website, from your user details page.

SDKConnection connection =
        new SDKConnection(new BOTlibreCredential("12345");

The SDK includes a set of data objects that represent the Bot Libre object model.
The data objects are in the org.botlibre.sdk.config package, and include the following,

  • UserConfig - Defines a user's credentials and info.
  • BrowseConfig - Defines a search query criteria.
  • ChannelConfig - Defines a live chat channel's details.
  • InstanceConfig - Defines a bot's details.
  • ForumConfig - Defines a forum's details.
  • ForumPostConfig - Defines a forum post.
  • DomainConfig - Defines a domain's details.
  • ChatConfig - Input for chat bot messaging.
  • VoiceConfig - Defines a chat bot's voice.
  • ChatResponse - Response for chat bot messaging.
  • ContentConfig - Defines a tag/category request.

Users

The API allows you to connect a user, or create a new user.

Use the connect() API to connect a user, the user's details will be returned, or an error message if the connect fails. The returned user details will not include the password, but will include a token, that can be used in place of the password. After connecting a connection, all subsequent requests will use the user credentials, until you call disconnect().

UserConfig user = new UserConfig();
user.user = "test";
user.password = "password";
user = connection.connect(user);

Use the create() API to create a new user. A user id and password are required. You can also pass the user's name, email, bio, and other details. The user details are returned, with a token in place of the password.

UserConfig user = new UserConfig();
user.user = "test";
user.password = "password";
user.name = "Test Account";
user.email = "[email protected]";
user = connection.create(user);

Bots

The API allows you to browse bots, get a bot's details, and chat with a bot.

The browse() API is used to browse or search the set of channels in the domain.

BrowseConfig browse = new BrowseConfig();
browse.type = "Bot";
browse.typeFilter= "Public";
browse.tag= "cool";
browse.sort = "name";
List bots = connection.browse(browse);

The fetch() API is used to get a bot's details.

InstanceConfig bot = new InstanceConfig();
bot.id = "12345";
bot = connection.fetch(bot);

The chat() API is used to chat with a bot.

ChatConfig chat = new ChatConfig();
chat.instance = "12345";
chat.message = "Hello bot";
ChatResponse response = connection.chat(chat);

Live Chat

The API allows you to browse channels, and get channel details.

The browse() API is used to browse or search the set of channels in the domain.

BrowseConfig browse = new BrowseConfig();
browse.type = "Channel";
browse.typeFilter= "Public";
browse.tag= "cool";
browse.sort = "name";
List channels = connection.browse(browse);

The fetch() API is used to get a channel's details.

ChannelConfig channel = new ChannelConfig();
channel.id = "12345";
channel = connection.fetch(channel);

The LiveChatConnection class is used to chat in a channel. It can be created using the openLiveChat() API on the SDKConnection class. You must pass the ChannelConfig with its id set, and an implementation of LiveChatListener that will receive the chat messages. Once you have a connection established, you can send and receive messages.

ChannelConfig channel = new ChannelConfig();
channel.id = "12345";
LiveChatConnection livechat = connection.openLiveChat(channel, myListener);
livechat.sendMessage("Hello World");

Android Activities

The SDK includes a set of Android activities you can reuse, or modify in your own app. The MainActivity contains the SDKConnection and some shared data, so you will need to include it even if not using the activity. The bot activities include, ChooseBotActivity, InstanceActivity, BrowseActivity, and ChatActivity. The live chat activities include, ChooseChannelActivity, ChannelActivity, ChannelBrowseActivity, and LiveChatActivity.

Here is an example of launching a bot InstanceActivity.

MainActivity.current = new MainActivity();
InstanceConfig config = new InstanceConfig();
config.id = "12345";
HttpAction action = new HttpFetchAction(this, config);
action.execute();

Note, because of the way Android does its packaging, you will need to search/replace the "org.botlibre.sdk.activity.R" import with your own application's unique package. This will resolve the generated R class dependencies. Eclipse ADT can do this automatically from its Android Tools menu.

You can use the SDK to access any of Bot Libre's services, for personal, academic, or commercial applications. You cannot use them for spam, or to violate the Bot Libre's terms of service. Bot Libre's services are also provided as a commercial service on BotLibre.biz.


by jyambz posted Aug 23 2018, 16:07

As i sign up using a different user account on my bots app.I never browse my bots inside the app. I only have my bots nothing less.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 3303, today: 0, week: 1, month: 3

by admin posted Aug 23 2018, 18:41
Not sure I understand?

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 3234, today: 0, week: 4, month: 5

Id: 26632
Etiquetas: blog, android, api, mobile, sdk, java
Publicado: May 13 2014, 15:03
Actualizado: Aug 23 2018, 18:41
Respuestas: 2
Vistas: 17300, hoy: 2, la semana: 15, mes: 19
2 0 5.0/5