Configure your Bot for BDK 2.0

1. Generate your Bot

Building your Project using the Symphony Bot Generator

This section requires npm (Node Package Manager) to be installed on your local machine as a prerequisite.
For all Symphony BDK applications, you should start with the Symphony Bot Generator. The Symphony Generator offers a fast way to bootstrap your Symphony BDK project in several languages, including Java:
1
$ npm i -g generator-symphony
2
$ mkdir botProject && cd botProject
3
$ yo symphony 2.0
Copied!
This will prompt you with a number of questions about your bot and Pod configuration. Type in your bot's metadata, use arrows to scroll, and press enter to move on to the next prompt:

Spring Boot Integration

The BDK 2.0 and Symphony Bot Generator provides an available Spring Boot Integration out of the box. To bootstrap your bot as a Spring Boot project, select the 'Spring Boot' option when prompted to 'select your framework' when going through the generator's options.
1
$ yo symphony 2.0
2
__ __ ___ _
3
\ \ / /__ / __|_ _ _ __ _ __| |_ ___ _ _ _ _
4
\ V / _ \ \__ \ || | ' \| '_ \ ' \/ _ \ ' \ || |
5
|_|\___/ |___/\_, |_|_|_| .__/_||_\___/_||_\_, |
6
|__/ |_| |__/
7
https://developers.symphony.com
8
9
Welcome to Symphony Generator v1.4.3
10
Application files will be generated in folder: /Users/reed.feldman/bdk-documentation-bot
11
______________________________________________________________________________________________________
12
? Enter your pod host develop2.symphony.com
13
? Enter your bot username bdk-documentation-bot
14
? Select your programing language Java (beta)
15
? Select your build system Maven
16
? Select your framework Java (no framework)
17
? Enter your project groupId com.symphony
18
? Enter your project artifactId bot-application
19
? Enter your base package com.symphony.java
20
Generating RSA keys...
21
...
22
-----BEGIN RSA PUBLIC KEY-----
23
MIICCgKCAgEAlToybEs8ovplnlYCrmVp9l81GAUC+JxK2RIjMleQS2giH/9EHuwlmskgp40Z
24
QcFXQvaXdryo8ftPoZS32KdcvB7kbC0eX1nltPRHic+e/fQAu4N1A0hTQGd8kGQ3CUabNOeN
25
VsahEj7P2OrIfsN4+5kOEV5JHIA1kSsB/csLETAyDuMPoGqEE7Nm8MMlO/74WezG7R8EmIlH
26
HnOlz9qtaZH4SOCrMTj7mY0zy3HtYztnBcAPuclbaHoQWkh05EdSE2j4SjlZpNe9aD9gSjLQ
27
3dYmTfrQZMC8Dqlfm2yDG5jr78jUY9sXPAM8UThjl2i4YrnH6kH5kj1tujn4RaF++tzU1uVJ
28
W30HEi6hzVsnbUfvv1qEo5v8AZYc91TN6tLMuClGz4h7RmejX3yRBYV90csaqhyvJQlBLR/r
29
RAo6mv+7PaAK5rPvZVbH1ogW1UBQnYaGfCu4OxAWTXNnUO9g6yuVr3LVxsLlpEkltNj9Hn60
30
YD9i/FwNKtxsPja0vQXxqrmaNAHZkSbhVsRPaZZArBSnSbEWyNoE+GN26D5rWtK9ubjDzD0e
31
6G4FrGZeX/oyYb1BhmgQ3WRddEzF8y0cltzuckVnPJY0jEc3THhmOPZfNjwiONlVeHOPP8qk
32
aRby39IdyszVeVTbNlq727vxCJFzzUxx8VpaSlB0P3byypcCAwEAAQ==
33
-----END RSA PUBLIC KEY-----
Copied!

Building your project from scratch

This section will help you to understand how to create your bot application from scratch.

Maven-based project

