Last active
July 22, 2016 16:38
-
-
Save snippet-java/0d3d4233ea25e6b85e8c05d8c88a4a29 to your computer and use it in GitHub Desktop.
Dialog Java Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.dialog.v1.*; | |
import com.ibm.watson.developer_cloud.dialog.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
DialogService service = new DialogService(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/dialog/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.dialog.v1.*; | |
import com.ibm.watson.developer_cloud.dialog.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
DialogService service = new DialogService(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/dialog/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
List<Dialog> dialogs = service.getDialogs(); | |
System.out.println(dialogs); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.dialog.v1.*; | |
import com.ibm.watson.developer_cloud.dialog.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
DialogService service = new DialogService(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/dialog/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
Dialog dialog = service.createDialog("my-dialog", new File("template.xml")); | |
System.out.println(dialog); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.dialog.v1.*; | |
import com.ibm.watson.developer_cloud.dialog.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
DialogService service = new DialogService(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/dialog/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
service.deleteDialog("{dialog_id}"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.dialog.v1.*; | |
import com.ibm.watson.developer_cloud.dialog.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
DialogService service = new DialogService(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/dialog/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
Dialog dialog = service.updateDialog("{dialog_id}", new File("template.xml")); | |
System.out.println(dialog); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.dialog.v1.*; | |
import com.ibm.watson.developer_cloud.dialog.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
DialogService service = new DialogService(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/dialog/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
Map params = new HashMap(); params.put(DialogService.DIALOG_ID, "{dialog_id}"); params.put(DialogService.CLIENT_ID, {client_id}); params.put(DialogService.INPUT, "Hi Hello"); params.put(DialogService.CONVERSATION_ID, {conversation_id}); Conversation conversation = service.converse(params); System.out.println(conversation); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.dialog.v1.*; | |
import com.ibm.watson.developer_cloud.dialog.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
DialogService service = new DialogService(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/dialog/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
Map params = new HashMap(); params.put(DialogService.DIALOG_ID, "{dialog_id}"); params.put(DialogService.DATE_FROM, new Date()); params.put(DialogService.DATE_TO, new Date()); params.put(DialogService.OFFSET, {offset}); params.put(DialogService.LIMIT, {limit}); List conversationData = service.getConversationData(params); System.out.println(conversationData); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.dialog.v1.*; | |
import com.ibm.watson.developer_cloud.dialog.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
DialogService service = new DialogService(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/dialog/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
List profile = service.getProfile("{dialog_id}", {client_id}); System.out.println(profile); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ibm.watson.developer_cloud.dialog.v1.*; | |
import com.ibm.watson.developer_cloud.dialog.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
DialogService service = new DialogService(); | |
TranslationResult translation = null; | |
try { | |
translation = service.translate(null, "en", "es"); | |
} catch (IllegalArgumentException e) { | |
// Missing or invalid parameter | |
} catch (BadRequestException e) { | |
// Missing or invalid parameter | |
} catch (UnauthorizedException e) { | |
// Access is denied due to invalid credentials | |
} catch (ForbiddenException e) { | |
// Forbidden: Service refuse the request | |
} catch (NotFoundException e) { | |
// Not found | |
} catch (TooManyRequestsException e) { | |
// Too many requests | |
} catch (InternalServerErrorException e) { | |
// Internal Server Error | |
} catch (ServiceUnavailableException e) { | |
// Service Unavailable | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment