Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

symphonyoss/symphony-java-sample-bots

Repository files navigation

Symphony Java Sample Bots

NOTE! This repository have been archived; if you're looking for Symphony Java client samples, checkout https://github.com/symphonyoss/symphony-java-client/tree/master/examples


Build Status Open Issues Average time to resolve an issue License CII Best Practices Validation Status FOSSA Status

A series of sample Java bots that use the symphony-java-client (SJC) to interact with the Symphony platform. The main goal of this repository is to help developers moving their first steps with SJC, including the initial and minimum Maven project setup.

The code structure is intentionally kept simple, to improve code readability; no advanced use cases will be hosted in this project, since SJC already includes a long collection of examples

Below are listed the 4 sample bots currently hosted; 2 bots (HelloWorldBot and RssBot) run and terminate, while 2 others (EchoBot and StockInfoBot) run in background continuously and respond to messages under certain conditions.

Browse the code to check the differences.

  • Hello World Bot - org.symphonyoss.samples.HelloWorldBot; sends a hello world message to a given Symphony user (specified via receiver.email in symphony.properties) in a 1:1 chat, then terminates
  • Echo Bot - org.symphonyoss.samples.EchoBot; listens and posts back messages on 1:1 and group Symphony chats
  • Stock Info Bot - org.symphonyoss.samples.StockInfoBot; listens to 1:1 and group Symphony chats, checks messages for cashtags and posts related data extracted from Yahoo Finance API
  • RSS Bot - org.symphonyoss.samples.RssBot; fetches RSS feed data from given url (rss.url in symphony.properties) and sends some (rss.limit in symphony.properties) of them to a given Symphony user (user.email in symphony.properties) in a 1:1 chat.

Project setup

Follow these instructions to get started with this project and run your first java application using the Symphony Java client.

  1. Make sure Apache Maven 3.x is installed in your workstation; run which mvn on your console to check
  2. Clone this repo - git clone https://github.com/symphonyoss/symphony-java-sample-bots.git ; cd symphony-java-sample-bots
  3. Create a symphony.properties file in the project root - cp symphony.properties.sample symphony.properties
  4. Follow the instructions below to put the right configuration

Bot configuration

Open symphony.properties and edit the properties documented below.

Symphony API endpoints

sessionauth.url=https://foundation-dev-api.symphony.com/sessionauth
keyauth.url=https://foundation-dev-api.symphony.com/keyauth
pod.url=https://foundation-dev.symphony.com/pod
agent.url=https://foundation-dev.symphony.com/agent

The Symphony API endpoints, defaulting to the Foundation Developer Pod values; make sure that you have access to these endpoints, using curl or similar commands.

SSL endpoints truststore

truststore.file=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/security/cacerts
truststore.password=changeit

The certificate truststore to validate SSL certificates of the Symphony API endpoints; if the server is using certificates that are not included in the default JVM bundle, you can specify the location of a custom truststore to use.

Make sure to locate the cacert file of your JVM; in OSX, the command is $(/usr/libexec/java_home) /jre/lib/security/cacerts, check this article for other platforms.

Symphony service account

user.cert.file=./certs/bot.user.p12
user.cert.password=changeit
[email protected]

These properties identify the Symphony service account that will impersonate the bot; to authenticate, it needs a P12 certificate released by the Symphony pod administrator (and its related password).

If you don't have a Symphony pod, you can apply for a [14 day trial of the Foundation Developer Pod](symphony .foundation/odp).

To validate your p12 certificate, try openssl pkcs12 -info -in <file-name>.p12.

Running behind an HTTP proxy

The bot configuration allows to define a proxy.url parameter that will configure SJC accordingly; the code is part of Utils.java and relies on jersey-apache-connector-2.23.1 and javax.ws .rs-api-2.1 libraries, defined in pom.xml

Other bot configurations

Specifies the email of the Symphony user that should receive the message; it is only used by HelloWorldBot and RssBot.

rss.url=https://twitrss.me/twitter_user_to_rss/?user=symphonyoss
rss.limit=3

Specifies the source and limit of the RSS feed used by RssBot

Building the project

Simply type mvn package and a uberjar will be created in the ./target folder.

Running the Bots

Assuming the Maven is executed, you can run each sample bot using the following Java command:

export SYMPHONY_CONFIG_FILE=symphony.properties
java -Xmx1024m -classpath target/symphony-java-sample-bots-0.9.1-SNAPSHOT.jar org.symphonyoss.samples.HelloWorldBot

You can replace HelloWorldBot with the other samples mentioned before. For OSX/Linux users, a run-bot.sh is provided.

If you're running on Windows, you should use set instead of export.

If you're using Java 9 (check with java -version), please add --add-modules java.activation right after the java element in the commandline reported above.

Integration testing

This project ships with EchoBotIT, a simple example of integration testing using the Symphony Java client.

To configure it, you must create a symphony.properties.it configuration file (checkout symphony.properties.it .sample), which will be used to instanciate a second client that listens to the sender's messages.

Make sure that user.email in symphony.properties.it matches with sender.email defined in symphony.properties.

To run it, simply type:

export SYMPHONY_CONFIG_FILE=symphony.properties.it
mvn clean install -Pintegration-testing

Dependencies

This project uses the following libraries:

Contribute

Please read our Contribution guidelines and access our issue tracker on Github.

Project team

  • Maurizio (maoo) Pillitu - Devops Director at the Symphony Software Foundation ; Project leader, Administrator and main developer of the project
  • Frank (ftbb) Tarsillo - MD at IHS MarkIT ; Administrator and support developer of the project; he's also the Project leader of the Symphony Java Client

All Administrators can:

  • Access to the project build settings (on Travis CI)
  • Access SonarCloud, Coverity, WhiteSource (or any other reporting system) to manage authentication keys connected with CI build
  • Deploy artifacts (nightly build snapshots) on Sonatype and (releases on) Maven Central The OpenShift Online environment, used for Continuous Delivery (against the Symphony Foundation Developer pod), can is managed by the Foundation Infra team

Governance model

This project is largely self-governed; to know more, please read on https://symphonyoss.atlassian.net/wiki/display/FM/Project+Governance

About

A set of simple Bots for Symphony, implemented in Java.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published