If you want to use Maven as build system, you have to configure your root pom.xml as such:
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0"
3
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
<modelVersion>4.0.0</modelVersion>
6
7
<groupId>com.example</groupId>
8
<artifactId>symphony-bdk</artifactId>
9
<version>0.0.1-SNAPSHOT</version>
10
<name>symphony-bdk</name>
11
<description>Demo project for Symphony BDK</description>
12
13
<dependencyManagement>
14
<dependencies>
15
<dependency>
16
<groupId>com.symphony.platformsolutions</groupId>
17
<artifactId>symphony-bdk-bom</artifactId>
18
<version>1.3.2.BETA</version>
19
<type>pom</type>
20
<scope>import</scope>
21
</dependency>
22
</dependencies>
23
</dependencyManagement>
24
25
<dependencies>
26
<!-- Core dependencies -->
27
<dependency>
28
<groupId>com.symphony.platformsolutions</groupId>
29
<artifactId>symphony-bdk-core</artifactId>
30
</dependency>
31
<dependency>
32
<groupId>com.symphony.platformsolutions</groupId>
33
<artifactId>symphony-bdk-http-jersey2</artifactId> <!-- or symphony-bdk-http-webclient -->
34
<scope>runtime</scope>
35
</dependency>
36
<dependency>
37
<groupId>com.symphony.platformsolutions</groupId>
38
<artifactId>symphony-bdk-template-freemarker</artifactId> <!-- or symphony-bdk-http-handlebars -->
39
<scope>runtime</scope>
40
</dependency>
41
<!-- Logger Configuration -->
42
<dependency>
43
<groupId>org.slf4j</groupId>
44
<artifactId>slf4j-api</artifactId>
45
</dependency>
46
<dependency>
47
<groupId>ch.qos.logback</groupId>
48
<artifactId>logback-classic</artifactId>
49
<scope>runtime</scope>
50
</dependency>
51
</dependencies>
52
</project>
Copied!

Gradle-based project

If you want to use Gradle as build system, you have to configure your root build.gradle as such:
1
plugins {
2
id 'java-library'
3
}
4
5
group = 'com.example'
6
version = '0.0.1-SNAPSHOT'
7
8
repositories {
9
mavenCentral()
10
}
11
12
dependencies {
13
14
// import a BOM
15
implementation platform('com.symphony.platformsolutions:symphony-bdk-bom:1.3.2.BETA')
16
17
// define dependencies without versions
18
implementation 'com.symphony.platformsolutions:symphony-bdk-core'
19
runtimeOnly 'com.symphony.platformsolutions:symphony-bdk-http-jersey2' // or symphony-bdk-http-webclient
20
runtimeOnly 'com.symphony.platformsolutions:symphony-bdk-template-freemarker' // or symphony-bdk-http-handlebars
21
22
// logger configuration
23
implementation 'org.slf4j:slf4j-api'
24
runtimeOnly 'ch.qos.logback:logback-classic'
25
}
Copied!

2. Configure your Bot

Once you have your generated bot scaffold, the next step is to configure your bot user.
Ensure that your pod admin has created a corresponding service account on the admin portal of your Symphony Pod. Additionally, you must upload the generated RSA public key for the service account created.
Copy the entire contents of this RSA public key including the dashes on either side, and hand it to your pod admin and request for it to be saved against the respective service account you will be using.
Note: The bot username and bot email address entered to the Symphony Bot Generator must match exactly the Basic Information shown in the Pod above.

Create configuration file

Before implementing any code, you need to navigate to your src/main/resources/config.yaml configuration file, and adjust it according to your Symphony environment. The following configuration file is generated by default:
src/main/resources/config.yaml
1
host: develop2.symphony.com
2
3
bot:
4
username: bdk-documentation-bot
5
privateKeyPath: /bdk-documentation-bot/src/main/resources/rsa/privatekey.pem
Copied!
Depending on your Symphony environment you may need to make update and add additional values to your config.yaml file.

Click here for more detailed documentation about BDK configuration

3. Build your Bot

Now that you have configured your Bot project using the BDK 2.0 and Symphony Bot Generator, checkout one of our dedicated BDK 2.0 tutorials: