I know many developers, including myself, learn a lot from code samples (probably more than using actual API documentation). So to build on my post from earlier this week, we have published the first 5 code samples into the Watson Work org in Github and there should be more posted this week and next. My samples are the Twitter and Weather apps. I built these as fully functioning apps that you can deploy to a server and get up and going in a few minutes. And once they are running, feel free to hack away!
To make things simpler, I've also included a one-click button to deploy the app to Bluemix (which I thought was freaking cool how they make this possible). This, however, is not a required step. If you want to use with another cloud provider, by all means. Back to Bluemix, when you click the button, Bluemix pulls down the code from Github and magically gets it up and running.
One cool thing is that even before the samples were available, I already picked up a few blogs of developers using the APIs:
- https://redbooth.com/blog/ibm-watson-workspace-integration
- https://guedebyte.wordpress.com/2016/10/28/watson-workspace-work-services-needs-code-code-code-community-code-code-and-even-more-code-and-community/
- https://blog.rocketsoftware.com/2016/10/live-ibm-world-watson-putting-business-social/
- https://kbild.ch/2016/10/watson-workspace-send-nagios-monitoring-alerts-to-a-ww-space/
- http://opentopic.com/ibm-workspaces/
- http://blog.sapho.com/sapho-ibm-watson-workspace-collaboration-and-productivity-made-easy
Welcome #watsonworkspace! Nice that you join my sidebar in my Eclipse / IBM Notes Client. Next Step: Post a message! pic.twitter.com/7C4hyz6MDt— Christian Güdemann (@guedeWebGate) October 31, 2016
So quick tour of the Weather app. It uses the Weather Underground APIs to get current conditions based on a US zipcode. I use the node module to convert the zip code to city and state:
With that info, I now call the Weather Underground APIs to get the current conditions:
Now with the data that I get back, I build a message to post back to IBM Watson Workspace and put it in the appropriate JSON construct:
and then call the API to post it back:
So that should give you an idea on how to listen to a conversation, act on it, and then respond back. I followed a similar flow to build the Twitter app and my hope is you can take it and hack it to build your own. And if you are in the mood to help improve these samples, pull requests are welcome!
Now definitely check out what Redbooth, Rocket, OpenTopic, Sapho and others have done... VERY COOL! (and just to make it more enticing.. Sapho for example has Marketo and Google Adword integration... )
const cityState = zipcode.lookup(zc);
With that info, I now call the Weather Underground APIs to get the current conditions:
client.conditions(opts, function(err, data) {
Now with the data that I get back, I build a message to post back to IBM Watson Workspace and put it in the appropriate JSON construct:
const messageData = { type: "appMessage", version: 1.0, annotations: [ { type: "generic", version: 1.0, color: "#D5212B", title: "Current weather conditions", text: message } ] };
and then call the API to post it back:
request(sendMessageOptions, (err, response, body) => {
So that should give you an idea on how to listen to a conversation, act on it, and then respond back. I followed a similar flow to build the Twitter app and my hope is you can take it and hack it to build your own. And if you are in the mood to help improve these samples, pull requests are welcome!
Now definitely check out what Redbooth, Rocket, OpenTopic, Sapho and others have done... VERY COOL! (and just to make it more enticing.. Sapho for example has Marketo and Google Adword integration... )