org.botlibre.sdk
Class SDKConnection

java.lang.Object
  extended by org.botlibre.sdk.SDKConnection

public class SDKConnection
extends java.lang.Object

Connection class for a REST service connection. The SDK connection gives you access to the paphus or libre server services using a REST API.

The services include:


Constructor Summary
SDKConnection(Credentials credentials)
          Create an SDK connection with the credentials.
 
Method Summary
 void addAvatar(java.lang.String file, InstanceConfig config)
          Add the new avatar to the bot.
 void addSharedAvatar(AvatarConfig config)
          Add the shared avatar to the bot's avatars.
 java.util.List<WebMediumConfig> browse(BrowseConfig config)
          Return the list of content for the browse criteria.
 ChatResponse chat(ChatConfig config)
          Process the bot chat message and return the bot's response.
 DomainConfig connect(DomainConfig config)
          Connect to the domain.
 UserConfig connect(UserConfig config)
          Validate the user credentials (password, or token).
 ForumPostConfig create(ForumPostConfig config)
          Create a new forum post.
<T extends WebMediumConfig>
T
create(T config)
          Create the new content.
 UserConfig create(UserConfig config)
          Create a new user.
 MediaConfig createChannelFileAttachment(java.lang.String file, MediaConfig config)
          Create a new file/image/media attachment for a chat channel.
 MediaConfig createChannelImageAttachment(java.lang.String file, MediaConfig config)
          Create a new file/image/media attachment for a chat channel.
 ForumPostConfig createReply(ForumPostConfig config)
          Create a reply to a forum post.
static java.lang.String defaultUserImage()
          Return the name of the default user image.
 void delete(ForumPostConfig config)
          Permanently delete the forum post with the id.
 void delete(WebMediumConfig config)
          Permanently delete the content with the id.
 void deleteAllAvatars(InstanceConfig config)
          Delete all of the avatars for the bot.
 void deleteAvatar(AvatarConfig config)
          Delete the avatar from the bot.
 void disconnect()
          Disconnect from the connection.
 ForumPostConfig fetch(ForumPostConfig config)
          Fetch the forum post details for the forum post id.
<T extends WebMediumConfig>
T
fetch(T config)
          Fetch the content details from the server.
 UserConfig fetch(UserConfig config)
          Fetch the user details for the user credentials.
 java.net.URL fetchImage(java.lang.String image)
          Fetch the URL for the image from the server.
 void flag(ForumPostConfig config)
          Flag the forum post as offensive, a reason is required.
 void flag(UserConfig config)
          Flag the user post as offensive, a reason is required.
 void flag(WebMediumConfig config)
          Flag the content as offensive, a reason is required.
 java.lang.String[] getAccessModes()
          Return the access mode types.
 java.util.List<java.lang.String> getAdmins(WebMediumConfig config)
          Return the administrators of the content.
 java.util.List<AvatarConfig> getAvatars(InstanceConfig config)
          Return the avatars for the bot instances.
 java.lang.String[] getBotModes()
          Return the bot mode types.
 java.util.List<java.lang.String> getCategories(ContentConfig config)
          Return the list of categories for the type, and domain.
 BotModeConfig getChannelBotMode(ChannelConfig config)
          Return the channel's bot configuration.
 java.lang.String[] getChannelTypes()
          Return the channel types.
 java.lang.String[] getCorrectionModes()
          Return the correction mode types.
 Credentials getCredentials()
          Return the current application credentials.
 java.util.List<java.lang.String> getDefaultResponses(InstanceConfig config)
          Return the bot's default responses.
 DomainConfig getDomain()
          Return the current domain.
 SDKException getException()
          Return the last thrown exception.
 BotModeConfig getForumBotMode(ForumConfig config)
          Return the forum's bot configuration.
 java.util.List<java.lang.String> getGreetings(InstanceConfig config)
          Return the bot's greetings.
 LearningConfig getLearning(InstanceConfig config)
          Return the bot's learning configuration.
 java.lang.String[] getLearningModes()
          Return the learning mode types.
 java.util.List<ForumPostConfig> getPosts(BrowseConfig config)
          Return the list of forum posts for the forum browse criteria.
 java.util.List<AvatarConfig> getSharedAvatars()
          Return the shared avatar images for the server.
 java.util.List<java.lang.String> getTags(ContentConfig config)
          Return the list of tags for the type, and domain.
 java.util.List<java.lang.String> getTemplates()
          Return the list of bot templates.
 java.lang.String[] getTypes()
          Return the list of content types.
 UserConfig getUser()
          Return the current connected user.
 java.util.List<UserConfig> getUsers(java.lang.String usersCSV)
          Return the list of user details for the comma separated values list of user ids.
 java.util.List<java.lang.String> getUsers(WebMediumConfig config)
          Return the users for the content.
 VoiceConfig getVoice(InstanceConfig config)
          Return the bot's voice configuration.
 boolean isDebug()
          Return is debugging has been enabled.
 LiveChatConnection openLiveChat(ChannelConfig channel, LiveChatListener listener)
          Connect to the live chat channel and return a LiveChatConnection.
 void saveChannelBotMode(BotModeConfig config)
          Save the channel's bot configuration.
 void saveForumBotMode(BotModeConfig config)
          Save the forum's bot configuration.
 void saveLearning(LearningConfig config)
          Save the bot's learning configuration.
 void saveVoice(VoiceConfig config)
          Save the bot's voice configuration.
 void setCredentials(Credentials credentials)
          Set the application credentials.
 void setDebug(boolean debug)
          Enable debugging, debug messages will be logged to System.out.
 void setDomain(DomainConfig domain)
          Set the current domain.
 void setUser(UserConfig user)
          Set the current connected user.
 void tagAvatar(AvatarConfig config)
          Tag the avatar with the emotions.
 void train(TrainingConfig config)
          Train the bot with a new question/response pair.
 ForumPostConfig update(ForumPostConfig config)
          Update the forum post.
