This document summarizes a presentation about using the Watson Work Services Java SDK. It introduces the SDK, provides examples of how to authenticate and make requests using the SDK, and demonstrates integrating an app with Watson Workspace using the SDK. It also lists additional resources like documentation and an API explorer.
1. Vienna, October 16-17 2017
Using Watson Work Services
Java SDK*
Paul Withers, Intec System Ltd
@paulswithers
*Supported by Watson Workspace Emoticons
3. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Paul Withers
• pwithers@intec.co.uk
• https://watsonwork.me/pwithers@intec.co.uk
• @paulswithers
• http://www.intec.co.uk/blog
Notes Developer XPages Developer Java Developer
Watson Work
Services Developer
4. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
So You Want To…
• Build Apps
• Integrate with Watson Workspace /
Watson Work Services
• Code in Java
5. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Vienna, October 16-17 2017
App Pre-Requisites and Basics
6. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
• Create app at
https://workspace.ibm.com/developer/apps
• Make a note of appId and appSecret
• All code will need them!
• Secret is only shown when app is created
• Can now be regenerated
Setup Workspace App
7. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Your Java
Application
Watson
Workspace
Request Authorisation Code
https://api.watsonwork.ibm.com/oauth/authorize
oAuth 2.0
Return Authorisation Code
Request Authentication Token
https://api.watsonwork.ibm.com/oauth/token
Return Authentication Token
Use Token in Subsequent Requests
8. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Development
• scope=ibmid
• redirecturi just needs to be
accessible to browser
• Webhooks need externally
accessible URL
• Use ngrok
9. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Vienna, October 16-17 2017
Watson Work Services
10. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Watson Work Services APIs
• REST API Endpoints
• GET /oauth/authorize
• POST /v1/spaces/{spaceId}/files
• GraphQL Endpoint
• POST /graphql
11. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
GraphQL API Explorer
You could create / parse JSON manually in Java
12. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Vienna, October 16-17 2017
Watson Work Services Java SDK
13. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Watson Work Java SDK
14. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Using the SDK
• XPages Packaged Plugin from OpenNTF
• Download jar file from OpenNTF / Maven Central
• Maven
• Source code on Stash (includes Junit tests)
• Latest documentation on OpenNTF Wiki, Javadoc
<dependency>
<groupId>org.opencode4workspace.watson-work-services</groupId>
<artifactId>wws-api</artifactId>
<version>0.7.0</version>
</dependency>
15. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Using the SDK
• WWClient authentication as application / user
• Builder pattern for easy generation and compile-
time validation of queries
• Methods to output query and response as strings
• Automatic conversion of response to Java objects
• Methods to parse error response
16. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Basic Sample
17. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
More Complex Example
18. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Remember the IBM Connect OGS
• Notifications from Domino to Workspace by
Sapho
• Scheduled agent
Can open source do it quicker?
19. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Solving a Real-World Problem
20. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Demo
21. Social Connections 11 Chicago, June 1-2 2017Social Connections 12 Vienna, October 16-17 2017
Links
• Demo
• Watson Work Service Java SDK Documentation
• OpenNTF Project
• Watson Workspace Documentation
• Watson Work Services Explorer
Questions?