Symphony Developer - configure a bot for BDK 2.0

Note: Node Package Manager (NPM) needs to be installed on your local machine for the bot configuration to work

 

To generate a bot, the user needs to build their project using the Symphony Bot Generator. This offers a fast way to bootstrap your Symphony BDK project in several languages, including Java:

$ npm i -g generator-symphony
$ mkdir botProject && cd botProject
$ yo symphony 2.0

From here, enter the bot's metadata, use arrows to scroll, then press Enter to move to the next prompt.

 

For Spring Boot Integration, the Symphony Bot Generator and BDK 2.0 provides an out-of-the-box solution. To bootstrap your bot as a Spring Boot project, select the Spring Boot option when prompted to select your framework from the generator's options:

$ yo symphony 2.0

https://developers.symphony.com

Welcome to Symphony Generator v1.4.3
Application files will be generated in folder: /Users/USER/bdk-documentation-bot
______________________________________________________________________________________________________
? Enter your pod host develop2.symphony.com
? Enter your bot username bdk-documentation-bot
? Select your programing language Java (beta)
? Select your build system Maven
? Select your framework Java (no framework)
? Enter your project groupId com.symphony
? Enter your project artifactId bot-application
? Enter your base package com.symphony.java
Generating RSA keys...
...
-----BEGIN RSA PUBLIC KEY-----
MIICCgKCAgEAlToybEs8ovplnlYCrmVp9l81GAUC+JxK2RIjMleQS2giH/9EHuwlmskgp40Z
QcFXQvaXdryo8ftPoZS32KdcvB7kbC0eX1nltPRHic+e/fQAu4N1A0hTQGd8kGQ3CUabNOeN
VsahEj7P2OrIfsN4+5kOEV5JHIA1kSsB/csLETAyDuMPoGqEE7Nm8MMlO/74WezG7R8EmIlH
HnOlz9qtaZH4SOCrMTj7mY0zy3HtYztnBcAPuclbaHoQWkh05EdSE2j4SjlZpNe9aD9gSjLQ
3dYmTfrQZMC8Dqlfm2yDG5jr78jUY9sXPAM8UThjl2i4YrnH6kH5kj1tujn4RaF++tzU1uVJ
W30HEi6hzVsnbUfvv1qEo5v8AZYc91TN6tLMuClGz4h7RmejX3yRBYV90csaqhyvJQlBLR/r
RAo6mv+7PaAK5rPvZVbH1ogW1UBQnYaGfCu4OxAWTXNnUO9g6yuVr3LVxsLlpEkltNj9Hn60
YD9i/FwNKtxsPja0vQXxqrmaNAHZkSbhVsRPaZZArBSnSbEWyNoE+GN26D5rWtK9ubjDzD0e
6G4FrGZeX/oyYb1BhmgQ3WRddEzF8y0cltzuckVnPJY0jEc3THhmOPZfNjwiONlVeHOPP8qk
aRby39IdyszVeVTbNlq727vxCJFzzUxx8VpaSlB0P3byypcCAwEAAQ==
-----END RSA PUBLIC KEY-----

To use Maven as the build system, the user must configure the root pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>symphony-bdk</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>symphony-bdk</name>
<description>Demo project for Symphony BDK</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.symphony.platformsolutions</groupId>
<artifactId>symphony-bdk-bom</artifactId>
<version>1.3.2.BETA</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- Core dependencies -->
<dependency>
<groupId>com.symphony.platformsolutions</groupId>
<artifactId>symphony-bdk-core</artifactId>
</dependency>
<dependency>
<groupId>com.symphony.platformsolutions</groupId>
<artifactId>symphony-bdk-http-jersey2</artifactId> <!-- or symphony-bdk-http-webclient -->
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.symphony.platformsolutions</groupId>
<artifactId>symphony-bdk-template-freemarker</artifactId> <!-- or symphony-bdk-http-handlebars -->
<scope>runtime</scope>
</dependency>
<!-- Logger Configuration -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>

To use Gradle as the build system, the user must configure the root build.gradle:

plugins {
id 'java-library'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {

// import a BOM
implementation platform('com.symphony.platformsolutions:symphony-bdk-bom:1.3.2.BETA')

// define dependencies without versions
implementation 'com.symphony.platformsolutions:symphony-bdk-core'
runtimeOnly 'com.symphony.platformsolutions:symphony-bdk-http-jersey2' // or symphony-bdk-http-webclient
runtimeOnly 'com.symphony.platformsolutions:symphony-bdk-template-freemarker' // or symphony-bdk-http-handlebars

// logger configuration
implementation 'org.slf4j:slf4j-api'
runtimeOnly 'ch.qos.logback:logback-classic'
}

After generating the bot scaffold, the next step is to configure a bot user.

 

First, ensure that the administrator for the pod has created a corresponding service account via the Admin Portal. Additionally, upload the generated RSA public key for the service account created.

 

Second, copy the entire contents of the RSA public key (including the dashes on either side) and give this to the administrator of the pod. Request for this key to be saved against the respective service account you will be using (Figure 1):

 

1.png

Figure 1 Service Account Authentication

 

Note: The bot username and email address entered to the Symphony Bot Generator must be identical to the basic information displayed in the pod 

 

The final stage is to create a configuration file. Before implementing any code, the user needs to navigate to the src/main/resources/config.yaml file and adjust it for the Symphony environment. The following configuration file is generated by default:
host: develop2.symphony.com
bot:
username: bdk-documentation-bot
privateKeyPath: /bdk-documentation-bot/src/main/resources/rsa/privatekey.pem

Note: Depending on the Symphony environment, additional values/amendments to the configuration file may be required