Slack Connector

Configuring SearchBlox

Before using Slack Connector, SearchBlox has to be installed and set up successfully. Then create a Custom Collection.

1036

Configuring Slack Connector

Prerequisite

JAVA JDK
Install Java JDK 1.8.x for the Slack Connector to work. The environment variable is set as shown here (for Windows):

  JAVA_HOME = C:\Program Files\Java\jdk1.8.0_31

Link to download Java: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
For Linux, please make sure that JDK1.8 is installed in the server.

Kafka and Zookeeper

Windows

  • Go to C:\Kafka\config\server.properties and edit the line “log.dirs=/tmp/kafka-logs” to “log.dir= C:\Kafka\kafka-logs”.
  • Go to C:\Kafka\config\zookeeper.properties and edit the line “dataDir=/tmp/zookeeper-logs” to “dataDir=C:\Kafka\zookeeper-logs”.

Start Zookeeper
Start the Zookeeper service first.
In Windows, open the command prompt, then go to C:\kafka\bin\Windows and run the following command:

    zookeeper-server-start.bat C:\Kafka\config\zookeeper.properties
    

In Linux, open the terminal then go to /opt/Kafka/bin and run the following command:

   ./zookeeper-server-start.sh /opt/Kafka/config/zookeeper.properties

Start Kafka service
Open another command prompt/terminal.
In Windows, open the command prompt, then go to C:\kafka\bin\Windows and run the following command:

    kafka-server-start.bat C:\Kafka\config\server.properties

In Linux, open the terminal, then go to /opt/Kafka/bin and run the following command:

    ./kafka-server-start.sh /opt/Kafka/config/server.properties

Steps to Set Up Slack Connector
Please contact [email protected] to request the download link for SearchBlox Slack connector.

  • Download the SearchBlox Slack connector. Extract the downloaded zip file to C:\searchblox-slack-bot for Windows, and /opt/searchblox-slack-bot for Linux, and name the folder searchblox-slack-bot.
  • Unzip searchblox-slack-connector.zip under C:* or /opt*.
  • After extracting, C:\searchblox-slack-bot or /opt/searchblox-slack-bot should contain: searchblox-slack-bot-0.1.0.jar, application.properties and this readme.txt

🚧

Note:

In Linux, make sure that the necessary permissions have been provided to the folder /opt by using the CHMOD command for writing log files and executing jar files.

1017

Enter the details in C:/searchblox-slack-bot/application.properties or \opt\searchblox-slack-bot\application.properties. The properties with the prefix slackapi are slack properties. The properties with prefix zookeeper are Zookeeper properties. The properties with prefix Kafka are Kafka properties. The properties with prefix searchblox are SearchBlox properties.** *

slackapi.authenticationTokenSlack authentication token.
kafka.topicThe chat stream.
kafka.hostNameHostname where Kafka runs.
kafka.portDefault Kafka port number.
zookeeper.hostNameHostname where Zookeeper runs.
zookeeper.portZookeeper port number of. Default is 2181.
searchblox.restJsonApiSearchBlox rest API URL. Make changes based on IPaddress and port number used.
searchblox.apiKeySearchBlox application's API key in Menu → Admin.
searchblox.colnameName of custom collection.
  • The application.properties content details are provided here:
#slack authentication token
slackapi.authenticationToken = xoxp-141561976914-140855357792-141890124018-5e3bf599ec71b8c12fe44d13f75e9dd1

#kafka properties
kafka.topic = chat-stream
kafka.hostName = localhost
kafka.port = 9092

#zookeeper properties
zookeeper.hostName = localhost
zookeeper.port = 2181

#searchblox properties
searchblox.restJsonApi  = http://localhost:8080/searchblox/rest/v1/api/add
searchblox.apiKey = 21E176E310D04536534D1890674DCAC4
searchblox.colName = slack
  • Start SearchBlox.
  • Make sure to run Zookeeper first, and then Kafka, using the steps outlined in the preceding prerequisites section.
  • The log files will be written to C:\searchblox-slack-bot or /opt/searchblox-slack-bot.
  • Port 8181 must available before running the following command. If it is not available, change -Dserver.port number to any available port number.
  • For Windows, open the command prompt, go to C:\searchblox-slack-bot and execute:
    java -DLOG_PATH="C:\searchblox-slack-bot" -DLOG_LEVEL=DEBUG -DpropertySource=file:C:/searchblox-slack-bot/application.properties -Dserver.port=8181 -jar searchblox-slack-bot-0.1.0.jar
  • For Linux, open the command prompt, go to /opt/searchblox-slack-bot and execute:
    java -DLOG_PATH="/opt/searchblox-slack-bot" -DLOG_LEVEL=DEBUG -DpropertySource=file:/opt/searchblox-slack-bot/application.properties -Dserver.port=8181 -jar searchblox-slack-bot-0.1.0.jar.
668

Once the connector gets started, messages that are sent to the #general or #random channel in Slack will be indexed simultaneously.

🚧

Note:

The log level in the above command is set to DEBUG, this prints out the detailed explanation of requests and responses to the log. This can be changed to INFO for a short explanation.