Skip to main content

Connecting Slack to JAICF project

To connect the Slack channel to the JAICF project, please follow these steps:

  1. Prepare the project.
  2. Create a channel.
  3. Test the bot.

Prepare the project

Before connecting the channel, prepare the JAICF project in advance:

  1. Specify the following in the dependencies of build.gradle.kts file:
dependencies {
// ...
implementation("com.just-ai.jaicf:jaicp:$jaicfVersion")
implementation("com.just-ai.jaicf:slack:$jaicfVersion")
}
tip
Don’t forget to substitute $jaicfVersion with the latest framework version.
  1. Configure depending on the connection method to the platform:
  • long polling — the bot will connect to the Just AI server when interacting with the platform. Simple solution, convenient for local development, and debugging.

    For this method, specify SlackChannel in the JaicpPoller.kt file:

package com.just-ai.jaicf.template.connections

fun main() {
JaicpPollingConnector(
templateBot,
accessToken,
channels = listOf(
ChatApiChannel,
ChatWidgetChannel,
TelephonyChannel,
SlackChannel
)
).runBlocking()
}
  • webhook — the bot will receive messages from the platform using the specified link. Must be configured to connect JAICP Cloud.

    For this method, specify the channel SlackChannel in the JaicpServer.kt file:

package com.just-ai.jaicf.template.connections

fun main() {
JaicpServer(
botApi = templateBot,
accessToken = accessToken,
channels = listOf(
ChatApiChannel,
ChatWidgetChannel,
TelephonyChannel,
SlackChannel
)
).start(wait = true)
}

Create a channel

To create a channel please follow the instructions.

Testing the bot

Open the bot dialog window in Slack and select your bot from the list in the Apps subsection. Send it a welcome/activation phrase provided by your script. After that, your dialog with the bot should begin.