Got a question? Message me on Watson Workspace
A Watson Work Services app written in Spring Boot. This project allows an application to connect to Watson Work Services to receive and send messages via Webhook API.
The main purpose of this project is to provide third party app developers to be able to hook in their app logic without worrying about writing your own implementation from scratch.
- create message in a space
- set app photo
- By default the app looks for a file named
app-photo.jpg
insrc/main/reources
directory. The photo will be uploaded one the app start by using the @PostConstruct annotation
- By default the app looks for a file named
- upload file to a space
- authorize the application to act on behalf of a user
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- In your Web browser, go to Watson Work Services / Apps
- Click on
Create new app
- Give your app an unique name with description and click on
Create
- Take a note of the
App ID
andApp Secret
- Click on
Listen to Events -> Add an outbound webhook
- In the callback URL, specify the URL for your app. This code assumes that the webhook listener is at https://yoururl/webhook so don't forget to add /webhook to the end of the URL (if you don't know where the app will be deployed, use a sample URL for now, like https://test.acme.com/webhook and you can modify that later)
- Take a note of Webhook Secret
NOTE: Do not commit your app Id, secret, and webhook secret when pushing your changes to Github
Prerequisite for running the app using IntelliJ IDEA:
- Install Lombok Plugin for IntelliJ IDEA
- Install Ngrok - used for testing the app locally without deploying on any PaaS
- Fork it
- Clone the project
git clone https://github.com/YOUR_GITHUB_USERNAME/watsonwork-spring-boot.git
- Open IntelliJ IDEA
File -> New -> Project from Exisiting Sources...
- Navigate to the project and select
build.gradle
. ClickOK
- Click
OK
on Import Project from Gradle window - Open
src/main/resources/application.yml
watsonwork:
webhook:
secret: ${WEBHOOK_SECRET:of7bs9evq4lnbi9slg0qq2k7z6nsfk7y} #replace of7bs9evq4lnbi9slg0qq2k7z6nsfk7y with your webhook secret
app:
id: ${APP_ID:c79e3474-e963-4024-aa47-4a1087903381} #replace c79e3474-e963-4024-aa47-4a1087903381 with your app Id
secret: ${APP_SECRET:javltqgjfvjh2d99zj5bjdfr0q4x5lw3} #replace javltqgjfvjh2d99zj5bjdfr0q4x5lw3 with your app secret
api:
uri: ${WATSON_WORK_API_URI:https://api.watsonwork.ibm.com}
- Right click on
ApplicationBoostrap.java
->
Run ApplicationBootstrap..
- Open up terminal where ngrok is installed and run the command
ngrok.exe http 9080
on windows or./ngrok http 9080
on unix. By default the app runs onhttp port 9080
. This exposes your app via a publicly accessible URL. ngrok displays a forwarding url after executing the command above which might look as such:http://sd2323.ngrok.io
. Take a note of that URL - Navigate to your app on Watson Work Services / Apps. Select
Listen to Events
. Edit the webhook configuration with the new publicly available URL from ngrok. Make sure your callback URL has /webhook path. For example:http://sd2323.ngrok.io/webhook
- Select
message-created
Event. ClickSave
andEnable
the webhook - Add your app to a space on Watson Workspace and watch it echo your messages..
Assuming you have completed steps 1-6 in Running locally using IntelliJ IDEA
- Sign up for a free trial on Bluemix
- Install the Cloud Foundry CLI and then Install the Bluemix CLI. On Windows, be sure to add the bluemix cli to your PATH.
- Run
bluemix login -a https://api.ng.bluemix.net
, and enter your email and password when prompted - Open terminal in the project root. Run
./gradlew clean build
on linux/mac orgradlew clean build
on windows. - Run
cf push my-app-name -p build/libs/watsonwork-spring-boot-X.X.X.jar -m 512m
(Tip: Make sure the name you want to use is not taken on Bluemix already, since it must be unique.) - When it's finished pushing to bluemix, visit your app's url.
- Navigate to your app on Watson Work Services / Apps. Select
Listen to Events
. Edit the webhook configuration with the new publicly available URL from Bluemix. Make sure your callback URL has /webhook path. For example:https://my-host-name.mybluemix.net/webhook
- Spring Boot 1.5.6 - Web Framework
- Gradle - Dependency Management