Code Monkey home page Code Monkey logo

watsonwork-spring-boot's Introduction

Build Status

Got a question? Message me on Watson Workspace

watsonwork-spring-boot

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.

API Supported by the app

  • create message in a space
  • set app photo
    • By default the app looks for a file named app-photo.jpg in src/main/reources directory. The photo will be uploaded one the app start by using the @PostConstruct annotation
  • upload file to a space
  • authorize the application to act on behalf of a user

Getting Started

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.

Creating Watson Work Services App

  1. In your Web browser, go to Watson Work Services / Apps
  2. Click on Create new app
  3. Give your app an unique name with description and click on Create
  4. Take a note of the App ID and App Secret
  5. Click on Listen to Events -> Add an outbound webhook
  6. 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)
  7. Take a note of Webhook Secret

NOTE: Do not commit your app Id, secret, and webhook secret when pushing your changes to Github

Running locally using IntelliJ IDEA

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
  1. Fork it
  2. Clone the project git clone https://github.com/YOUR_GITHUB_USERNAME/watsonwork-spring-boot.git
  3. Open IntelliJ IDEA File -> New -> Project from Exisiting Sources...
  4. Navigate to the project and select build.gradle. Click OK
  5. Click OK on Import Project from Gradle window
  6. 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} 
  1. Right click on ApplicationBoostrap.java -> Run ApplicationBootstrap..
  2. 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 on http 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
  3. 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
  4. Select message-created Event. Click Save and Enable the webhook
  5. Add your app to a space on Watson Workspace and watch it echo your messages..

Deployment

Deploying on IBM Bluemix

Assuming you have completed steps 1-6 in Running locally using IntelliJ IDEA

  1. Sign up for a free trial on Bluemix
  2. Install the Cloud Foundry CLI and then Install the Bluemix CLI. On Windows, be sure to add the bluemix cli to your PATH.
  3. Run bluemix login -a https://api.ng.bluemix.net, and enter your email and password when prompted
  4. Open terminal in the project root. Run ./gradlew clean build on linux/mac or gradlew clean build on windows.
  5. Run cf push my-app-name -p build/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.)
  6. When it's finished pushing to bluemix, visit your app's url.
  7. 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

Built With

watsonwork-spring-boot's People

Contributors

bhumit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.