<T extends WebMediumConfig>
T
update(T config)
          Update the content.
 UserConfig update(UserConfig config)
          Update the user details.
<T extends WebMediumConfig>
T
updateIcon(java.lang.String file, T config)
          Update the contents icon.
 UserConfig updateIcon(java.lang.String file, UserConfig config)
          Update the user's icon.
 void userAdmin(UserAdminConfig config)
          Perform the user administration task (add or remove users, or administrators).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SDKConnection

public SDKConnection(Credentials credentials)
Create an SDK connection with the credentials. Use the Credentials subclass specific to your server.

Method Detail

defaultUserImage

public static java.lang.String defaultUserImage()
Return the name of the default user image.


connect

public UserConfig connect(UserConfig config)
Validate the user credentials (password, or token). The user details are returned (with a connection token, password removed). The user credentials are soted in the connection, and used on subsequent calls. An SDKException is thrown if the connect failed.


openLiveChat

public LiveChatConnection openLiveChat(ChannelConfig channel,
                                       LiveChatListener listener)
Connect to the live chat channel and return a LiveChatConnection. A LiveChatConnection is separate from an SDKConnection and uses web sockets for asynchronous communication. The listener will be notified of all messages.


connect

public DomainConfig connect(DomainConfig config)
Connect to the domain. A domain is an isolated content space. Any browse or query request will be specific to the domain's content.


disconnect

public void disconnect()
Disconnect from the connection. An SDKConnection does not keep a live connection, but this resets its connected user and domain.


fetch

public UserConfig fetch(UserConfig config)
Fetch the user details for the user credentials. A token or password is required to validate the user.


fetchImage

public java.net.URL fetchImage(java.lang.String image)
Fetch the URL for the image from the server.


fetch

public ForumPostConfig fetch(ForumPostConfig config)
Fetch the forum post details for the forum post id.


create

public UserConfig create(UserConfig config)
Create a new user.


create

public ForumPostConfig create(ForumPostConfig config)
Create a new forum post. You must set the forum id for the post.


createChannelFileAttachment

public MediaConfig createChannelFileAttachment(java.lang.String file,
                                               MediaConfig config)
Create a new file/image/media attachment for a chat channel.


createChannelImageAttachment

public MediaConfig createChannelImageAttachment(java.lang.String file,
                                                MediaConfig config)
Create a new file/image/media attachment for a chat channel.


createReply

public ForumPostConfig createReply(ForumPostConfig config)
Create a reply to a forum post. You must set the parent id for the post replying to.


fetch

public <T extends WebMediumConfig> T fetch(T config)
Fetch the content details from the server. The id or name and domain of the object must be set.


create

public <T extends WebMediumConfig> T create(T config)
Create the new content. The content will be returned with its new id.


update

public <T extends WebMediumConfig> T update(T config)
Update the content.


update

public ForumPostConfig update(ForumPostConfig config)
Update the forum post.


update

public UserConfig update(UserConfig config)
Update the user details. The password must be passed to allow the update.


delete

public void delete(WebMediumConfig config)
Permanently delete the content with the id.


delete

public void delete(ForumPostConfig config)
Permanently delete the forum post with the id.


flag

public void flag(WebMediumConfig config)
Flag the content as offensive, a reason is required.


flag

public void flag(ForumPostConfig config)
Flag the forum post as offensive, a reason is required.


flag

public void flag(UserConfig config)
Flag the user post as offensive, a reason is required.


chat

public ChatResponse chat(ChatConfig config)
Process the bot chat message and return the bot's response. The ChatConfig should contain the conversation id if part of a conversation. If a new conversation the conversation id is returned in the response.


getAdmins

