Skip to content

A sample app that sends a Hello World message to a space in IBM Watson Workspace

License

Notifications You must be signed in to change notification settings

kevingrozav/watsonwork-helloworld

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

watsonwork-helloworld

Build Status

A Node.js sample app that sends a Hello World message to a space in [IBM Watson Workspace] (https://workspace.ibm.com).

The Watson Work platform provides spaces for people to exchange messages in conversations. This sample app shows how to retrieve information about a space, then send a message to the conversation in that space. It also demonstrates how to authenticate an application and obtain the OAuth token needed to make Watson Work API calls.

Try it out

To try the sample app do the following:

Registering the app

In your Web browser, go to [Watson Work Services - Apps] (https://workspace.ibm.com/developer/apps), add a new app named Hello World and write down its app id and app secret.

Building the app

Install Node.js 6+.

In a terminal window, do the following:

# For more verbose output
export DEBUG=watsonwork-*

# Get the code
git clone https://github.com/watsonwork/watsonwork-helloworld

# Build the app
cd watsonwork-helloworld
npm run build

Adding the app to a space

Leave the terminal window open as you'll need it again soon.

In your Web browser, go to Watson Workspace, create a space named Examples, then open the Apps tab for that space and add the Hello World app to it.

Sending a message using the app

You're now ready to use the sample app to send a message!

Back in the terminal window, do the following:

# Configure the app id and app secret
export HELLOWORLD_APP_ID=<the Hello World app id>
export HELLOWORLD_APP_SECRET=<the Hello World app secret>

npm run helloworld "Examples"

The Hello World app will send "Hello World! Welcome to Watson Work!" to the conversation in the Examples space. You should now see a new message in that space.

Project layout

The sample project source tree is organized as follows:

README.md     - this README
package.json  - Node.js package definition

src/          - Javascript sources

  app.js      - main app script

  test/       - unit tests

What API does the app use?

The app uses the [Watson Work OAuth API] (https://workspace.ibm.com/developer/docs) to authenticate and get an OAuth token. It then uses the [Watson Work GraphQL API] (https://workspace.ibm.com/developer/docs) to retrieve a list of spaces. Finally, it uses the [Watson Work Spaces API] (https://workspace.ibm.com/developer/docs) to send a message to the conversation in the selected space.

How can I contribute?

Pull requests welcome!

About

A sample app that sends a Hello World message to a space in IBM Watson Workspace

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%