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
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.
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 terminatesorg.symphonyoss.samples.EchoBot
; listens and posts back messages on 1:1 and group Symphony chatsorg.symphonyoss.samples.StockInfoBot
; listens to 1:1 and group Symphony chats, checks messages for cashtags and posts related data extracted from Yahoo Finance APIorg.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.Follow these instructions to get started with this project and run your first java application using the Symphony Java client.
which mvn
on your console
to checkgit clone https://github.com/symphonyoss/symphony-java-sample-bots.git ; cd symphony-java-sample-bots
symphony.properties
file in the project root - cp symphony.properties.sample symphony.properties
Open symphony.properties
and edit the properties documented below.
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.
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.
user.cert.file=./certs/bot.user.p12
user.cert.password=changeit
user.email=bot.user@YOURNAME.com
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.
To validate your p12 certificate, try openssl pkcs12 -info -in <file-name>.p12
.
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
receiver.email=your.name@YOURNAME.com
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
Simply type mvn package
and a uberjar will be created in the ./target
folder.
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.
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
This project uses the following libraries:
Please read our Contribution guidelines and access our issue tracker on Github.
All Administrators can:
This project is largely self-governed; to know more, please read on https://symphonyoss.atlassian.net/wiki/display/FM/Project+Governance