public java.util.List<java.lang.String> getAdmins(WebMediumConfig config)
Return the administrators of the content.


getAvatars

public java.util.List<AvatarConfig> getAvatars(InstanceConfig config)
Return the avatars for the bot instances.


getSharedAvatars

public java.util.List<AvatarConfig> getSharedAvatars()
Return the shared avatar images for the server.


getUsers

public java.util.List<UserConfig> getUsers(java.lang.String usersCSV)
Return the list of user details for the comma separated values list of user ids.


getPosts

public java.util.List<ForumPostConfig> getPosts(BrowseConfig config)
Return the list of forum posts for the forum browse criteria.


getCategories

public java.util.List<java.lang.String> getCategories(ContentConfig config)
Return the list of categories for the type, and domain.


getTags

public java.util.List<java.lang.String> getTags(ContentConfig config)
Return the list of tags for the type, and domain.


getTemplates

public java.util.List<java.lang.String> getTemplates()
Return the list of bot templates.


getUsers

public java.util.List<java.lang.String> getUsers(WebMediumConfig config)
Return the users for the content.


getChannelBotMode

public BotModeConfig getChannelBotMode(ChannelConfig config)
Return the channel's bot configuration.


saveChannelBotMode

public void saveChannelBotMode(BotModeConfig config)
Save the channel's bot configuration.


saveForumBotMode

public void saveForumBotMode(BotModeConfig config)
Save the forum's bot configuration.


saveLearning

public void saveLearning(LearningConfig config)
Save the bot's learning configuration.


saveVoice

public void saveVoice(VoiceConfig config)
Save the bot's voice configuration.


tagAvatar

public void tagAvatar(AvatarConfig config)
Tag the avatar with the emotions. The avatar will then be displayed when words or sentences trigger the emotional state.


train

public void train(TrainingConfig config)
Train the bot with a new question/response pair.


userAdmin

public void userAdmin(UserAdminConfig config)
Perform the user administration task (add or remove users, or administrators).


deleteAllAvatars

public void deleteAllAvatars(InstanceConfig config)
Delete all of the avatars for the bot.


deleteAvatar

public void deleteAvatar(AvatarConfig config)
Delete the avatar from the bot.


addAvatar

public void addAvatar(java.lang.String file,
                      InstanceConfig config)
Add the new avatar to the bot. The file will be uploaded to the server.


updateIcon

public <T extends WebMediumConfig> T updateIcon(java.lang.String file,
                                                T config)
Update the contents icon. The file will be uploaded to the server.


updateIcon

public UserConfig updateIcon(java.lang.String file,
                             UserConfig config)
Update the user's icon. The file will be uploaded to the server.


getForumBotMode

public BotModeConfig getForumBotMode(ForumConfig config)
Return the forum's bot configuration.


getVoice

public VoiceConfig getVoice(InstanceConfig config)
Return the bot's voice configuration.


getDefaultResponses

public java.util.List<java.lang.String> getDefaultResponses(InstanceConfig config)
Return the bot's default responses.


getGreetings

public java.util.List<java.lang.String> getGreetings(InstanceConfig config)
Return the bot's greetings.


getLearning

public LearningConfig getLearning(InstanceConfig config)
Return the bot's learning configuration.


browse

public java.util.List<WebMediumConfig> browse(BrowseConfig config)
Return the list of content for the browse criteria. The type defines the content type (one of Bot, Forum, Channel, Domain).


addSharedAvatar

public void addSharedAvatar(AvatarConfig config)
Add the shared avatar to the bot's avatars.


getTypes

public java.lang.String[] getTypes()
Return the list of content types.


getChannelTypes

public java.lang.String[] getChannelTypes()
Return the channel types.


getAccessModes

public java.lang.String[] getAccessModes()
Return the access mode types.


getLearningModes

public java.lang.String[] getLearningModes()
Return the learning mode types.


getCorrectionModes

public java.lang.String[] getCorrectionModes()
Return the correction mode types.


getBotModes

public java.lang.String[] getBotModes()
Return the bot mode types.


getUser

public UserConfig getUser()
Return the current connected user.


setUser

public void setUser(UserConfig user)
Set the current connected user. connect() should be used to validate and connect a user.


getDomain

public DomainConfig getDomain()
Return the current domain. A domain is an isolated content space.


setDomain

public void setDomain(DomainConfig domain)
Set the current domain. A domain is an isolated content space. connect() should be used to validate and connect a domain.


getCredentials

public Credentials getCredentials()
Return the current application credentials.


setCredentials

public void setCredentials(Credentials credentials)
Set the application credentials.


isDebug

public boolean isDebug()
Return is debugging has been enabled.


setDebug

public void setDebug(boolean debug)
Enable debugging, debug messages will be logged to System.out.


getException

public SDKException getException()
Return the last thrown exception.